@ResponseBody @RequestMapping(value = "/user/cemail.htm", method = RequestMethod.POST) public BizResponse cemail(String no, String uemail) { this.setWebData("no", no); // 操作结果 BizResponse response = this.newBizResponse(); try { // 查找 UserModel user = this.userService.findByNo(no); if (user == null) { this.buildResponse(response, BizResponseEnum.OBJECT_NOT_EXIST); return response; } // 长度 uemail = StringUtils.trimToEmpty(uemail); user.setEmail(TextUtils.truncate(uemail, DAS.USER.EMAIL_MAX)); // 更新 this.userService.update(user); } catch (Exception e) { logger.error("修改登录用户电子邮箱异常!", e); this.buildResponse(response, BizResponseEnum.SYSTEM_ERROR); } // JSON返回 return response; }
@ResponseBody @RequestMapping(value = "/user/create.htm", method = RequestMethod.POST) public BizResponse create(String uname, String passwd, String passwd2, String uemail) { // 操作结果 BizResponse response = this.newBizResponse(); try { // 参数检查 if (StringUtils.isBlank(uname) || StringUtils.isBlank(passwd) || StringUtils.isBlank(uemail)) { this.buildResponse(response, BizResponseEnum.REQUIRE_PARAM); return response; } if (!StringUtils.equals(passwd, passwd2)) { this.buildResponse(response, BizResponseEnum.INVALID_PASSWD); return response; } // 用户名检查 UserModel user = this.userService.findByNickName(uname); if (user != null) { this.buildResponse(response, BizResponseEnum.EXIST_UNAME); return response; } // 电子邮箱检查 // TODO: // 新建 user = this.newInitUser(); user.setNo(UserConverter.encode(this.userTicketService.nextValue())); user.setNickName(uname); user.setPasswd(MD5Utils.digest(passwd)); user.setEmail(uemail); // 更新 this.userService.create(user); response.getBizData().put(BizResponse.BIZ_ID_KEY, uname); } catch (Exception e) { logger.error("新增用户异常!", e); this.buildResponse(response, BizResponseEnum.SYSTEM_ERROR); } // JSON返回 return response; }
@ResponseBody @RequestMapping(value = "/user/cpasswd.htm", method = RequestMethod.POST) public BizResponse cpasswd(String no, String opasswd, String passwd, String passwd2) { this.setWebData("no", no); // 操作结果 BizResponse response = this.newBizResponse(); try { // 查找 UserModel user = this.userService.findByNo(no); if (user == null) { this.buildResponse(response, BizResponseEnum.OBJECT_NOT_EXIST); return response; } // 原密码 if (!StringUtils.equals(user.getPasswd(), MD5Utils.digest(opasswd))) { this.buildResponse(response, BizResponseEnum.INVALID_PASSWD); return response; } // 新密码 if (!StringUtils.equals(passwd, passwd2)) { this.buildResponse(response, BizResponseEnum.INVALID_PASSWD); return response; } // 长度 user.setPasswd(MD5Utils.digest(passwd)); // 更新 this.userService.update(user); } catch (Exception e) { logger.error("修改登录用户密码异常!", e); this.buildResponse(response, BizResponseEnum.SYSTEM_ERROR); } // JSON返回 return response; }
@ResponseBody @RequestMapping(value = "/user/update-{id}.htm", method = RequestMethod.POST) public BizResponse update( @PathVariable long id, String uname, String passwd, String passwd2, String uemail) { // 操作结果 BizResponse response = this.newBizResponse(); try { // 查询 UserModel user = this.userService.findByNickName(uname); user.setPasswd(MD5Utils.digest(passwd)); user.setEmail(uemail); // 更新 this.userService.update(user); } catch (Exception e) { logger.error("修改用户异常!", e); this.buildResponse(response, BizResponseEnum.SYSTEM_ERROR); } // JSON返回 return response; }