domain-driven-design - 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
另一个问题:我的表示层,控制器应该在那个层上吗?
解决方案
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.
推荐阅读
- android - adb shell 命令以禁用每个应用程序的 android 通知
- typescript - 如何从 NPM 包中的声明合并中导出类型
- react-native - Expo => 未处理的承诺拒绝:错误:未授权使用后台位置服务
- sql - 在 azure synapse sql server 中选择列值作为逗号分隔字符串
- c# - Azure 计时器函数中未调用 .netCore 启动类
- r - 计算可变长度话语中最终单词的频率列表
- python - 刷新页面后如何使选定的选项保持不变?
- node.js - 来自cloudflare问题的NodeJS证书
- ios - 将协议使用限制为两种类类型
- html - 默认情况下如何从html打开一个url来打开instagram应用程序