Skip to content

创建设计器

基本用法

ts
import { createDomainDesigner } from '@ddd-tool/domain-designer-core'
const d = createDomainDesigner()

可选的初始化参数

ts
import { createDomainDesigner } from '@ddd-tool/domain-designer-core'
const d = createDomainDesigner({
  moduleName: 'order',
  ignoreValueObjects: ['time', 'name'],
})
参数名参数类型说明默认值
moduleNamestring模块名,在代码生成时,会以该名称作为代码分包的依据ts 文件名
ignoreValueObjectsstring[]忽略的值对象名称,在代码生成阶段,如果名称匹配则不会生成值对象[
'time',
'id',
'pid',
'name',
'state',
'status',
'version',
'code',
'message',
'type',
'result',
'data',
'payload',
'meta',
'context',
'sorting'
]
为什么有 ignoreValueObjects 这个属性?

答:在正常的设计中,要尽可能用有业务意义的命名去定义一个值。

如:应该是userName,而非name

但也有例外:在UserCreatedEvent中有个time属性是正常的,因为这个 time 的业务属性很弱,我们只是需要一个时间而已,那么像这样模糊的属性名在代码生成的时候就不应该被视为值对象