[英]in spring boot, what's better? using multiple repositories in one service or using multiple services in one controller?
我正在尝试制作此 rest 端点: /api/Offers/{offerId}/comments
,在设计视图中有什么更好的?
OfferService
中使用CommentRepository
和OfferRepository
或OfferController
中使用CommentService
和OfferService
这是针对一般问题的,我不知道最推荐的方法是什么!
我会选择第二个变体:
在 OfferController 中使用 CommentService 和 OfferService
这没有什么特别的原因,但对我来说,除了存储库之外,它更清楚。 (只有我的意见)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.