Normally, when your are designing an enterprise application, your domain model is contained in your application's service layer. Over this layer (controllers), the communication is performed using DTOs, then you only are transfering the required information by your different clients (web user interface, another backend application, mobile applications and so on). It is in this point where Orika can help us.
Let me show you an example. Imagine you have this domain object.
Imagine you need two different endpoints to serves information about persons. One of them must to return a basic person information, and the other one must to return the complete information about the person. As you can imagine, you need two DTOs to transfer the required information into the body's response (using json or whatever you want).
Here are our DTOs.
Take a look.
In fact, this example is very simple, but Orika supports more complex mappings. You can find a complete Orika's guide here.
Happy new year!
No comments:
Post a Comment