Skip to main content
Version: 3.10

Entity 实体

1. 结构声明

class Entity extends Annotatable {
name: string = '';
uuid: uuid = createUUID();
tableName: string;
description?: string;
origin: 'ide' | 'sql' | 'table' | 'excel' | 'view' = 'ide';
properties: Array<EntityProperty>;
indexes: Array<EntityIndex>;
}

2. 节点示例

(1) 示例

AST 如下:

{
"concept": "Entity",
"name": "Product",
"description": "",
"uuid": "bd624ce40865488faff6d6e6a5f04422",
"tableName": "product",
"origin": "ide",
"properties": [
{
"concept": "EntityProperty",
"name": "id",
"uuid": "4a1d95bf7a3c4c14a6b0e19da915908c",
"columnName": "id",
"label": "主键",
"description": "主键",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
},
"required": true,
"primaryKey": true,
"display": {
"inTable": false,
"inFilter": false,
"inForm": false,
"inDetail": false
},
"rules": [],
"generationRule": "auto",
"sequence": "Entity11050486256"
},
{
"concept": "EntityProperty",
"name": "createdTime",
"uuid": "a64b6d6b317a4e6f84532986d7c35aa3",
"columnName": "created_time",
"label": "创建时间",
"description": "创建时间",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "DateTime",
"inferred": false,
"ruleMap": {}
},
"display": {
"inTable": true,
"inFilter": false,
"inForm": false,
"inDetail": false
},
"rules": [],
"generationRule": "auto"
},
{
"concept": "EntityProperty",
"name": "updatedTime",
"uuid": "24167f6184964537857b4031479f0262",
"columnName": "updated_time",
"label": "更新时间",
"description": "更新时间",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "DateTime",
"inferred": false,
"ruleMap": {}
},
"display": {
"inTable": true,
"inFilter": false,
"inForm": false,
"inDetail": false
},
"rules": [],
"generationRule": "auto"
},
{
"concept": "EntityProperty",
"name": "createdBy",
"uuid": "971e11c2bf224828a7f328417049f94b",
"columnName": "created_by",
"label": "创建者",
"description": "创建者",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "String",
"inferred": false,
"ruleMap": {}
},
"display": {
"inTable": false,
"inFilter": false,
"inForm": false,
"inDetail": false
},
"rules": [],
"generationRule": "auto"
},
{
"concept": "EntityProperty",
"name": "updatedBy",
"uuid": "8c409bb2165946358064f43b334fb5a6",
"columnName": "updated_by",
"label": "更新者",
"description": "更新者",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "String",
"inferred": false,
"ruleMap": {}
},
"display": {
"inTable": false,
"inFilter": false,
"inForm": false,
"inDetail": false
},
"rules": [],
"generationRule": "auto"
},
{
"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": "name",
"uuid": "f617749bae2545639102821de778add3",
"label": "",
"description": "",
"columnName": "name",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "String",
"inferred": false,
"ruleMap": {}
},
"display": {
"inDetail": true,
"inFilter": true,
"inForm": true,
"inTable": true
},
"rules": [],
"generationRule": "manual"
},
{
"concept": "EntityProperty",
"name": "category",
"uuid": "78500e51966245d984b095c7795dd21e",
"label": "",
"description": "",
"columnName": "category",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "String",
"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"
}
],
"indexes": []
}

对应的代码如下:

@(
description = "",
uuid = "bd624ce40865488faff6d6e6a5f04422",
tableName = "product",
origin = "ide",
)
entity Product {
@(
label = "主键",
description = "主键",
uuid = "4a1d95bf7a3c4c14a6b0e19da915908c",
columnName = "id",
required = true,
primaryKey = true,
generationRule = "auto",
sequence = "Entity11050486256",
)
id: Integer;

@(
label = "创建时间",
description = "创建时间",
uuid = "a64b6d6b317a4e6f84532986d7c35aa3",
columnName = "created_time",
generationRule = "auto",
)
createdTime: DateTime;

@(
label = "更新时间",
description = "更新时间",
uuid = "24167f6184964537857b4031479f0262",
columnName = "updated_time",
generationRule = "auto",
)
updatedTime: DateTime;

@(
label = "创建者",
description = "创建者",
uuid = "971e11c2bf224828a7f328417049f94b",
columnName = "created_by",
generationRule = "auto",
)
createdBy: String;

@(
label = "更新者",
description = "更新者",
uuid = "8c409bb2165946358064f43b334fb5a6",
columnName = "updated_by",
generationRule = "auto",
)
updatedBy: String;

@(
label = "",
description = "",
uuid = "8f9b69575e4c4e33b8673aefe7ada2c0",
columnName = "price",
databaseTypeAnnotation = @DatabaseTypeAnnotation(
typeName = "decimal",
arguments = [ "precision" -> "31" ],
)
,
generationRule = "manual",
)
price: Decimal;

@(
label = "",
description = "",
uuid = "f617749bae2545639102821de778add3",
columnName = "name",
generationRule = "manual",
)
name: String;

@(
label = "",
description = "",
uuid = "78500e51966245d984b095c7795dd21e",
columnName = "category",
generationRule = "manual",
)
category: String;

@(
label = "",
description = "",
uuid = "b1a9e167277e4f73b6b218eb7ede43ad",
columnName = "status",
generationRule = "manual",
)
status: app::enums::ProductStatus;
}