From 3a155a52de7d0adb6373868b2792bcdab949493c Mon Sep 17 00:00:00 2001 From: river Date: Mon, 14 Aug 2023 17:30:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20[#4]=20=E6=94=AF=E6=8C=81=E7=94=B5?= =?UTF-8?q?=E8=AF=9D=E5=8F=B7=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/BaseSchema/dataWriter.spec.ts | 4 ++-- utils/BaseSchema/tableParser.spec.ts | 2 +- utils/BaseSchema/tableParser.ts | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/utils/BaseSchema/dataWriter.spec.ts b/utils/BaseSchema/dataWriter.spec.ts index 63e4eab..71fb45b 100644 --- a/utils/BaseSchema/dataWriter.spec.ts +++ b/utils/BaseSchema/dataWriter.spec.ts @@ -91,7 +91,7 @@ const resultExample2 = { const resultExample3 = { Height: 180 }; const resultExample4 = { is_novel: true }; const resultExample5 = { score: 4 }; -const resultExample6 = { phone: 13800000000 }; +const resultExample6 = { phone: "13800000000" }; describe("dataWriter init", () => { it("should init", function () { @@ -186,7 +186,7 @@ describe("parse phone", () => { it("should parse phone field", () => { expect( core.load(resultExample6).parseOneField(tableInfo.fields[6]), - ).toEqual(4); + ).toEqual("13800000000"); }); }); describe("parse all type", () => { diff --git a/utils/BaseSchema/tableParser.spec.ts b/utils/BaseSchema/tableParser.spec.ts index 1e7bb42..7b2d6c5 100644 --- a/utils/BaseSchema/tableParser.spec.ts +++ b/utils/BaseSchema/tableParser.spec.ts @@ -128,7 +128,7 @@ describe("BaseSchema class format", () => { }); it("should format phone fields", function () { - expect(core.formatNumberField(tableInfo.fields[6])).toBe(`phone: number;`); + expect(core.formatPhoneField(tableInfo.fields[6])).toBe(`phone: string;`); }); it("should format title", function () { diff --git a/utils/BaseSchema/tableParser.ts b/utils/BaseSchema/tableParser.ts index d8eac4a..5939d04 100644 --- a/utils/BaseSchema/tableParser.ts +++ b/utils/BaseSchema/tableParser.ts @@ -53,6 +53,9 @@ export class TableParser { formatNumberField(iBaseFieldMeta: IBaseFieldMeta) { return `${iBaseFieldMeta.name}: number;`; } + formatPhoneField(iBaseFieldMeta: IBaseFieldMeta) { + return `${iBaseFieldMeta.name}: string;`; + } formatBooleanField(iBaseFieldMeta: IBaseFieldMeta) { return `${iBaseFieldMeta.name}: boolean;`; @@ -67,7 +70,7 @@ export class TableParser { case 99003: // 货币 case 99002: // 进度 case 13: // 电话 - return this.formatNumberField(field); + return this.formatPhoneField(field); case 3: return this.formatSelectField(field); case 4: