r/SpringBoot • • Feb 25 '24

Map dto in controller

Hi my manager tell me that best practice is to map the returned dto from service layer in controller not in service Would any one agree with this ? My knowledge is the controller just one line and just delegate the logic to service layer and just return the response entity

23 Upvotes

35 comments sorted by

View all comments

1

u/[deleted] Feb 25 '24

The mapping from entity to DTO should happen in the service, not in the controller. They might have suggested this just to see if it works, with the intention of later moving the mapping to the service.