Skip to content

Commit

Permalink
feat: [#4] 支持电话号码
Browse files Browse the repository at this point in the history
  • Loading branch information
Leizhenpeng committed Aug 14, 2023
1 parent a8742ff commit 3a155a5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions utils/BaseSchema/dataWriter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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", () => {
Expand Down
2 changes: 1 addition & 1 deletion utils/BaseSchema/tableParser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
5 changes: 4 additions & 1 deletion utils/BaseSchema/tableParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;`;
Expand All @@ -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:
Expand Down

0 comments on commit 3a155a5

Please sign in to comment.