@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(); } }
/** * 获取手机验证码 * * @param headers * @param content * @return */ @Path("/get/code") @POST @Produces("application/json;charset=utf-8") public String getCode(String content) { // 参数是否为空 if (StringUtils.isEmpty("content")) { return OpenResult.parameterError("无参数").buildJson(); } JSONObject json = JSONObject.parseObject(content); String mobileno = json.getString("mobileno"); // 手机注册验证码:201;手机找回密码:205,重置密码:253 String codetype = json.getString("codetype"); if (StringUtils.isEmpty(mobileno) || StringUtils.isEmpty(codetype)) { return OpenResult.parameterError("参数错误").buildJson(); } // 验证手机号格式是否正确 boolean flag = ValidateUtil.isMobile(mobileno); if (!flag) { return OpenResult.serviceError(10119, "手机号码有误").buildJson(); } // 手机号是否已被注册 JSONObject result = registService.mobileUnique(mobileno); if (result != null) { if (result.getIntValue("retcode") != 0) { return OpenResult.serviceError(result.getIntValue("retcode"), result.getString("msg")) .buildJson(); } } else { return OpenResult.unknown("服务异常").buildJson(); } try { // 获取手机验证码 result = registService.getIdentifyingCode(mobileno); if (result != null) { int retcode = result.getIntValue("retcode"); String msg = result.getString("msg"); if (retcode != 0) { return OpenResult.serviceError(retcode, msg).buildJson(); } } else { return OpenResult.unknown("服务异常").buildJson(); } MobileCodeResult mobileCodeResult = new MobileCodeResult(); Long expiredtime = result.getLong("expiredtime"); mobileCodeResult.setExpiredtime(expiredtime); return OpenResult.ok().add("data", mobileCodeResult).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(); } }