EntityProperty 实体属性
1. 结构声明
- TS Declaration
- JSON Schema
class EntityProperty extends BaseNode {
name: string = '';
uuid: uuid = createUUID();
columnName: string;
label: string;
description: string;
typeAnnotation: TypeAnnotation;
databaseTypeAnnotation?: DatabaseTypeAnnotation;
required?: boolean;
defaultValue?: DefaultValue;
primaryKey?: boolean;
relationNamespace?: string;
relationEntity?: string;
relationProperty?: string;
deleteRule?: 'protect' | 'cascade';
display: Map<string, boolean> = ({
inDetail: true,
inFilter: true,
inForm: true,
inTable: true
} as any);
rules: Array<string>;
generationRule: 'auto' | 'autoIncrement' | 'manual' = 'auto';
sequence?: string;
}
{
"type": "object",
"properties": {
"composedBy": {
"type": "array",
"items": {
"type": "string"
}
},
"name": {
"type": "string"
},
"uuid": {
"$ref": "#/definitions/uuid"
},
"columnName": {
"type": "string"
},
"label": {
"type": "string"
},
"description": {
"type": "string"
},
"typeAnnotation": {
"$ref": "#/definitions/TypeAnnotation"
},
"databaseTypeAnnotation": {
"$ref": "#/definitions/DatabaseTypeAnnotation"
},
"required": {
"type": "boolean"
},
"defaultValue": {
"$ref": "#/definitions/DefaultValue"
},
"primaryKey": {
"type": "boolean"
},
"relationNamespace": {
"type": "string"
},
"relationEntity": {
"type": "string"
},
"relationProperty": {
"type": "string"
},
"deleteRule": {
"type": "string",
"enum": [
"protect",
"cascade"
]
},
"display": {
"type": "object",
"properties": {
"size": {
"type": "number"
}
},
"required": [
"size"
],
"additionalProperties": false
},
"rules": {
"type": "array",
"items": {
"type": "string"
}
},
"generationRule": {
"type": "string",
"enum": [
"auto",
"autoIncrement",
"manual"
]
},
"sequence": {
"type": "string"
}
},
"required": [
"name",
"uuid",
"columnName",
"label",
"description",
"typeAnnotation",
"display",
"rules",
"generationRule"
],
"additionalProperties": false
}
2. 节点示例
(1) 示例
AST 如下:
- JSON
- YAML
{
"concept": "EntityProperty",
"name": "status",
"uuid": "b1a9e167277e4f73b6b218eb7ede43ad",
"label": "",
"description": "",
"columnName": "status",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "reference",
"typeNamespace": "app.enums",
"typeName": "ProductStatus",
"inferred": false,
"ruleMap": {}
},
"display": {
"inDetail": true,
"inFilter": true,
"inForm": true,
"inTable": true
},
"rules": [],
"generationRule": "manual"
}
concept: EntityProperty
name: status
uuid: b1a9e167277e4f73b6b218eb7ede43ad
label: ""
description: ""
columnName: status
typeAnnotation:
concept: TypeAnnotation
typeKind: reference
typeNamespace: app.enums
typeName: ProductStatus
inferred: false
ruleMap: {}
display:
inDetail: true
inFilter: true
inForm: true
inTable: true
rules: []
generationRule: manual
对应的代码如下:
- 文本化 NASL
@(
label = "",
description = "",
uuid = "b1a9e167277e4f73b6b218eb7ede43ad",
columnName = "status",
generationRule = "manual",
)
status: app::enums::ProductStatus
(2) 带关联关系的
AST 如下:
- JSON
- YAML
{
"concept": "EntityProperty",
"name": "productId",
"uuid": "b1a9e167277e4f73b6b218eb7ede43ad",
"label": "",
"description": "",
"columnName": "productId",
"relationNamespace": "app.dataSources.defaultDS",
"relationEntity": "Product",
"relationProperty": "id",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
},
"display": {
"inDetail": true,
"inFilter": true,
"inForm": true,
"inTable": true
},
"rules": [],
"generationRule": "manual"
}
concept: EntityProperty
name: productId
uuid: b1a9e167277e4f73b6b218eb7ede43ad
label: ""
description: ""
columnName: productId
relationNamespace: app.dataSources.defaultDS
relationEntity: Product
relationProperty: id
typeAnnotation:
concept: TypeAnnotation
typeKind: primitive
typeNamespace: nasl.core
typeName: Long
inferred: false
ruleMap: {}
display:
inDetail: true
inFilter: true
inForm: true
inTable: true
rules: []
generationRule: manual
对应的代码如下:
- 文本化 NASL
@(
label = "",
description = "",
uuid = "b1a9e167277e4f73b6b218eb7ede43ad",
columnName = "productId",
generationRule = "manual",
)
productId: nasl::core::Integer
(3) 带数据源类型的
AST 如下:
- JSON
- YAML
{
"concept": "EntityProperty",
"name": "price",
"uuid": "8f9b69575e4c4e33b8673aefe7ada2c0",
"label": "",
"description": "",
"columnName": "price",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Decimal",
"inferred": false,
"ruleMap": {
"scale": 2
}
},
"databaseTypeAnnotation": {
"concept": "DatabaseTypeAnnotation",
"typeName": "decimal",
"arguments": {
"precision": "31"
}
},
"display": {
"inDetail": true,
"inFilter": true,
"inForm": true,
"inTable": true
},
"rules": [],
"generationRule": "manual"
}
concept: EntityProperty
name: price
uuid: 8f9b69575e4c4e33b8673aefe7ada2c0
label: ""
description: ""
columnName: price
typeAnnotation:
concept: TypeAnnotation
typeKind: primitive
typeNamespace: nasl.core
typeName: Decimal
inferred: false
ruleMap:
scale: 2
databaseTypeAnnotation:
concept: DatabaseTypeAnnotation
typeName: decimal
arguments:
precision: "31"
display:
inDetail: true
inFilter: true
inForm: true
inTable: true
rules: []
generationRule: manual
对应的代码如下:
- 文本化 NASL
@(
label = "",
description = "",
uuid = "8f9b69575e4c4e33b8673aefe7ada2c0",
columnName = "price",
databaseTypeAnnotation = @decimal(31),
generationRule = "manual",
)
price: nasl::core::Decimal