8000 APP层是如何直接使用infrastructure层的,infrastructure层只有gateway的实现类,APP层直接注入gateway实现类吗 · Issue #574 · alibaba/COLA · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

APP层是如何直接使用infrastructure层的,infrastructure层只有gateway的实现类,APP层直接注入gateway实现类吗 #574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
bobzh39 opened this issue Mar 10, 2025 · 1 comment

Comments

@bobzh39
Copy link
bobzh39 commented Mar 10, 2025

APP层是如何直接使用infrastructure层的,infrastructure层只有gateway的实现类,APP层直接注入实现类吗?还是说注入Mapper?感觉注入Mapper不太合理啊,gateway才是防腐层 ,但是接口定义在领域层,但不是所有业务都有领域的。 简单的CRUD做成DDD又搞复杂了。

@bobzh39 bobzh39 changed the title APP层是如何直接使用infrastructure层的,infrastructure层只有gateway的实现类,APP层直接注入实现类吗 APP层是如何直接使用infrastructure层的,infrastructure层只有gateway的实现类,APP层直接注入gateway实现类吗 Mar 10, 2025
@ariesyp
Copy link
ariesyp commented Mar 18, 2025

我的理解是infrastructure不仅仅只有gateway的实现类。gateway是用来表示领域层接入infrastructure必须提供的方法。从cqrs的角度看,领域层更多涉及到的是具体的动作导致状态的变化,对应的是command。而很多界面展示涉及到的的仅仅是查询,并不涉及到领域层的状态变化,对应的是Query,此时就会出现App直接使用infrastructure层,毕竟针对不同的客户端如手机App、Web查询的方式可能会有区别,为了维持领域层相对稳定,这些外部展现方式不同导致查询方式不同,并不应该直接反映在领域层。
再说Mapper,这个Mapper并不一定只来源于领域层,infrastructure和App层都可以定义Mapper接口,只是实现放到infrastructure层就行。另外作者的思路也是,有必要才上DDD,简单的CRUD完全可以用App直接使用infrastructure层,达到之前controller->service->repository的效果。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0