@Path("/get/userInfo") @POST @Produces("application/json;charset=utf-8") public String getUserInfo(@Context HttpServletRequest request, String content) { if (StringUtils.isEmpty(content)) { return OpenResult.parameterError("无参数").buildJson(); } JSONObject json = JSONObject.parseObject(content); String idNumber = json.getString("idNumber"); String captcha = json.getString("captcha"); String uuId = json.getString("uuId"); if (StringUtils.isEmpty(idNumber) || StringUtils.isEmpty(captcha) || StringUtils.isEmpty(uuId)) { return OpenResult.parameterError("参数错误").buildJson(); } try { if (!ValidateUtil.isIdNumber(idNumber)) { return OpenResult.parameterError(10103, "身份证号有误,请正确填写您的18位身份证号").buildJson(); } if (!ImageCaptchaValidator.validateResponse(uuId, captcha)) { return OpenResult.parameterError(10203, "验证码不正确").buildJson(); } JSONObject result = personalService.queryUserInfo(idNumber); if (result != null) { int retcode = result.getIntValue("retcode"); if (retcode != 0) { return result.toJSONString(); } NoPwdResult pwdResult = new NoPwdResult(); String mobileNo = result.getString("mobileno"); mobileNo = InfoMasker.masker(mobileNo, 3, 4, "*", 1); pwdResult.setMobileno(mobileNo); JSONObject userInfo = new JSONObject(); userInfo.put("mobileno", result.getString("mobileno")); userInfo.put("userid", result.getString("userid")); userInfo.put("email", result.getString("email")); setMemcacheJSON(idNumber, userInfo); return OpenResult.ok().add("data", pwdResult).buildJson(); } else { return OpenResult.unknown("服务异常").buildJson(); } } catch (StockRestException e) { log.error("找回密码时获取用户信息异常:" + e); return OpenResult.serviceError(e.getRetcode(), e.getMsg()).buildJson(); } catch (StockServiceException e) { log.error("找回密码时获取用户信息异常:" + e); return OpenResult.serviceError(e.getRetcode(), e.getMsg()).buildJson(); } }
@Path("/findpwd/getcode") @POST @Produces("application/json;charset=utf-8") public String getCodeForFindPwd(String content) { if (StringUtils.isEmpty(content)) { return OpenResult.parameterError("无参数").buildJson(); } JSONObject json = JSONObject.parseObject(content); String idNumber = json.getString("idNumber"); if (StringUtils.isEmpty(idNumber)) { return OpenResult.parameterError("参数错误").buildJson(); } try { boolean flag = checkIdNumber(idNumber); if (log.isDebugEnabled()) { log.debug("找回密码自延期" + flag); } JSONObject result = null; String userId = null; String mobileno = null; json = getUser(idNumber); if (json != null) { userId = json.getString("userid"); mobileno = json.getString("mobileno"); } else { JSONObject info = personalService.queryUserInfo(idNumber); if (info != null) { mobileno = info.getString("mobileno"); userId = info.getString("userid"); } else { return OpenResult.parameterError("请输入注册身份证号码").buildJson(); } } result = personalService.getCodeForfindPasswd(userId, mobileno); if (result != null) { if (result.getInteger("retcode") != 0) { return result.toJSONString(); } MobileCodeResult codeResult = new MobileCodeResult(); codeResult.setExpiredtime(result.getLong("expiredtime")); return OpenResult.ok().add("data", codeResult).buildJson(); } else { return OpenResult.unknown("服务异常").buildJson(); } } catch (StockServiceException e) { log.error("找回密码时获取验证码异常:" + e); return OpenResult.serviceError(e.getRetcode(), e.getMsg()).buildJson(); } }
@Path("/findpwd/modifypwd") @POST @Produces("application/json;charset=utf-8") public String modifyPwd(String content) { if (StringUtils.isEmpty(content)) { return OpenResult.parameterError("无参数").buildJson(); } JSONObject json = JSONObject.parseObject(content); String validcode = json.getString("validcode"); String passwd = json.getString("passwd"); String idNumber = json.getString("idNumber"); try { // session自动延期 boolean flag = checkIdNumber(idNumber); if (log.isDebugEnabled()) { log.debug("找回密码自延期" + flag); } JSONObject result = null; // 获取存放在json中的用户信息 json = getUser(idNumber); String userId = null; String mobileno = null; if (json != null) { userId = json.getString("userid"); mobileno = json.getString("mobileno"); } else { JSONObject info = personalService.queryUserInfo(idNumber); if (info != null) { mobileno = info.getString("mobileno"); userId = info.getString("userid"); } else { return OpenResult.parameterError("请输入注册身份证号码").buildJson(); } } if (StringUtils.isEmpty(userId) || StringUtils.isEmpty(mobileno) || StringUtils.isEmpty(validcode) || StringUtils.isEmpty(passwd)) { return OpenResult.parameterError("参数错误").buildJson(); } result = personalService.validCodeForFindPasswd(userId, mobileno, validcode); int retcode = result.getInteger("retcode"); if (retcode != 0) { if (retcode == 10202) { return OpenResult.serviceError(retcode, "验证码错误!").buildJson(); } else { return result.toJSONString(); } } /*JSONObject re = personalService.modifyPasswd(userId, mobileno, validcode, passwd); if (re != null) { return re.toJSONString(); } else { return OpenResult.unknown("服务异常").buildJson(); }*/ return OpenResult.ok().buildJson(); } catch (StockServiceException e) { log.error("修改密码异常:" + e); return OpenResult.serviceError(e.getRetcode(), e.getMsg()).buildJson(); } }