|
@ -94,6 +94,59 @@ public class SMSController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "checkCaptcha", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
public String send2(String mobile, int type, @RequestParam(required = false) String captchaToken) {
|
|
|
try {
|
|
|
if (type > 10 || type < 1) {
|
|
|
return error(-1, "无效的请求!");
|
|
|
}
|
|
|
if (StringUtils.isEmpty(mobile)) {
|
|
|
return error(-1, "手机号码不允许为空!");
|
|
|
}
|
|
|
// if (type == 4) {
|
|
|
// // 登录时校验用户是否存在
|
|
|
// List<Patient> patients = patientDao.findByMobile(mobile);
|
|
|
// if (patients == null||patients.size()==0) {
|
|
|
// return error(-1, "该手机号未注册!");
|
|
|
// }
|
|
|
// } else if (type == 5) {
|
|
|
// // 登录时校验用户是否存在
|
|
|
// Doctor doctor = doctorDao.findByMobile(mobile);
|
|
|
// if (doctor == null) {
|
|
|
// return error(-1, "该手机号未注册!");
|
|
|
// }
|
|
|
// }
|
|
|
if (StringUtils.isNotEmpty(captchaToken)) {
|
|
|
String ct = request.getSession().getAttribute("captchaToken").toString();
|
|
|
if (!StringUtils.equalsIgnoreCase(captchaToken, ct)) {
|
|
|
return error(-1, "图形验证码错误!");
|
|
|
}
|
|
|
}
|
|
|
// 获取ip地址
|
|
|
String ip = NetworkUtil.getIpAddress(request);
|
|
|
if (StringUtils.isEmpty(ip)) {
|
|
|
return error(-1, "无效的ip请求!");
|
|
|
}
|
|
|
// String res = smsService.send(mobile, ip, type, getUID());
|
|
|
String res = null;
|
|
|
//内网发送 通过redis的队列
|
|
|
if("local".equals(springProfiles)){
|
|
|
res = smsService.sendToNeiWang(mobile, ip, type);
|
|
|
}else {
|
|
|
res = smsService.send(mobile, ip, type, getRepUID());
|
|
|
}
|
|
|
if (StringUtils.equals(res, "ok")) {
|
|
|
return write(200, "验证码短信已发送!");
|
|
|
} else {
|
|
|
return error(-1, res);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
return error(-1, "短信发送失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 验证手机验证码
|
|
|
* @param type 消息类型:1微信端注册,2微信端找回密码,3医生端找回密码
|