コード例 #1
0
 @PreAuthorize("hasAnyRole('ROLE_ADMIN','ROLE_SUPERUSER')")
 @RequestMapping(
     value = "/removestockitem/{idStoc}",
     method = RequestMethod.GET,
     produces = "application/json")
 @ResponseBody
 public JSONResponseWithId removeStoc(@PathVariable Long idStoc) {
   JSONResponseWithId response = new JSONResponseWithId();
   try {
     Stoc stoc = inventoryService.removeStoc(idStoc);
     response.setId(stoc.getIdStoc());
     response.setMessage("S-a șters articolul: " + stoc.getNumeStoc());
   } catch (Exception e) {
     response.setId(-1);
     response.setMessage("Articolul nu s-a șters");
   }
   return response;
 }
コード例 #2
0
 @PreAuthorize("hasAnyRole('ROLE_ADMIN','ROLE_SUPERUSER')")
 @RequestMapping(
     value = "/editstockitem",
     method = RequestMethod.POST,
     produces = "application/json")
 @ResponseBody
 public JSONResponseWithId editStoc(@RequestBody StocFormModel stoc) {
   JSONResponseWithId response = new JSONResponseWithId();
   try {
     Stoc edited = inventoryService.edit(stoc);
     response.setId(edited.getIdStoc());
     response.setMessage("S-a editat articolul: " + stoc.getNumeStoc());
   } catch (DataAccessException e) {
     response.setId(-1);
     response.setMessage("Articolul nu s-a editat");
   }
   return response;
 }