I'm working on a backend layer of a webapp in Java which is essentially an RESTful API (using Spring Boot). Within my backend I'm calling another API (essentially my database) to retrieve and combine data. Current my workflow for handling a GET request looks the following
- Receive request within my API
- Call the other API (database), and map it's JSON response to a DTO
- Convert DTO to BO to perform logic on it
- Return BO via spring boot (which turns its fields into a JSON body and returns this)
My question is
Following the DTO logic, would it be more correct to turn my BO into a second DTO, containing the data to be transferred (as I understand it is discouraged to transfer data with a BO)
Essentially this would add a step to my list above, between 3 and 4:
---> ...
---> 3.5. Convert BO to new DTO
---> 4. Return DTO via sprint boot
The reason I haven't done this is because it seems a bit intensive to convert objects twice, however I see the benefits to the DTO / BO pattern.
Aucun commentaire:
Enregistrer un commentaire