【发布时间】:2018-12-01 18:24:18
【问题描述】:
我正在构建一个邀请系统,其中管理员只能邀请
- 尚未被邀请的用户
- 尚未加入系统的用户(=已经是成员)
此流程涉及两个实体 Invitation 和 User。
- 删除用户不应删除他已发送的邀请
- 更新用户的名字不应更新他的所有邀请
这似乎表明应该将Invitations 和User 添加到两个单独的聚合中。
那么实现上述逻辑的唯一方法就是使用像IInvitationService这样的域服务。 我说的对吗?
这个接口可以有两种方法:
public interface IInvitationService
{
Task<Result> Create(Invitation invitation, CancellationToken token);
Task<Result> Delete(Invitation invitation, CancellationToken token);
}
最后,如果我采用服务方式,我将有两种可能的“方式”来创建邀请。
IInvitationRepository.Create()
IInvitationService.Create()
你不觉得这很混乱吗?
【问题讨论】:
标签: design-patterns domain-driven-design repository-pattern software-design aggregateroot