Пример #1
0
 /** 更新 */
 @RequestMapping(value = "/update", method = RequestMethod.POST)
 public String update(Role role, RedirectAttributes redirectAttributes) {
   if (!isValid(role)) {
     return ERROR_VIEW;
   }
   Role pRole = roleService.find(role.getId());
   if (pRole == null || pRole.getIsSystem()) {
     return ERROR_VIEW;
   }
   roleService.update(role, "isSystem", "admins");
   addFlashMessage(redirectAttributes, SUCCESS_MESSAGE);
   return "redirect:list.jhtml";
 }
Пример #2
0
 /** 删除 */
 @RequestMapping(value = "/delete", method = RequestMethod.POST)
 public @ResponseBody Message delete(Long[] ids) {
   if (ids != null) {
     for (Long id : ids) {
       Role role = roleService.find(id);
       if (role != null
           && (role.getIsSystem() || (role.getAdmins() != null && !role.getAdmins().isEmpty()))) {
         return Message.error("admin.role.deleteExistNotAllowed", role.getName());
       }
     }
     roleService.delete(ids);
   }
   return SUCCESS_MESSAGE;
 }
Пример #3
0
 /** 保存 */
 @RequestMapping(value = "/save", method = RequestMethod.POST)
 public String save(Role role, RedirectAttributes redirectAttributes) {
   if (!isValid(role)) {
     return ERROR_VIEW;
   }
   role.setIsSystem(false);
   role.setAdmins(null);
   roleService.save(role);
   addFlashMessage(redirectAttributes, SUCCESS_MESSAGE);
   return "redirect:list.jhtml";
 }
Пример #4
0
 /** 列表 */
 @RequestMapping(value = "/list", method = RequestMethod.GET)
 public String list(Pageable pageable, ModelMap model) {
   model.addAttribute("page", roleService.findPage(pageable));
   return "/admin/role/list";
 }
Пример #5
0
 /** 编辑 */
 @RequestMapping(value = "/edit", method = RequestMethod.GET)
 public String edit(Long id, ModelMap model) {
   model.addAttribute("role", roleService.find(id));
   return "/admin/role/edit";
 }