@Path("/findpwd/validcode") @POST @Produces("application/json;charset=utf-8") public String validCodeForFindPwd(String content) { if (StringUtils.isEmpty(content)) { return OpenResult.parameterError("无参数").buildJson(); } JSONObject json = JSONObject.parseObject(content); String userId = json.getString("userid"); String mobileno = json.getString("mobileno"); String validcode = json.getString("validcode"); if (StringUtils.isEmpty(userId) || StringUtils.isEmpty(mobileno) || StringUtils.isEmpty(validcode)) { return OpenResult.parameterError("参数错误").buildJson(); } try { JSONObject result = personalService.validCodeForFindPasswd(userId, mobileno, validcode); 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(); } }