|
@ -956,6 +956,67 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
|
|
|
throw new IllegalStateException("验证码发送失败!");
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/oauth/sendMlwCaptcha", method = RequestMethod.GET)
|
|
|
public ResponseEntity<Oauth2Envelop<Captcha>> sendMlwCaptcha(@RequestParam Map<String, String> parameters) throws Exception {
|
|
|
String client_id = parameters.get("client_id");
|
|
|
String username = parameters.get("username");
|
|
|
if (StringUtils.isEmpty(client_id)) {
|
|
|
throw new InvalidRequestException("client_id");
|
|
|
}
|
|
|
if (StringUtils.isEmpty(username)) {
|
|
|
throw new InvalidRequestException("username");
|
|
|
}
|
|
|
if (username.length()>12){
|
|
|
throw new InvalidRequestException("请输入正确的手机号!");
|
|
|
}
|
|
|
//验证请求间隔超时,防止频繁获取验证码
|
|
|
if (!wlyyRedisVerifyCodeService.isIntervalTimeout(client_id, username)) {
|
|
|
throw new IllegalAccessException("SMS request frequency is too fast");
|
|
|
}
|
|
|
WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedSMS");
|
|
|
if (wlyyHospitalSysDictDO!=null&&!StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())){
|
|
|
String captcha = wlyyHospitalSysDictDO.getDictValue();
|
|
|
Captcha _captcha = new Captcha();
|
|
|
_captcha.setCode(captcha);
|
|
|
_captcha.setExpiresIn(300);
|
|
|
wlyyRedisVerifyCodeService.store(client_id, username, captcha, 300);
|
|
|
|
|
|
Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>("success", 200);
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
headers.set("Cache-Control", "no-store");
|
|
|
headers.set("Pragma", "no-cache");
|
|
|
return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
|
|
|
}else {
|
|
|
//发送短信获取验证码
|
|
|
String captcha = wlyyRedisVerifyCodeService.getCodeNumber();
|
|
|
SmsDO smsDO = new SmsDO();
|
|
|
smsDO.setCaptcha(captcha);
|
|
|
smsDO.setClientId(client_id);
|
|
|
smsDO.setContent("您好,你的手机登录短信验证码是:"+captcha+",5分钟内有效。");
|
|
|
smsDO.setMobile(username);
|
|
|
smsDO.setDeadline(DateUtil.getNextMin(new Date(),5));
|
|
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
|
|
smsDO.setRequestIp(NetworkUtil.getIpAddress(request));
|
|
|
smsDO.setCreateTime(new Date());
|
|
|
baseSmsDao.save(smsDO);
|
|
|
//
|
|
|
String result = txySmsService.sendMessage(username,captcha);
|
|
|
if ("Ok".equals(result)) {
|
|
|
Captcha _captcha = new Captcha();
|
|
|
_captcha.setCode(captcha);
|
|
|
_captcha.setExpiresIn(300);
|
|
|
wlyyRedisVerifyCodeService.store(client_id, username, captcha, 300);
|
|
|
|
|
|
Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>("captcha", 200, null);
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
headers.set("Cache-Control", "no-store");
|
|
|
headers.set("Pragma", "no-cache");
|
|
|
return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
|
|
|
}
|
|
|
}
|
|
|
throw new IllegalStateException("验证码发送失败!");
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/oauth/sendCaptcha", method = RequestMethod.GET)
|
|
|
public ResponseEntity<Oauth2Envelop<Captcha>> sendCaptcha(@RequestParam Map<String, String> parameters) throws Exception {
|
|
|
String wxId = parameters.get("wxId");
|
|
@ -976,6 +1037,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
|
|
|
return sendZBCaptcha(parameters);
|
|
|
}else if("hz_yyyzh_wx".equals(wxId)){
|
|
|
return sendTXYCaptcha(parameters);
|
|
|
}else if("xm_mlwyy_wx".equals(wxId)){
|
|
|
return sendMlwCaptcha(parameters);
|
|
|
}
|
|
|
throw new IllegalStateException("验证码发送失败");
|
|
|
}
|