Skip to content
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

实践中dao层如何复用? #15

Closed
flazx opened this issue Jan 10, 2020 · 2 comments
Closed

实践中dao层如何复用? #15

flazx opened this issue Jan 10, 2020 · 2 comments

Comments

@flazx
Copy link

flazx commented Jan 10, 2020

我们在使用sniper的过程中,dao层的复用拿捏不太准,例如:有两个服务
--shopAdmin(商城后端服务接口)
-- shopAdminDao
--shopHome(商城前端服务接口)
--shopHomeDao
在dao层有很多方法可以复用(例如:获取商品详情),这个应当通过[内部服务service的接口]去调用,还是dao层直接通过代码依赖来调用来实现代码的复用呢?那种调用方式更合理呢?

@taoso
Copy link
Member

taoso commented Jan 11, 2020

我们这边认为 dao 层跟 service 层不需要一一对应。对于商品,你应该设一个单独的 dao,比如叫 commodityDao,服务 shopAdmin 和 shopHome 都应该调用同一个 commodityDao,不同的业务逻辑都组织到 service 层,相同的逻辑下沉到 dao 层。

service 跟 dao 层是多对多的,一个服务可以调多个 dao,一个 dao 也可以让不同的服务调用。

@flazx
Copy link
Author

flazx commented Jan 13, 2020

非常感谢您的答复~~

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