Home > Enterprise >  Converting DTO to Entity Manually
Converting DTO to Entity Manually

Time:07-03

I'm new here and also new in this developer world! I started my studies in the beginning of this year and now I am trying to do a very simple Spring Boot API REST project. However I'm not getting how can I convert DTO to an Entity and then return it to the Controller.

I'd like to make a Mapper Class to do this work and not using a library for this, but rather do it manually(I know that is not the simplest way, but it's just for my apprenticeship). Then pass it to the Service and then to the Controller. Is that right?

Can anyone help me with this issue?

CodePudding user response:

I'm not getting how can I convert DTO to an Entity and then return it to the Controller.

-> It is not a good design to expose the entity to the end user. You must convert that entity to a dto and then share it with the end user in case it is required.

This is a sample design that you can use. enter image description here

  • Related