@RequiresPermissions("resource:delete")
 @RequestMapping(value = "/{id}/delete", method = RequestMethod.GET)
 public String delete(@PathVariable("id") Long id, RedirectAttributes redirectAttributes) {
   resourceService.deleteResource(id);
   redirectAttributes.addFlashAttribute("msg", "删除成功");
   return "redirect:/resource";
 }
Esempio n. 2
0
 @RequestMapping("/")
 public String index(@CurrentUser User user, Model model) {
   Set<String> permissions = userService.findPermissions(user.getUsername());
   List<Resource> menus = resourceService.findMenus(permissions);
   model.addAttribute("menus", menus);
   return "index";
 }
 @RequiresPermissions("resource:update")
 @RequestMapping(value = "/{id}/update", method = RequestMethod.POST)
 public String update(Resource resource, RedirectAttributes redirectAttributes) {
   resourceService.updateResource(resource);
   redirectAttributes.addFlashAttribute("msg", "修改成功");
   return "redirect:/resource";
 }
 @RequiresPermissions("resource:update")
 @RequestMapping(value = "/{id}/update", method = RequestMethod.GET)
 public String showUpdateForm(@PathVariable("id") Long id, Model model) {
   model.addAttribute("resource", resourceService.findOne(id));
   model.addAttribute("op", "修改");
   return "resource/edit";
 }
 @RequiresPermissions("resource:create")
 @RequestMapping(value = "/{parentId}/appendChild", method = RequestMethod.POST)
 public String create(Resource resource, RedirectAttributes redirectAttributes) {
   resourceService.createResource(resource);
   redirectAttributes.addFlashAttribute("msg", "新增子节点成功");
   return "redirect:/resource";
 }
 @RequiresPermissions("resource:create")
 @RequestMapping(value = "/{parentId}/appendChild", method = RequestMethod.GET)
 public String showAppendChildForm(@PathVariable("parentId") Long parentId, Model model) {
   Resource parent = resourceService.findOne(parentId);
   model.addAttribute("parent", parent);
   Resource child = new Resource();
   child.setParentId(parentId);
   child.setParentIds(parent.makeSelfAsParentIds());
   model.addAttribute("resource", child);
   model.addAttribute("op", "新增子节点");
   return "resource/edit";
 }
 @RequiresPermissions("resource:view")
 @RequestMapping(method = RequestMethod.GET)
 public String list(Model model) {
   model.addAttribute("resourceList", resourceService.findAll());
   return "resource/list";
 }