M1-domain.yaml
6.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# M1 DDD聚合领域静态模型 (v2.2:EmployeeAggregate 增审核统计字段 auditApproveCount/auditRejectCount/remark/lastAuditTime;订单审核字段见 Order)
# 领域聚合唯一数据源:前端所有拖拽组件强制绑定本层字段,禁止自定义字段。
aggregates:
# 聚合1:客户聚合 CustomerAggregate
- aggregateId: CustomerAggregate
description: 客户主数据聚合,独立事务边界
aggregateRoot:
name: Customer
identifier: customerId
attributes:
- name: customerName
type: string
- name: contactPhone
type: string
constraints:
pattern: "^\\d{11}$"
patternMessage: 手机号需为 11 位数字
- name: registerTime
type: datetime
- name: customerLevel
type: string
entities: []
valueObjects: []
# 聚合2:产品聚合 ProductAggregate
- aggregateId: ProductAggregate
description: 商品主数据聚合,独立事务边界
aggregateRoot:
name: Product
identifier: productId
attributes:
- name: productName
type: string
- name: skuCode
type: string
constraints:
unique: true
- name: category
type: string
- name: saleCurrency
type: string
- name: salePrice
type: decimal
constraints:
exclusiveMin: 0
- name: stockNum
type: int
constraints:
min: 0
- name: isOnSale
type: boolean
entities: []
valueObjects: []
# 聚合3:订单聚合 OrderAggregate
- aggregateId: OrderAggregate
description: 订单业务聚合,独立事务边界
aggregateRoot:
name: Order
identifier: orderId
attributes:
- name: createTime
type: datetime
- name: totalCurrency
type: string
- name: totalAmount
type: decimal
- name: customerId
type: string
refAggregate: CustomerAggregate
refRoot: Customer
refIdentifier: customerId
description: 客户ID,引用客户聚合根主键
# 审核相关字段:由 AuditOrder 命令的 bizSteps 指令程序通用填充(非订单专用引擎代码)
- name: orderStatus
type: string
description: 订单状态(如 CREATED/PASS/REJECT),AuditOrder 按审核结果置位
- name: auditorId
type: string
refAggregate: EmployeeAggregate
refRoot: Employee
refIdentifier: employeeId
description: 审核人工号,引用员工聚合根主键
- name: auditorName
type: string
- name: auditTime
type: datetime
- name: auditRemark
type: string
- name: auditResult
type: string
description: 审核结论(PASS/REJECT)——AuditOrder 命令入参,仅用于 CONDITION_SET_FIELD 派生 orderStatus;未在 M3 建列,故为不落库的瞬态字段
relations:
- ref: OrderItem
relationType: composition
- ref: PaymentTerm
relationType: composition
- ref: DeliveryAddressEntity
relationType: composition
entities:
- name: OrderItem
localIdentifier: itemId
attributes:
- name: productId
type: string
refAggregate: ProductAggregate
refRoot: Product
refIdentifier: productId
description: 商品ID,引用产品聚合根主键
- name: quantity
type: int
constraints:
min: 1
- name: itemCurrency
type: string
- name: itemPrice
type: decimal
- name: PaymentTerm
localIdentifier: termId
attributes:
- name: paymentType
type: string
- name: dueDays
type: int
constraints:
min: 0
- name: depositRatio
type: decimal
constraints:
min: 0
max: 1
- name: settleCurrency
type: string
- name: settleAmount
type: decimal
- name: DeliveryAddressEntity
localIdentifier: addrId
attributes:
- name: province
type: string
- name: city
type: string
- name: district
type: string
- name: streetDetail
type: string
- name: receiverName
type: string
- name: receiverPhone
type: string
constraints:
pattern: "^\\d{11}$"
patternMessage: 收货手机号需为 11 位数字
valueObjects: []
# 聚合4:员工聚合 EmployeeAggregate(供 AuditOrder 的 REMOTE_QUERY_SET_FIELD 查审核人姓名;
# 并承载审核统计——AuditOrder 的 bizSteps 条件程序按审核结果通用地回写这些字段)
- aggregateId: EmployeeAggregate
description: 员工主数据聚合,独立事务边界
aggregateRoot:
name: Employee
identifier: employeeId
attributes:
- name: employeeName
type: string
- name: department
type: string
- name: auditApproveCount
type: int
constraints:
min: 0
description: 累计审核通过数——AuditOrder 命中 PASS 时 REMOTE_INCREMENT_FIELD +1
- name: auditRejectCount
type: int
constraints:
min: 0
description: 累计审核驳回数——AuditOrder 命中 REJECT 时 REMOTE_INCREMENT_FIELD +1
- name: remark
type: string
description: 备注——AuditOrder 在订单金额>100 时以 REMOTE_SET_FIELD 覆盖写入审核备注
- name: lastAuditTime
type: datetime
description: 上次审核时间——AuditOrder 每次审核以 REMOTE_SET_FIELD 覆盖为本次审核时间
entities: []
valueObjects: []
globalConstraints:
- crossAggRefRule: 跨聚合仅允许引用对方【聚合根唯一标识】,禁止引用对方内部实体、值对象
- transactionBoundary: 一次事务只能修改同一个聚合内对象,跨聚合拆分为多个事务
- cascadeDelete: 聚合根删除时,级联删除自身内部所有组合子实体
- foreignKeyStrategy: "业务层做引用校验,默认不创建数据库物理外键;如需物理外键增加 dbForeignKey: true"