@RequestMapping( value = "", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<?> list() { return new ResponseEntity<List<Product>>(service.listAll(), HttpStatus.OK); }
@RequestMapping( value = "/{id}", method = RequestMethod.DELETE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<?> delete(@PathVariable("id") int id) { service.delete(new Product(id)); return new ResponseEntity<Product>(HttpStatus.OK); }
@RequestMapping( value = "", method = RequestMethod.PATCH, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<?> update(@RequestBody Product product) { service.update(product); return new ResponseEntity<Product>(HttpStatus.OK); }
@RequestMapping( value = "/remove/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<?> list(@PathVariable("id") int id) { HttpStatus status = HttpStatus.NOT_FOUND; if (service.canRemove(id)) { status = HttpStatus.OK; } return new ResponseEntity<Product>(status); }