I want a pass a dto and another value using the @RequestBody in spring. Something like shown in below,(This is my controller code)
public User createUser( @RequestBody @Validated UserDto userDto,@RequestBody Integer roleId ){
return userService.createUser(userDto.getUsername(), userDto.getEmail(), userDto.getPassword(),roleId);
}
Below is the json I'm sending via the post call.
{
"username": "usernameABC",
"email" : "abc@gmail.com",
"emailRepeat" : "abc@gmail.com",
"password" : "asdasd",
"passwordRepeat" : "asdasd",
"roleId" : 1
}
Is it possible to do this? or do I have to include the roleId in the dto itself?