我目前正在构建一个 CQS 风格的 DDD 应用程序。我对所有“组件”如何相互工作有一些疑问。
但首先我将简要概述一下应用程序的结构:
ApplicationService
-> Receives command objects
-> doesn't return any results
-> Acts on Domain model
-> Speaks with Aggregate repository for domain modifications
QueryService
-> Bypasses domain model; doesn't speak with Aggregate Repositories
-> Executes queries against database to populate view
-> Returns 'Representation' objects
REST Controller
-> Receives HTTP requests and binds 'body content' & request params to Command objects
-> delegates to ApplicationService for POST, PUT & DELETE requests
-> Always returns at least some HTTP code
-> delegates to QueryService for GET requests
Infrastructure
-> Handles persistence to DB
-> Contains some scheduling operations
-> Handles foreign domain events our domain model is 'interested' in
'Open Host'
-> This is mainly a Facade to be used by other domains
-> Facade delegates methods to ApplicationService for domain modifications and to QueryService for data retrieval (bypassing Repositories)
我的问题:
- a 与a
DomainEventHandler对应并在 aRepository上调用某些方法可以Aggregate吗?或者它应该总是对应于一个ApplicationService? QueryService返回 'Representation ' 对象。这些由 UI AND by'Open Host' Facade作为返回值使用。可以将这些对象重用为返回值Facade吗?还是应该Facade自己创建Objects,连结果都基本一样?ApplicationService将 'Commands' 作为输入参数。可以吗?这些Commands也被使用Open Host Facade?还是应该Facade只接受原始值并Commands在委托给时将它们转换为ApplicationService?DomainEventHandlers似乎驻留在“Infrastructure”层。是否有可能 aApplicationService或Domain Service也订阅了 aDomain Event?或者这总是一种Infrastructure责任?
非常欢迎所有建议!