I want to write a method for updating a book. The parameters I am passing are updated book and the id of the same book. I am confused about the exact way to implement the update method. Should I pass id in the path param or not because id is already contained in the updated book which I am passing.
BookController
@PUT
@Path("/{isbn}")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public BookResourceRto updateBook(BookResourceRto book, @PathParam("isbn") String isbn){
Book updatedBook = bookRtoTransformer.apply(updatedBookRto);
return bookModelTransformer.apply(bookService.updateBook(updatedBook));}
BookService
public Book updateBook(Book updatedBook) {
BookRepoRto bookRepoRto = bookModelTransformer.apply(updatedBook);
return bookRepoRtoTransformer.apply(bookRepository.save(bookRepoRto));
}