增加了date和time的数据类型

This commit is contained in:
Xu Chang 2023-03-09 22:23:57 +08:00
parent 7b94be3082
commit 7b0150896c
5 changed files with 24 additions and 44 deletions

View File

@ -2938,15 +2938,13 @@ function constructAttributes(entity) {
], true))); ], true)));
break; break;
} }
case 'Float': { case 'Double':
attrAssignments.push(factory.createPropertyAssignment(factory.createIdentifier("type"), factory.createStringLiteral("float")), factory.createPropertyAssignment(factory.createIdentifier("params"), factory.createObjectLiteralExpression([ case 'Float':
factory.createPropertyAssignment(factory.createIdentifier("precision"), factory.createNumericLiteral(typeArguments[0].literal.text)), case 'Decimal': {
factory.createPropertyAssignment(factory.createIdentifier("scale"), factory.createNumericLiteral(typeArguments[1].literal.text)) if (['Double', 'Float'].includes(text)) {
], true))); console.warn("".concat(entity, "\u5BF9\u8C61\u4E2D\u8FD8\u6709").concat(text, "\u7C7B\u578B\u5B9A\u4E49\uFF0C\u73B0\u5728\u7EDF\u4E00\u7528Decimal\u8FDB\u884C\u5B58\u50A8"));
break;
} }
case 'Double': { attrAssignments.push(factory.createPropertyAssignment(factory.createIdentifier("type"), factory.createStringLiteral("decimal")), factory.createPropertyAssignment(factory.createIdentifier("params"), factory.createObjectLiteralExpression([
attrAssignments.push(factory.createPropertyAssignment(factory.createIdentifier("type"), factory.createStringLiteral("double")), factory.createPropertyAssignment(factory.createIdentifier("params"), factory.createObjectLiteralExpression([
factory.createPropertyAssignment(factory.createIdentifier("precision"), factory.createNumericLiteral(typeArguments[0].literal.text)), factory.createPropertyAssignment(factory.createIdentifier("precision"), factory.createNumericLiteral(typeArguments[0].literal.text)),
factory.createPropertyAssignment(factory.createIdentifier("scale"), factory.createNumericLiteral(typeArguments[1].literal.text)) factory.createPropertyAssignment(factory.createIdentifier("scale"), factory.createNumericLiteral(typeArguments[1].literal.text))
], true))); ], true)));

View File

@ -8,12 +8,14 @@ export declare type Text = string;
export declare type Image = string; export declare type Image = string;
export declare type File = string; export declare type File = string;
export declare type Datetime = number | Date; export declare type Datetime = number | Date;
export declare type Day = number | Date;
export declare type Time = number | Date;
export declare type Boolean = boolean; export declare type Boolean = boolean;
export declare type Price = number; export declare type Price = number;
export declare type PrimaryKey = string; export declare type PrimaryKey = string;
export declare type ForeignKey<E extends string> = string; export declare type ForeignKey<E extends string> = string;
export declare type Sequence = string; export declare type Sequence = string;
export { Geo, SingleGeo } from './Geo'; export { Geo, SingleGeo } from './Geo';
export declare type DataTypes = number | string | Datetime | Geo | Object | SingleGeo; export declare type DataTypes = number | string | Datetime | Day | Time | Geo | Object | SingleGeo;
export declare const types: string[]; export declare const types: string[];
export declare const unIndexedTypes: string[]; export declare const unIndexedTypes: string[];

View File

@ -1,5 +1,6 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.unIndexedTypes = exports.types = void 0; exports.unIndexedTypes = exports.types = void 0;
exports.types = ['Int', 'Uint', 'Double', 'Float', 'String', 'Text', 'Datetime', 'Boolean', 'Image', 'File', 'Geo', 'SingleGeo', 'Price']; exports.types = ['Int', 'Uint', 'Double', 'Float', 'String', 'Text', 'Datetime', 'Day', 'Time',
'Boolean', 'Image', 'File', 'Geo', 'SingleGeo', 'Price'];
exports.unIndexedTypes = ['Text', 'Image', 'File', 'Object']; exports.unIndexedTypes = ['Text', 'Image', 'File', 'Object'];

View File

@ -5340,40 +5340,16 @@ function constructAttributes(entity: string): ts.PropertyAssignment[] {
); );
break; break;
} }
case 'Float': { case 'Double':
attrAssignments.push( case 'Float':
factory.createPropertyAssignment( case 'Decimal': {
factory.createIdentifier("type"), if (['Double', 'Float'].includes(text)) {
factory.createStringLiteral("float") console.warn(`${entity}对象中还有${text}类型定义现在统一用Decimal进行存储`);
),
factory.createPropertyAssignment(
factory.createIdentifier("params"),
factory.createObjectLiteralExpression(
[
factory.createPropertyAssignment(
factory.createIdentifier("precision"),
factory.createNumericLiteral(
(<ts.NumericLiteral>(<ts.LiteralTypeNode>typeArguments![0]).literal).text
)
),
factory.createPropertyAssignment(
factory.createIdentifier("scale"),
factory.createNumericLiteral(
(<ts.NumericLiteral>(<ts.LiteralTypeNode>typeArguments![1]).literal).text
)
)
],
true
)
)
);
break;
} }
case 'Double': {
attrAssignments.push( attrAssignments.push(
factory.createPropertyAssignment( factory.createPropertyAssignment(
factory.createIdentifier("type"), factory.createIdentifier("type"),
factory.createStringLiteral("double") factory.createStringLiteral("decimal")
), ),
factory.createPropertyAssignment( factory.createPropertyAssignment(
factory.createIdentifier("params"), factory.createIdentifier("params"),

View File

@ -9,6 +9,8 @@ export type Text = string;
export type Image = string; export type Image = string;
export type File = string; export type File = string;
export type Datetime = number | Date; export type Datetime = number | Date;
export type Day = number | Date;
export type Time = number | Date;
export type Boolean = boolean; export type Boolean = boolean;
export type Price = number; export type Price = number;
export type PrimaryKey = string; export type PrimaryKey = string;
@ -16,7 +18,8 @@ export type ForeignKey<E extends string> = string;
export type Sequence = string; // 自增长序列为了让人阅读方便为了支持分布式这里用string底层实现可自定义 export type Sequence = string; // 自增长序列为了让人阅读方便为了支持分布式这里用string底层实现可自定义
export { Geo, SingleGeo } from './Geo'; export { Geo, SingleGeo } from './Geo';
export type DataTypes = number | string | Datetime | Geo | Object | SingleGeo; export type DataTypes = number | string | Datetime | Day | Time | Geo | Object | SingleGeo;
export const types = ['Int', 'Uint', 'Double', 'Float', 'String', 'Text', 'Datetime', 'Boolean', 'Image', 'File', 'Geo', 'SingleGeo', 'Price']; export const types = ['Int', 'Uint', 'Double', 'Float', 'String', 'Text', 'Datetime', 'Day', 'Time',
'Boolean', 'Image', 'File', 'Geo', 'SingleGeo', 'Price'];
export const unIndexedTypes = ['Text', 'Image', 'File', 'Object']; export const unIndexedTypes = ['Text', 'Image', 'File', 'Object'];