We take separate model for request and response these are basically from UI point of view. Suppose we get the data from end user like : firstName, lastName, email, password.
We get this data in JSON formate so we have to convert this JSON object to java object for that we create a separate model object in the package ui.model.request. and it will also used by spring framework to convert JSON object to Java object.
Once we persist the data then we get some response back but in that response we. have like pkId of table but we don't want to send this in our response so we can't use a single entity that we used to perisit our data. So we create a new package with ui.model.response and we will copy that required fields and this will used to convert from Java object to JSON and it will be sent back to spring framework
Here incoming request like from end user
Now this incoming request received by method called createUser(); and @RequestBody annotation will take this request as JSON and it will map to UserDetailsRequestModel java bean and will convert JSON to java Object.
Similarly UserDto(basically this bean is carry out on different layer in our project like from controller to service to repository layer. It consists of some additional fields like encryptedPassword, emailVerificatioToke etc. )
Once we save our entity object which is constructed from UserDto bean. once we save we receive UserEntity but we will copy files from UserEntity bean to UserDto and we will copy the field from UserDto to UserRest (this is basically model which is sent back and spring framework will take that java object and convert into a json format and send back the response.)like this which consist of information that we want to expose only.
We get this data in JSON formate so we have to convert this JSON object to java object for that we create a separate model object in the package ui.model.request. and it will also used by spring framework to convert JSON object to Java object.
Once we persist the data then we get some response back but in that response we. have like pkId of table but we don't want to send this in our response so we can't use a single entity that we used to perisit our data. So we create a new package with ui.model.response and we will copy that required fields and this will used to convert from Java object to JSON and it will be sent back to spring framework
Here incoming request like from end user
Now this incoming request received by method called createUser(); and @RequestBody annotation will take this request as JSON and it will map to UserDetailsRequestModel java bean and will convert JSON to java Object.
Similarly UserDto(basically this bean is carry out on different layer in our project like from controller to service to repository layer. It consists of some additional fields like encryptedPassword, emailVerificatioToke etc. )
Once we save our entity object which is constructed from UserDto bean. once we save we receive UserEntity but we will copy files from UserEntity bean to UserDto and we will copy the field from UserDto to UserRest (this is basically model which is sent back and spring framework will take that java object and convert into a json format and send back the response.)like this which consist of information that we want to expose only.
Amazing Article,Really useful information to all So, I hope you will share more information to be check and share here.
ReplyDeleteinplant training for biotechnology in chennai
inplant training for ece students
inplant training mechanical engineering students
inplant training certificate format for civil engineering
inplant training report ppt
inplant training report samples
inplant training letter format
inplant training report for civil engineering pdf
inplant training report for electrical engineering
I Am Thankful To You For Create Such Kind Of Informative Website. Really It Is Useful According Your Current Topic. I Suggest To Keep This Continue For Those People, Who Are Looking For Such Kind Of Niche. After See Your Niche I Have Recommended Your Website With My Friends Also. We also provide Digital Marketing Services in Delhi SEO, SMM, PPC, Website Design & Development, and much more services
ReplyDelete