Merge branch 'dev' into test
This commit is contained in:
@@ -17,6 +17,7 @@ import com.intc.common.mail.utils.MailUtils;
|
||||
import com.intc.common.ratelimiter.annotation.RateLimiter;
|
||||
import com.intc.common.ratelimiter.enums.LimitType;
|
||||
import com.intc.common.redis.utils.RedisUtils;
|
||||
import com.intc.common.sms.config.properties.SmsProperties;
|
||||
import com.intc.common.web.config.properties.CaptchaProperties;
|
||||
import com.intc.common.web.enums.CaptchaType;
|
||||
import com.intc.web.domain.vo.CaptchaVo;
|
||||
@@ -50,6 +51,7 @@ public class CaptchaController {
|
||||
|
||||
private final CaptchaProperties captchaProperties;
|
||||
private final MailProperties mailProperties;
|
||||
private final SmsProperties smsProperties;
|
||||
|
||||
/**
|
||||
* 短信验证码
|
||||
@@ -60,17 +62,45 @@ public class CaptchaController {
|
||||
@GetMapping("/resource/sms/code")
|
||||
public R<Void> smsCode(@NotBlank(message = "{user.phonenumber.not.blank}") String phonenumber) {
|
||||
String key = GlobalConstants.CAPTCHA_CODE_KEY + phonenumber;
|
||||
String code = RandomUtil.randomNumbers(4);
|
||||
String code = RandomUtil.randomNumbers(6);
|
||||
RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
|
||||
// 验证码模板id 自行处理 (查数据库或写死均可)
|
||||
String templateId = "";
|
||||
// 验证码模板id 从配置文件读取
|
||||
String templateId = smsProperties.getCodeTemplateId();
|
||||
if (StringUtils.isBlank(templateId)) {
|
||||
log.error("短信验证码模板ID未配置,请在配置文件中设置 sms.plus.code-template-id");
|
||||
return R.fail("短信服务配置错误,请联系管理员");
|
||||
}
|
||||
LinkedHashMap<String, String> map = new LinkedHashMap<>(1);
|
||||
map.put("code", code);
|
||||
SmsBlend smsBlend = SmsFactory.getSmsBlend("config1");
|
||||
SmsResponse smsResponse = smsBlend.sendMessage(phonenumber, templateId, map);
|
||||
if (!smsResponse.isSuccess()) {
|
||||
log.error("验证码短信发送异常 => {}", smsResponse);
|
||||
return R.fail(smsResponse.getData().toString());
|
||||
// 解析错误信息
|
||||
String errorMsg = "短信发送失败";
|
||||
if (smsResponse.getData() != null) {
|
||||
String data = smsResponse.getData().toString();
|
||||
if (data.contains("SMS_TEMPLATE_ILLEGAL")) {
|
||||
errorMsg = "短信模板不存在,请联系管理员配置正确的模板ID";
|
||||
} else if (data.contains("SMS_SIGNATURE_ILLEGAL")) {
|
||||
errorMsg = "短信签名不存在,请联系管理员配置正确的签名";
|
||||
} else if (data.contains("Message")) {
|
||||
// 尝试提取Message字段
|
||||
try {
|
||||
int msgStart = data.indexOf("Message\":\"") + 10;
|
||||
int msgEnd = data.indexOf("\"", msgStart);
|
||||
if (msgStart > 10 && msgEnd > msgStart) {
|
||||
String message = data.substring(msgStart, msgEnd);
|
||||
errorMsg = "短信发送失败:" + message;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("解析短信错误信息失败", e);
|
||||
}
|
||||
} else if (data.contains("isv.")) {
|
||||
errorMsg = "短信服务配置错误,请联系管理员";
|
||||
}
|
||||
}
|
||||
return R.fail(errorMsg);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ spring:
|
||||
# username: root
|
||||
# password: root
|
||||
driverClassName: org.postgresql.Driver
|
||||
url: jdbc:postgresql://154.8.147.51:15432/fishery_dev?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
|
||||
url: jdbc:postgresql://81.70.89.108:15432/fishery_dev?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
|
||||
username: postgres
|
||||
password: intc@123987
|
||||
# 从库数据源 - TDengine
|
||||
@@ -60,7 +60,7 @@ spring:
|
||||
type: ${spring.datasource.type}
|
||||
driverClassName: com.taosdata.jdbc.rs.RestfulDriver
|
||||
# 不指定数据库名,在 SQL 中使用完整路径 fishery.table_name
|
||||
url: jdbc:TAOS-RS://154.8.147.51:6041?timezone=Shanghai&charset=UTF-8&locale=en_US.UTF-8
|
||||
url: jdbc:TAOS-RS://81.70.89.108:6041?timezone=Shanghai&charset=UTF-8&locale=en_US.UTF-8
|
||||
username: root
|
||||
password: intc@123456
|
||||
hikari:
|
||||
@@ -106,13 +106,13 @@ spring:
|
||||
spring.data:
|
||||
redis:
|
||||
# 地址
|
||||
host: 154.8.147.51
|
||||
host: 81.70.89.108
|
||||
# 端口,默认为6379
|
||||
port: 6379
|
||||
port: 26379
|
||||
# 数据库索引
|
||||
database: 9
|
||||
# redis 密码必须配置
|
||||
password: intc@123987
|
||||
password: bbd4b56e5d3f
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
# 是否开启ssl
|
||||
@@ -185,7 +185,9 @@ sms:
|
||||
access-key-id: LTAI5tRnPowmTLjH181nSbsR
|
||||
# 称为accessSecret有些称之为apiSecret
|
||||
access-key-secret: Vh2LoAM1t3XuMUVy2wTWSACJ97kOUW
|
||||
signature: 【鱼测云】
|
||||
# 短信签名:需要在阿里云控制台创建并审核通过,格式如:鱼测云(不带【】符号)
|
||||
# 请在阿里云短信服务控制台 -> 国内消息 -> 签名管理 中查看您的签名
|
||||
signature: 鱼测云 # TODO: 请填写您的阿里云短信签名(不带【】符号)
|
||||
sdk-app-id: 您的sdkAppId
|
||||
config2:
|
||||
# 厂商标识,标定此配置是哪个厂商,详细请看厂商标识介绍部分
|
||||
@@ -194,6 +196,12 @@ sms:
|
||||
access-key-secret: 您的accessKeySecret
|
||||
signature: 您的短信签名
|
||||
sdk-app-id: 您的sdkAppId
|
||||
# plus扩展配置
|
||||
plus:
|
||||
# 短信验证码模板ID(请根据实际短信服务商的模板ID配置)
|
||||
# 请在阿里云短信服务控制台获取真实的模板CODE,格式如:SMS_460655548
|
||||
# 模板内容需包含 ${code} 参数
|
||||
code-template-id: 'SMS_465720430' # TODO: 请填写您的阿里云短信模板CODE
|
||||
|
||||
|
||||
--- # 三方授权
|
||||
|
||||
@@ -187,6 +187,10 @@ sms:
|
||||
access-key-secret: 您的accessKeySecret
|
||||
signature: 您的短信签名
|
||||
sdk-app-id: 您的sdkAppId
|
||||
# plus扩展配置
|
||||
plus:
|
||||
# 短信验证码模板ID(请根据实际短信服务商的模板ID配置)
|
||||
code-template-id: SMS_123456789
|
||||
|
||||
--- # 三方授权
|
||||
justauth:
|
||||
|
||||
@@ -171,7 +171,7 @@ mybatis-encryptor:
|
||||
# api接口加密
|
||||
api-decrypt:
|
||||
# 是否开启全局接口加密
|
||||
enabled: true
|
||||
enabled: false
|
||||
# AES 加密头标识
|
||||
headerFlag: encrypt-key
|
||||
# 响应加密公钥 非对称算法的公私钥 如:SM2,RSA 使用者请自行更换
|
||||
|
||||
Reference in New Issue
Block a user