コード例 #1
0
 @RequestMapping(
     value = {"disable"},
     method = RequestMethod.POST)
 public String disable(HttpServletRequest request, Integer id, String repassword, ModelMap model) {
   if (virifyEquals("admin.operate", UserUtils.getAdminFromSession(request), id, model)) {
     return "common/ajaxError";
   }
   SystemUser entity = service.updateStatus(id, true);
   if (notEmpty(entity)) {
     logOperateService.save(
         new LogOperate(
             UserUtils.getAdminFromSession(request).getId(),
             "disable.user",
             RequestUtils.getIp(request),
             getDate(),
             id + ":" + entity.getName()));
   }
   return "common/ajaxDone";
 }
コード例 #2
0
 @RequestMapping(
     value = {"enable"},
     method = RequestMethod.POST)
 public String enable(
     Integer id,
     String repassword,
     HttpServletRequest request,
     HttpSession session,
     ModelMap model) {
   if (virifyEquals("admin.operate", UserUtils.getAdminFromSession(session), id, model)) {
     return TEMPLATE_ERROR;
   }
   SystemUser entity = service.updateStatus(id, false);
   if (notEmpty(entity)) {
     logOperateService.save(
         new LogOperate(
             UserUtils.getAdminFromSession(session).getId(),
             "enable.user",
             RequestUtils.getIp(request),
             getDate(),
             id + ":" + entity.getName()));
   }
   return TEMPLATE_DONE;
 }
コード例 #3
0
 @RequestMapping(SAVE)
 public String save(
     SystemUser entity,
     String repassword,
     Integer[] roleIds,
     HttpServletRequest request,
     HttpSession session,
     ModelMap model) {
   if (virifyNotEmpty("username", entity.getName(), model)
       || virifyNotEmpty("nickname", entity.getNickName(), model)
       || virifyNotUserName("username", entity.getName(), model)
       || virifyNotNickName("nickname", entity.getNickName(), model)) {
     return TEMPLATE_ERROR;
   }
   if (entity.isSuperuserAccess()) {
     entity.setRoles(arrayToCommaDelimitedString(roleIds));
   } else {
     entity.setRoles(null);
     entity.setDeptId(null);
   }
   if (notEmpty(entity.getId())) {
     SystemUser user = service.getEntity(entity.getId());
     if ((!user.getName().equals(entity.getName())
             && virifyHasExist("username", service.findByName(entity.getName()), model))
         || (!user.getNickName().equals(entity.getNickName())
             && virifyHasExist("nickname", service.findByNickName(entity.getNickName()), model))) {
       return TEMPLATE_ERROR;
     }
     if (notEmpty(entity.getPassword())) {
       if (virifyNotEquals("repassword", entity.getPassword(), repassword, model)) {
         return TEMPLATE_ERROR;
       } else {
         entity.setPassword(VerificationUtils.encode(entity.getPassword()));
       }
     } else {
       entity.setPassword(user.getPassword());
       if (!notEmpty(entity.getEmail()) || !entity.getEmail().equals(user.getEmail())) {
         entity.setEmailChecked(false);
       }
     }
     entity =
         service.update(
             entity.getId(),
             entity,
             new String[] {
               ID,
               "dateRegistered",
               "authToken",
               "lastLoginDate",
               "lastLoginIp",
               "loginCount",
               "disabled"
             });
     if (entity.isSuperuserAccess()) {
       roleUserService.dealRoleUsers(entity.getId(), roleIds);
     }
     if (notEmpty(entity)) {
       logOperateService.save(
           new LogOperate(
               UserUtils.getAdminFromSession(session).getId(),
               "update.user",
               RequestUtils.getIp(request),
               getDate(),
               entity.getId() + ":" + entity.getName()));
     }
   } else {
     if (virifyNotEmpty("password", entity.getPassword(), model)
         || virifyNotEquals("repassword", entity.getPassword(), repassword, model)
         || virifyHasExist("username", service.findByName(entity.getName()), model)
         || virifyHasExist("nickname", service.findByNickName(entity.getNickName()), model)) {
       return TEMPLATE_ERROR;
     }
     entity.setPassword(VerificationUtils.encode(entity.getPassword()));
     entity = service.save(entity);
     if (entity.isSuperuserAccess() && null != roleIds) {
       for (Integer roleId : roleIds) {
         roleUserService.save(new SystemRoleUser(roleId, entity.getId()));
       }
     }
     if (notEmpty(entity)) {
       logOperateService.save(
           new LogOperate(
               UserUtils.getAdminFromSession(session).getId(),
               "save.user",
               RequestUtils.getIp(request),
               getDate(),
               entity.getId() + ":" + entity.getName()));
     }
   }
   return TEMPLATE_DONE;
 }