I have an @RestController that allows to POST with a few @RequestParam arguments and 2 @RequestPart arguments to be able to create an object in the service layer that needs some input + 2 files like this:
@RequestMapping(value = "/", method = RequestMethod.POST)
public ResponseEntity createBook(@RequestParam("authorId") UUID authorId,
@RequestParam("pages") int pages,
@RequestParam("rating") BookRating rating,
@RequestPart("file") MultipartFile file,
@RequestPart("file2") MultipartFile file2) {
I would like to create an object that encapsulates all those parameters, so I can do something like:
public ResponseEntity createBook( CreateBookParameters params ) {
How do I do this? What annotation do I need to use in my controller? Are there any annotations I need to use in the CreateBookParameters or is this a simple POJO ?
Do I need to change anything to the request I do if I do these changes (I am testing with "form-data" setting in Postman)?
@RequestParams into an@ModelAttribute CreateBookParameters.