Skip to main content
Version: 3.6

EntityProperty 实体属性

1. 结构声明

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;
}

2. 节点示例

(1) 示例

AST 如下:

{
"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"
}

对应的代码如下:

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

(2) 带关联关系的

AST 如下:

{
"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"
}

对应的代码如下:

@(
label = "",
description = "",
uuid = "b1a9e167277e4f73b6b218eb7ede43ad",
columnName = "productId",
generationRule = "manual",
)
productId: nasl::core::Integer

(3) 带数据源类型的

AST 如下:

{
"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"
}

对应的代码如下:

@(
label = "",
description = "",
uuid = "8f9b69575e4c4e33b8673aefe7ada2c0",
columnName = "price",
databaseTypeAnnotation = @decimal(31),
generationRule = "manual",
)
price: nasl::core::Decimal