@RequestMapping(method = RequestMethod.PUT, value = "{id}") public Category update(@PathVariable String id, @RequestBody Category category) throws CategoryDoesntExistException { Category update = categoryService.findOne(Long.valueOf(id)); update.setName(category.getName()); return categoryService.save(update); }
@RequestMapping(method = RequestMethod.DELETE, value = "{id}") public void delete(@PathVariable String id) { categoryService.delete(Long.valueOf(id)); }
@RequestMapping(method = RequestMethod.GET, value = "{id}") public Category get(@PathVariable String id) { return categoryService.findOne(Long.valueOf(id)); }
@RequestMapping(method = RequestMethod.POST) public Category create(@RequestBody Category category) throws CategoryAlreadyExistsException { return categoryService.create(category); }
@RequestMapping(method = RequestMethod.GET) public List<Category> getAll() { return categoryService.findAll(); }