我正在开发一个系统,并试图将 ddd 与 node.js 一起使用。这是系统的一个示例,从高层次上看:
database tables(mongoldb):
user
username: String
firstName: String
middleName: String
lastName: String
department
title: String
members: [{
user: {type: this.mongoose.Schema.ObjectId, ref: 'user’},
permissions: String
}]
patient
user: {type: this.mongoose.Schema.ObjectId, ref: 'user’},
department: [{type: this.mongoose.Schema.ObjectId, ref: ‘department’}]
lab: [{
patient: {type: this.mongoose.Schema.ObjectId, ref: ‘patient’}
doctor: {type: this.mongoose.Schema.ObjectId, ref: 'user’},
type: String,
results: {there is a lot going on here, }
}]
medication: [{
patient: {type: this.mongoose.Schema.ObjectId, ref: ‘patient’}
doctor: {type: this.mongoose.Schema.ObjectId, ref: 'user’},
name: String,
dosage: Number,
etc.
}]
业务逻辑规定,只有患者或患者、科室列表中某个科室成员的医生才能查看其医疗信息。我最初认为它应该在一个单独的域服务中,因为它似乎跨越实体,但缺点是需要其他服务调用权限服务,我认为服务不应该调用其他服务。如果我放置在实验室和药物实体中,那么我就是重复代码并且违反了干法。如果我添加到部门域服务,那么我正在调用另一个服务。从ddd的角度来看,这样的逻辑属于哪里?