首页 > 解决方案 > DDD 数据层和表示层

问题描述

您好我有一个关于 ddd 层的问题:我基本上将我的文件夹构建在:

├───presentations
│     ├───controllers
│     ├───helpers
│     ├───protocols
├───modules
│   ├───domain   #interfaces of implemented command handler
│     ├───commands            #Commands interfaces & abstract implementations
│     ├───errors              #Errors & Error Types
│     ├───events              #Events interfaces & abstract implementations
│     ├───services            #services interfaces & abstract implementations
│   ├───infrastructure
│     ├───persistence #repositories implementations

但我怀疑应该在哪一层创建我的用例、命令处理程序、命令实现、事件实现。我的问题是我应该在我的模块 / ** / 基础设施文件夹中创建还是应该创建一个文件夹,如:

├───DATA or APPLICATION
│    ├───dtos            #Commands interfaces & abstract implementations
│    ├───commands            #Commands interfaces & abstract implementations
│    ├───events              #Events interfaces & abstract implementations
│    ├───useCases            #services interfaces & abstract implementations

另一个问题:我的表示层,控制器应该在那个层上吗?

标签: domain-driven-design

解决方案


You can create a folder in ./modules/application and put your use cases there. About where to put the command handlers, command implementations or events implementations should be in the infrastructure folder. Because probably they are going to be dependent of some infrastructure, like rabbitmq, or spring boot (if you are using java), or amazon SQS etc.. Yes, your controller folder should be inside the presentation, also if you have any CLI or Event controller that is triggered by outside.


推荐阅读