r/SpringBoot • u/ahmedzahran94 • 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
12
u/BackpackerSimon Feb 25 '24
Because you might need to use a service in another service. Then you are mixing domain objects. Dtos are the external contract so in my work are the controllers problem to convert to/ from the entity objects