简体   繁体   中英

in spring boot, what's better? using multiple repositories in one service or using multiple services in one controller?

I am trying to make this rest endpoint: /api/Offers/{offerId}/comments , what is better in design view?

  • using CommentRepository and OfferRepository inside OfferService OR
  • using CommentService and OfferService inside OfferController

It is sort of specific to general issue, I don't know what is most recommended approach!

I would pick the second variant:

using CommentService and OfferService inside OfferController

There is no special reason for that, but for me its clearer, other than the repositories. (Only my Opinion)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM