【发布时间】:2016-09-29 06:31:23
【问题描述】:
我正在开发一个系统并尝试将 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的角度来看,这样的逻辑属于哪里?
【问题讨论】:
-
应用程序服务不应调用其他应用程序服务,因为它们是用例入口点,但您可以使用的域服务数量没有限制。
标签: node.js domain-driven-design ddd-service