Ejemplo n.º 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";
 }
Ejemplo n.º 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;
 }