|
@@ -1,23 +1,19 @@
|
|
|
package cn.com.qmth.examcloud.core.basic.service.impl;
|
|
|
|
|
|
-import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
-import cn.com.qmth.examcloud.core.basic.base.constants.PropKeys;
|
|
|
+import org.apache.commons.lang3.RandomUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
import cn.com.qmth.examcloud.core.basic.service.SmsCodeService;
|
|
|
import cn.com.qmth.examcloud.exchange.inner.api.SmsCloudService;
|
|
|
import cn.com.qmth.examcloud.exchange.inner.api.request.CheckSmsCodeReq;
|
|
|
import cn.com.qmth.examcloud.exchange.inner.api.request.SendSmsCodeReq;
|
|
|
-import cn.com.qmth.examcloud.exchange.inner.api.response.CheckIdentifyingCodeResp;
|
|
|
-import cn.com.qmth.examcloud.web.bootstrap.PropertyHolder;
|
|
|
-import org.apache.commons.lang3.RandomUtils;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
|
|
@Service
|
|
|
public class SmsCodeServiceImpl implements SmsCodeService {
|
|
|
|
|
|
@Autowired
|
|
|
- SmsCloudService smsCloudService;
|
|
|
+ SmsCloudService smsCloudService;
|
|
|
|
|
|
@Override
|
|
|
public void sendSmsCode(String phone) {
|
|
@@ -26,21 +22,6 @@ public class SmsCodeServiceImpl implements SmsCodeService {
|
|
|
int code = 1000 + RandomUtils.nextInt(1, 8999);
|
|
|
req.setCode(String.valueOf(code));
|
|
|
|
|
|
- int smsEffectivetime = PropertyHolder.getInt(PropKeys.SEND_VERIFICATION_CODE_EFFECTIVE_TIME,
|
|
|
- 120);
|
|
|
- int smsIntervalSeconds = PropertyHolder
|
|
|
- .getInt(PropKeys.SEND_VERIFICATION_CODE_INTERVAL_SECONDS, 60);
|
|
|
-
|
|
|
- String smsSign = PropertyHolder.getString(PropKeys.SEND_VERIFICATION_CODE_SIGN);
|
|
|
- String smsTemplatecode = PropertyHolder
|
|
|
- .getString(PropKeys.SEND_VERIFICATION_CODE_TEMPLATE_CODE);
|
|
|
-
|
|
|
- if (StringUtils.isBlank(smsSign)) {
|
|
|
- throw new StatusException("001060", "签名未配置");
|
|
|
- }
|
|
|
- if (StringUtils.isBlank(smsTemplatecode)) {
|
|
|
- throw new StatusException("001061", "模板未配置");
|
|
|
- }
|
|
|
smsCloudService.sendSmsCode(req);
|
|
|
}
|
|
|
|
|
@@ -50,10 +31,7 @@ public class SmsCodeServiceImpl implements SmsCodeService {
|
|
|
CheckSmsCodeReq req = new CheckSmsCodeReq();
|
|
|
req.setCode(smsCode);
|
|
|
req.setPhone(phone);
|
|
|
- CheckIdentifyingCodeResp resp = smsCloudService.checkSmsCode(req);
|
|
|
- if (!resp.getSuccess()) {
|
|
|
- throw new StatusException("001050", "验证码错误");
|
|
|
- }
|
|
|
+ smsCloudService.checkSmsCode(req);
|
|
|
}
|
|
|
|
|
|
}
|