I have a controller that converts dto to an entity and passes it to the service level.
@PostMapping(value = "/new", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<UserDto> create(@RequestBody UserDto userDto){
User newUser= userService.save(userMapper.userDtoToUser(userDto));
return ResponseEntity......body(userMapper.userToUserDto(newUser));
}
Will the correct decision be to transfer to the service not an entity, but a dto? For example:
public interface UserService{
UserDto save(UserDto userDto);
}
And will the decision be correct to convert the entity and dto at the controller level?