February 2018
Intermediate to advanced
406 pages
9h 55m
English
Leaving aside validations for a minute (which we will cover in a while), the insertion looks very simple to implementing the REST interface.
We map the POST operation to the insertProduct method and in the implementation, we just call save on the repository that was already defined:
@RequestMapping(value="/product", method = RequestMethod.POST)
ResponseEntity<Product> insertProduct(@RequestBody Product product) {
Product savedProduct = prodRepo.save(product) ;
return new ResponseEntity<Product>(savedProduct, HttpStatus.OK);
}
Notice a few differences from the getProduct method we coded earlier:
Read now
Unlock full access