|
|
@@ -1,10 +1,12 @@
|
|
|
package com.sckw.message.service;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
+import com.sckw.core.common.enums.EnvConstant;
|
|
|
import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
|
import com.sckw.core.exception.BusinessException;
|
|
|
import com.sckw.core.model.constant.Global;
|
|
|
import com.sckw.core.utils.CollectionUtils;
|
|
|
+import com.sckw.core.utils.NumberUtils;
|
|
|
import com.sckw.core.utils.StringUtils;
|
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
|
import com.sckw.message.model.vo.req.GetSmsVerifyCoderReqVO;
|
|
|
@@ -17,6 +19,7 @@ import com.sckw.system.api.RemoteSystemService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.cloud.stream.function.StreamBridge;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -40,6 +43,10 @@ public class SmsService {
|
|
|
@DubboReference(version = "1.0.0", group = "design", check = false)
|
|
|
private RemoteSystemService remoteSystemService;
|
|
|
|
|
|
+ @Value("${spring.profiles.active}")
|
|
|
+ private String env;
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* @param param
|
|
|
* @return com.sckw.core.web.response.HttpResult
|
|
|
@@ -50,9 +57,9 @@ public class SmsService {
|
|
|
public void sendVerifyCode(SendSmsVerifyCoderReqVO param) {
|
|
|
Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(Collections.singletonList(DictTypeEnum.SEND_SMS_TYPE.getType()));
|
|
|
Map<String, String> map;
|
|
|
- if (CollectionUtils.isNotEmpty(dict)){
|
|
|
+ if (CollectionUtils.isNotEmpty(dict)) {
|
|
|
map = dict.get(DictTypeEnum.SEND_SMS_TYPE.getType());
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
map = new HashMap<>();
|
|
|
}
|
|
|
String type = param.getType();
|
|
|
@@ -65,9 +72,9 @@ public class SmsService {
|
|
|
throw new BusinessException("请勿频繁获取短信验证码!");
|
|
|
}
|
|
|
Map<String, Object> params = new HashMap<>(Global.NUMERICAL_SIXTEEN);
|
|
|
- //TODO:测试先写死code码为123456,上线再放开
|
|
|
- params.put("code", 123456);
|
|
|
-// params.put("code", NumberUtils.createRandomVcode());
|
|
|
+ //生产环境才发短信
|
|
|
+ String code = EnvConstant.PROD.equals(env) ? NumberUtils.createRandomVcode() : "123456";
|
|
|
+ params.put("code", code);
|
|
|
SckwSms sckwSms = new SckwSms();
|
|
|
sckwSms.setPhone(param.getPhone()).setType(type).setTemplateCode(SmsCodeEnum.VERIFICATION_CODE)
|
|
|
.setParams(params).setCreateBy(LoginUserHolder.getUserId());
|