Ejemplo n.º 1
0
 public Result add(Request request) {
   String code = request.get("code");
   DefaultUser user = userService.findUserByUserCode(code);
   if (user != null) {
     throw new CapMessageException(
         CapAppContext.getMessage("users.exist", new Object[] {code}), getClass());
   }
   String name = request.get("name");
   String password = request.get("password");
   String confirm = request.get("confirm");
   passwordService.checkPasswordRule(code, password, confirm, true);
   String email = request.get("email");
   String[] roleCodes = request.getParamsAsStringArray("roleCodes");
   userService.createUser(code, name, password, email, roleCodes);
   return new AjaxFormResult();
 }
Ejemplo n.º 2
0
 public Result modify(Request request) {
   String oid = request.get("oid");
   String code = request.get("code");
   String password = request.get("password");
   String confirm = request.get("confirm");
   boolean reset = !StringUtils.isBlank(password);
   if (reset) {
     // 代表要修改密碼
     passwordService.checkPasswordRule(code, password, confirm, true);
   }
   DefaultUser user = userService.findUserByUserCode(code);
   if (user != null && !user.getOid().equals(oid)) {
     throw new CapMessageException(
         CapAppContext.getMessage("users.exist", new Object[] {code}), getClass());
   }
   String name = request.get("name");
   String email = request.get("email");
   String[] roleCodes = request.getParamsAsStringArray("roleCodes");
   userService.updateUserByOid(oid, code, name, reset, password, email, roleCodes);
   return new AjaxFormResult();
 }
Ejemplo n.º 3
0
 @HandlerType(HandlerTypeEnum.GRID)
 public MapGridResult query(SearchSetting search, Request params) {
   String code = params.get("code");
   String name = params.get("name");
   String[] roleCodes = params.getParamsAsStringArray("roleCodes");
   String[] status = params.getParamsAsStringArray("status");
   Page<Map<String, Object>> page =
       userService.findUser(
           code, name, roleCodes, status, search.getMaxResults(), search.getFirstResult());
   Map<String, Formatter> fmt = new HashMap<String, Formatter>();
   fmt.put("createTime", new ADDateFormatter());
   fmt.put("updateTime", new ADDateFormatter());
   fmt.put("pwdExpiredTime", new ADDateFormatter());
   fmt.put(
       "status",
       new CodeTypeFormatter(
           codeTypeService, "userStatus", (Locale) SimpleContextHolder.get(CapWebUtil.localeKey)));
   return new MapGridResult(page.getContent(), page.getTotalRow(), fmt);
 }
Ejemplo n.º 4
0
 public Result unlock(Request request) {
   String[] oids = request.getParamsAsStringArray("oids");
   userService.unlockUserByOids(oids);
   return new AjaxFormResult();
 }