コード例 #1
0
 @RequestMapping(value = "role/audit")
 public ModelAndView auditRole(Integer roleId, Integer auditStatus) throws Exception {
   Map<String, Object> map = new HashMap<String, Object>();
   MapBindingResult result = new MapBindingResult(map, "");
   if (roleId == null || auditStatus == null) {
     FieldError error = new FieldError("sysRole", "roleName", "更新的角色不存在!");
     result.addError(error);
   } else {
     SysRole checkById = this.sysRoleUserService.selectOneRole(roleId);
     if (checkById == null) {
       FieldError error = new FieldError("sysRole", "roleName", "更新的角色不存在!");
       result.addError(error);
     }
   }
   if (result.hasErrors()) {
     List<SysRight> allRights = this.sysRoleUserService.findRights();
     RightModuleBuilder builder = RightModuleBuilder.initModules(allRights);
     map.put("builder", builder);
     return new ModelAndView("sys/sys_role_view", map);
   }
   // audit SysRole
   SysRole sysRole = this.sysRoleUserService.selectOneRole(roleId);
   sysRole.setAuditStatus(auditStatus);
   this.sysRoleUserService.auditRole(sysRole);
   //
   map.put("success_msg", "角色审核通过!");
   map.put("action", "update");
   return new ModelAndView("sys/sys_role_success", map);
 }
コード例 #2
0
 @RequestMapping(value = "role/save")
 public ModelAndView saveRole(@ModelAttribute @Valid SysRole sysRole, BindingResult result)
     throws Exception {
   Map<String, Object> map = new HashMap<String, Object>();
   SysRole checkOne = this.sysRoleUserService.selectByRoleName(sysRole.getRoleName());
   if (checkOne != null) {
     FieldError error = new FieldError("sysRole", "roleName", "角色名已存在!");
     result.addError(error);
   }
   if (result.hasErrors()) {
     List<SysRight> allRights = this.sysRoleUserService.findRights();
     RightModuleBuilder builder = RightModuleBuilder.initModules(allRights);
     map.put("builder", builder);
     return new ModelAndView("sys/sys_role_new", map);
   }
   // create SysRole
   sysRole.setAuditStatus(EntityConstants.IS_VALILD_0);
   sysRole.setIsValid(EntityConstants.IS_VALILD_1);
   this.sysRoleUserService.createRole(sysRole);
   //
   map.put("success_msg", "角色创建成功!");
   map.put("action", "new");
   return new ModelAndView("sys/sys_role_success", map);
 }