|
@@ -58,7 +58,7 @@ public class TMessageCodeController {
|
|
|
|
|
|
@ApiOperation(value = "发送注册验证码")
|
|
|
@PostMapping("/sentRegisterCode")
|
|
|
- public ResponseModel<?> sentRegisterCode(String ifForeign, String phoneOrEmail) {
|
|
|
+ public ResponseModel<?> sentRegisterCode(String ifForeign, String phoneOrEmail, String hostName) {
|
|
|
if (StringUtils.isEmpty(phoneOrEmail)) {
|
|
|
// 说明参数为空
|
|
|
return R.fail(ResponseCodesEnum.A0100, "手机号或邮箱为空!");
|
|
@@ -66,10 +66,17 @@ public class TMessageCodeController {
|
|
|
// 查询该 手机号/邮箱 最后一次发送验证码的时间
|
|
|
Date lastSendTime = tMessageCodeService.getLastSendTime(phoneOrEmail);
|
|
|
long lastTime = lastSendTime.getTime();
|
|
|
- long currentTime = new Date().getTime();
|
|
|
+ long currentTime = System.currentTimeMillis();
|
|
|
if (currentTime - lastTime < 10 * 60 * 1000) {
|
|
|
return R.fail("请勿频繁发送,10分钟后再试");
|
|
|
}
|
|
|
+ String SZ = "Sunzee";
|
|
|
+ String companyType = "";
|
|
|
+ if (StringUtils.isNotEmpty(hostName) && SZ.equals(hostName)) {
|
|
|
+ companyType = "0";
|
|
|
+ } else {
|
|
|
+ companyType = "1";
|
|
|
+ }
|
|
|
// 如果是国内
|
|
|
if (ifForeign.equals("0")) {
|
|
|
// 定义国内手机号和邮箱的正则表达式
|
|
@@ -86,7 +93,7 @@ public class TMessageCodeController {
|
|
|
return R.fail(ResponseCodesEnum.A0202, "用户手机号已存在");
|
|
|
}
|
|
|
// 国内发送短信
|
|
|
- String result = tMessageCodeService.sentMessage("0", phoneOrEmail);
|
|
|
+ String result = tMessageCodeService.sentMessage("0", phoneOrEmail, companyType);
|
|
|
return R.ok(result);
|
|
|
} else if (Pattern.matches(emailReg, phoneOrEmail)) {
|
|
|
// 检测是否已有邮箱注册
|
|
@@ -104,10 +111,6 @@ public class TMessageCodeController {
|
|
|
return R.fail(ResponseCodesEnum.A0100, "不是有效的手机号或邮箱地址");
|
|
|
}
|
|
|
} else {
|
|
|
- // 海外
|
|
|
-// if (StringUtils.isEmpty(phoneOrEmail)) {
|
|
|
-// return R.fail(ResponseCodesEnum.A0100, "邮箱为空!");
|
|
|
-// }
|
|
|
//检测是否已有邮箱注册
|
|
|
LambdaQueryWrapper<TAdmin> query = Wrappers.lambdaQuery();
|
|
|
query.eq(TAdmin::getEmail, phoneOrEmail);
|
|
@@ -123,7 +126,7 @@ public class TMessageCodeController {
|
|
|
|
|
|
@ApiOperation(value = "发送忘记密码验证码")
|
|
|
@PostMapping("/sentForgetCode")
|
|
|
- public ResponseModel<?> sentForgetCode(String ifForeign, String username, String phoneOrEmail) {
|
|
|
+ public ResponseModel<?> sentForgetCode(String ifForeign, String username, String phoneOrEmail, String hostName) {
|
|
|
|
|
|
if (StringUtils.isEmpty(username)) {
|
|
|
return R.fail(ResponseCodesEnum.A0100, "用户名为空!");
|
|
@@ -131,6 +134,13 @@ public class TMessageCodeController {
|
|
|
if (ifForeign.equals("2")) {
|
|
|
ifForeign = "0";
|
|
|
}
|
|
|
+ String SZ = "Sunzee";
|
|
|
+ String companyType = "";
|
|
|
+ if (StringUtils.isNotEmpty(hostName) && SZ.equals(hostName)) {
|
|
|
+ companyType = "0";
|
|
|
+ } else {
|
|
|
+ companyType = "1";
|
|
|
+ }
|
|
|
// 如果是国内
|
|
|
if (ifForeign.equals("0")) {
|
|
|
if (StringUtils.isEmpty(phoneOrEmail)) {
|
|
@@ -152,7 +162,7 @@ public class TMessageCodeController {
|
|
|
return R.fail(ResponseCodesEnum.A0001, "登录名或手机号出错");
|
|
|
}
|
|
|
//国内发送短信
|
|
|
- String result = tMessageCodeService.sentMessage("1", phoneOrEmail);
|
|
|
+ String result = tMessageCodeService.sentMessage("1", phoneOrEmail, companyType);
|
|
|
return R.ok(result);
|
|
|
} else if (Pattern.matches(emailReg, phoneOrEmail)) {
|
|
|
System.out.println("忘记密码 >>> 这是一个邮箱地址");
|