@RequestMapping(value = "/get") public @ResponseBody ResponseObject get( @RequestParam(value = "start", required = false) Integer start) { if (start != null) { return productService.getProducts(start); } else { return productService.findAll(); } }
@RequestMapping(value = "/update") public @ResponseBody ResponseObject update( @RequestBody @Valid Product product, BindingResult errors) throws Exception { if (errors.hasErrors()) throw new ValidateException(errors.getAllErrors().get(0).getDefaultMessage()); return productService.update(product); }
@RequestMapping(value = "/get-dealers") public @ResponseBody ResponseObject getDealers(@RequestParam("productId") Integer productId) throws Exception { return productService.getDealers(productId); }
@RequestMapping(value = "/find") public @ResponseBody ResponseObject getProduct(@RequestParam("productId") Integer productId) { return productService.findById(productId); }
@RequestMapping(value = "/get-parts") public @ResponseBody ResponseObject getParts(@RequestParam("productId") Integer productId) { return productService.getParts(productId); }
@RequestMapping(value = "/delete") public @ResponseBody ResponseObject deleteProduct(@RequestParam("productId") Integer productId) throws Exception { return productService.deleteById(productId); }