@PreAuthorize("hasAuthority('ADMIN')") @RequestMapping(value = "/admin/marca/remove", method = RequestMethod.GET) public String marcaRemove(@RequestParam(value = "id", required = true) long id, Model model) { System.out.println("Marca -> Remove -> GET"); mar.delete(id); return "redirect:/admin/marche"; }
@PreAuthorize("hasAuthority('ADMIN')") @RequestMapping(value = "/admin/marca", method = RequestMethod.GET) public String marca(@RequestParam(value = "id", required = true) long id, Model model) { System.out.println("Marca -> GET"); Marca marca = mar.findOne(id); model.addAttribute("marca", marca); return "admin@marcaEditForm"; }
@PreAuthorize("hasAuthority('ADMIN')") @RequestMapping( value = "/json/marche/search", method = RequestMethod.GET, produces = "application/json") public @ResponseBody Marche marcaJSON( @RequestParam(value = "q", required = true) String q, Model model) { return new Marche(mar.findByDescrizioneContainingIgnoreCase(q)); }
@PreAuthorize("hasAuthority('ADMIN')") @RequestMapping(value = "/admin/marca/new", method = RequestMethod.POST) public String marcaPOST(@ModelAttribute Marca marca, Model model) { System.out.println("Marca -> Nuovo -> POST"); try { mar.save(marca); return "redirect:/admin/marche"; } catch (Exception e) { model.addAttribute("messaggio", "La marca " + marca.getDescrizione() + " é già presente"); return "admin@marcaNewForm"; } }
@PreAuthorize("hasAuthority('ADMIN')") @RequestMapping(value = "/json/marche", method = RequestMethod.GET) public @ResponseBody Marche marcheJSON(Model model) { return new Marche(mar.findAll()); }
@PreAuthorize("hasAuthority('ADMIN')") @RequestMapping(value = "/json/marca/{id}", method = RequestMethod.GET) public @ResponseBody Marca marcaJSON(@PathVariable long id, Model model) { return mar.findOne(id); }