(Sorry my English is so bad).
The user entity in my spring boot project has the following basic fields: id, name, email, role, password. Admin can create new employee (including password field), update employee (except for password field), view employee information (except for password field). Employees can edit their information(except for role field). If I create only one DTO, will it be used for all of the above actions? Should I create a DTO for each of those actions?
CodePudding user response:
If I create only one DTO, will it be used for all of the above actions?
Not unless you write code to make that happen. You could have a single DTO for any number of actions if you wanted, but Spring does not impose that. Creating a DTO will not make it be used for all of the actions.
Should I create a DTO for each of those actions?
Generally, no.
CodePudding user response:
(I am french so please excuse my english if it is incorrect, I do my best).
I would create one DTO per "display" case. But it is not an obligation.
