@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
 @ResponseStatus(HttpStatus.NO_CONTENT)
 public void updateCommodity(@PathVariable("id") Long id, @RequestBody Commodity commodity) {
   if (commodityRepository.exists(id)) {
     commodity.setId(id);
     commodityRepository.save(commodity);
   }
 }
  @RequestMapping(method = RequestMethod.POST)
  public ResponseEntity<String> createCommodity(
      HttpServletRequest request, @RequestBody Commodity commodity) {
    commodityRepository.saveAndFlush(commodity);
    final Long id = commodity.getId();

    URI uri = new UriTemplate("{requestUrl}/{id}").expand(request.getRequestURL().toString(), id);
    final HttpHeaders headers = new HttpHeaders();
    headers.put("Location", singletonList(uri.toASCIIString()));
    return new ResponseEntity<String>(headers, HttpStatus.CREATED);
  }
 @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
 @ResponseStatus(HttpStatus.NO_CONTENT)
 public void deleteCommodity(@PathVariable("id") Long id) {
   commodityRepository.delete(id);
 }
 @RequestMapping(value = "/{id}", method = RequestMethod.GET)
 public @ResponseBody Commodity read(@PathVariable("id") Long id) {
   return commodityRepository.findOne(id);
 }
 @RequestMapping(method = RequestMethod.GET, produces = "application/json")
 @ResponseBody
 public Page<Commodity> listCommodity(Pageable page) {
   return commodityRepository.findAll(page);
 }