!11 Merge branch 'develop' of https://gitee.com/L-Shilin/go-fly-platform-s…
Merge pull request !11 from Iamasoldier/feature_temp
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
# 订单中心CDN预热配置
|
||||
cdn:
|
||||
prefetch:
|
||||
# 是否启用CDN预热功能
|
||||
enabled: true
|
||||
# 每批次预热的文件数量
|
||||
batch-size: 50
|
||||
# 预热区域:domestic-仅中国内地,overseas-全球(不包含中国内地),不传-全球
|
||||
area: domestic
|
||||
|
||||
# 日志配置
|
||||
logging:
|
||||
level:
|
||||
com.central.order.controller.OrderFileController: DEBUG
|
||||
@@ -126,3 +126,18 @@ wx:
|
||||
activity-start: lgwkRnbdDc3mEwk3RMob43LpLHnLfglZtTkbFRPsPCA
|
||||
order-complete: ZeIlAA6ImQLxBiLmo-53lM7wkL4KnuKKTGKWBZwYAdM
|
||||
video-edit-complete: IXpL-Voztm3GM-zFj3sxA39qy8oRtAcxTiT7_Qsyz9Q
|
||||
|
||||
# 订单中心CDN预热配置
|
||||
cdn:
|
||||
prefetch:
|
||||
# 是否启用CDN预热功能
|
||||
enabled: true
|
||||
# 每批次预热的文件数量
|
||||
batch-size: 50
|
||||
# 预热区域:domestic-仅中国内地,overseas-全球(不包含中国内地),不传-全球
|
||||
area: domestic
|
||||
|
||||
# 日志配置
|
||||
logging:
|
||||
level:
|
||||
com.central.order.controller.OrderFileController: DEBUG
|
||||
@@ -21,6 +21,7 @@
|
||||
<module>zlt-common-core</module>
|
||||
<module>zlt-elasticsearch-spring-boot-starter</module>
|
||||
<module>zlt-oss-spring-boot-starter</module>
|
||||
<module>zlt-sms-spring-boot-starter</module>
|
||||
<module>zlt-zookeeper-spring-boot-starter</module>
|
||||
<module>zlt-wechat-common-core</module>
|
||||
<module>zlt-wechat-spring-boot-starter</module>
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-commons</artifactId>
|
||||
<version>6.0.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
<artifactId>zlt-sms-spring-boot-starter</artifactId>
|
||||
<description>短信服务通用组件</description>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.tencentcloudapi</groupId>
|
||||
<artifactId>tencentcloud-sdk-java</artifactId>
|
||||
<version>3.1.825</version>
|
||||
</dependency>
|
||||
<!-- 腾讯云短信SDK依赖可后续补充 -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
|
||||
<version>2.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||
<version>4.5.20</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.83</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||
<version>4.6.4</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.tencentcloudapi</groupId>
|
||||
<artifactId>tencentcloud-sdk-java-common</artifactId>
|
||||
<version>3.1.1040</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.central.sms.config;
|
||||
|
||||
import com.central.sms.service.ISmsService;
|
||||
import com.central.sms.service.SmsServiceFactory;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(SmsProperties.class)
|
||||
public class SmsAutoConfigure {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(ISmsService.class)
|
||||
public ISmsService smsService(SmsServiceFactory factory) {
|
||||
return factory.getSmsService();
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package com.central.sms.config;
|
||||
|
||||
import com.central.sms.enums.SmsProviderType;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties(prefix = "sms")
|
||||
public class SmsProperties {
|
||||
private SmsProviderType provider = SmsProviderType.TENCENT;
|
||||
private TencentConfig tencent = new TencentConfig();
|
||||
private AliyunConfig aliyun = new AliyunConfig();
|
||||
|
||||
public SmsProviderType getProvider() { return provider; }
|
||||
public void setProvider(SmsProviderType provider) { this.provider = provider; }
|
||||
public TencentConfig getTencent() { return tencent; }
|
||||
public void setTencent(TencentConfig tencent) { this.tencent = tencent; }
|
||||
public AliyunConfig getAliyun() { return aliyun; }
|
||||
public void setAliyun(AliyunConfig aliyun) { this.aliyun = aliyun; }
|
||||
|
||||
public static class TencentConfig {
|
||||
private String appId;
|
||||
private String secretId;
|
||||
private String secretKey;
|
||||
private String signName;
|
||||
public String getAppId() { return appId; }
|
||||
public void setAppId(String appId) { this.appId = appId; }
|
||||
public String getSecretId() { return secretId; }
|
||||
public void setSecretId(String secretId) { this.secretId = secretId; }
|
||||
public String getSecretKey() { return secretKey; }
|
||||
public void setSecretKey(String secretKey) { this.secretKey = secretKey; }
|
||||
public String getSignName() { return signName; }
|
||||
public void setSignName(String signName) { this.signName = signName; }
|
||||
}
|
||||
|
||||
public static class AliyunConfig {
|
||||
private String accessKeyId;
|
||||
private String accessKeySecret;
|
||||
private String signName;
|
||||
public String getAccessKeyId() { return accessKeyId; }
|
||||
public void setAccessKeyId(String accessKeyId) { this.accessKeyId = accessKeyId; }
|
||||
public String getAccessKeySecret() { return accessKeySecret; }
|
||||
public void setAccessKeySecret(String accessKeySecret) { this.accessKeySecret = accessKeySecret; }
|
||||
public String getSignName() { return signName; }
|
||||
public void setSignName(String signName) { this.signName = signName; }
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package com.central.sms.enums;
|
||||
|
||||
public enum SmsProviderType {
|
||||
TENCENT,
|
||||
ALIYUN
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.central.sms.exception;
|
||||
|
||||
public class SmsSendException extends RuntimeException {
|
||||
public SmsSendException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.central.sms.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface ISmsService {
|
||||
/**
|
||||
* 发送短信
|
||||
* @param phone 手机号
|
||||
* @param templateId 短信模板ID
|
||||
* @param params 模板参数
|
||||
* @return 是否发送成功
|
||||
*/
|
||||
boolean sendSms(String phone, String templateId, Map<String, String> params);
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.central.sms.service;
|
||||
|
||||
import com.central.sms.config.SmsProperties;
|
||||
import com.central.sms.enums.SmsProviderType;
|
||||
import com.central.sms.service.impl.AliyunSmsService;
|
||||
import com.central.sms.service.impl.TencentSmsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class SmsServiceFactory {
|
||||
|
||||
@Autowired
|
||||
private TencentSmsService tencentSmsService;
|
||||
@Autowired
|
||||
private AliyunSmsService aliyunSmsService;
|
||||
@Autowired
|
||||
private SmsProperties smsProperties;
|
||||
|
||||
public ISmsService getSmsService() {
|
||||
SmsProviderType type = smsProperties.getProvider();
|
||||
switch (type) {
|
||||
case ALIYUN:
|
||||
return aliyunSmsService;
|
||||
case TENCENT:
|
||||
default:
|
||||
return tencentSmsService;
|
||||
}
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package com.central.sms.service.impl;
|
||||
|
||||
import com.aliyuncs.DefaultAcsClient;
|
||||
import com.aliyuncs.IAcsClient;
|
||||
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
|
||||
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
import com.aliyuncs.profile.DefaultProfile;
|
||||
import com.central.sms.config.SmsProperties;
|
||||
import com.central.sms.exception.SmsSendException;
|
||||
import com.central.sms.service.ISmsService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class AliyunSmsService implements ISmsService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AliyunSmsService.class);
|
||||
|
||||
@Autowired
|
||||
private SmsProperties smsProperties;
|
||||
|
||||
@Override
|
||||
public boolean sendSms(String phone, String templateId, Map<String, String> params) {
|
||||
SmsProperties.AliyunConfig config = smsProperties.getAliyun();
|
||||
DefaultProfile profile = DefaultProfile.getProfile(
|
||||
"cn-hangzhou", // 地域ID
|
||||
config.getAccessKeyId(),
|
||||
config.getAccessKeySecret()
|
||||
);
|
||||
IAcsClient client = new DefaultAcsClient(profile);
|
||||
|
||||
SendSmsRequest request = new SendSmsRequest();
|
||||
request.setPhoneNumbers(phone);
|
||||
request.setSignName(config.getSignName());
|
||||
request.setTemplateCode(templateId);
|
||||
// 阿里云短信模板参数为JSON字符串
|
||||
if (params != null && !params.isEmpty()) {
|
||||
request.setTemplateParam(com.alibaba.fastjson.JSON.toJSONString(params));
|
||||
}
|
||||
|
||||
try {
|
||||
logger.info("[阿里云短信] 发送请求: 手机号={}, 模板={}, 参数={}", phone, templateId, params);
|
||||
SendSmsResponse response = client.getAcsResponse(request);
|
||||
logger.info("[阿里云短信] 发送结果: {}", response.getMessage());
|
||||
return "OK".equalsIgnoreCase(response.getCode());
|
||||
} catch (ClientException e) {
|
||||
logger.error("[阿里云短信] 发送失败,手机号:{},模板:{},参数:{},异常:{}", phone, templateId, params, e.getMessage(), e);
|
||||
throw new SmsSendException("阿里云短信发送失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package com.central.sms.service.impl;
|
||||
|
||||
import com.central.sms.config.SmsProperties;
|
||||
import com.central.sms.exception.SmsSendException;
|
||||
import com.central.sms.service.ISmsService;
|
||||
import com.tencentcloudapi.common.Credential;
|
||||
import com.tencentcloudapi.common.profile.ClientProfile;
|
||||
import com.tencentcloudapi.common.profile.HttpProfile;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class TencentSmsService implements ISmsService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(TencentSmsService.class);
|
||||
|
||||
@Autowired
|
||||
private SmsProperties smsProperties;
|
||||
|
||||
@Override
|
||||
public boolean sendSms(String phone, String templateId, Map<String, String> params) {
|
||||
try {
|
||||
SmsProperties.TencentConfig config = smsProperties.getTencent();
|
||||
logger.info("[短信发送][服务商:TENCENT] 手机号={}, 模板ID={}, 参数={}", phone, templateId, params);
|
||||
Credential cred = new Credential(config.getSecretId(), config.getSecretKey());
|
||||
HttpProfile httpProfile = new HttpProfile();
|
||||
httpProfile.setEndpoint("sms.tencentcloudapi.com");
|
||||
ClientProfile clientProfile = new ClientProfile();
|
||||
clientProfile.setHttpProfile(httpProfile);
|
||||
/*SmsClient client = new SmsClient(cred, "ap-guangzhou", clientProfile);
|
||||
|
||||
SendSmsRequest req = new SendSmsRequest();
|
||||
req.setSmsSdkAppId(config.getAppId());
|
||||
req.setSignName(config.getSignName());
|
||||
req.setTemplateId(templateId);
|
||||
req.setPhoneNumberSet(new String[]{phone});
|
||||
req.setTemplateParamSet(params.values().toArray(new String[0]));
|
||||
|
||||
SendSmsResponse resp = client.SendSms(req);
|
||||
logger.info("[短信发送][服务商:TENCENT] 响应: code={}, message={}", resp.getSendStatusSet()[0].getCode(), resp.getSendStatusSet()[0].getMessage());
|
||||
return "Ok".equalsIgnoreCase(resp.getSendStatusSet()[0].getCode());*/
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
logger.error("[短信发送][服务商:TENCENT] 失败,手机号:{},模板ID:{},参数:{},异常:{}", phone, templateId, params, e.getMessage(), e);
|
||||
throw new SmsSendException("腾讯云短信发送失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
com.central.sms.config.SmsAutoConfigure
|
||||
@@ -91,3 +91,17 @@ zlt.wxpay.apiV3Key=aIt5Vw3cYXSCSd4L5h14kIyDsoXBow7r
|
||||
|
||||
|
||||
zlt.tenant.id: webApp
|
||||
|
||||
# 选择服务商:TENCENT 或 ALIYUN
|
||||
sms.provider=ALIYUN
|
||||
|
||||
# 腾讯云短信配置
|
||||
sms.tencent.appId=1400xxxxxxx # 短信应用ID
|
||||
sms.tencent.secretId=AKIDxxxxxxx # 控制台API密钥
|
||||
sms.tencent.secretKey=xxxxxxxxxxxx # 控制台API密钥
|
||||
sms.tencent.signName=xxx
|
||||
|
||||
# 阿里云短信配置
|
||||
sms.aliyun.accessKeyId=xxx
|
||||
sms.aliyun.accessKeySecret=xxx
|
||||
sms.aliyun.signName=xxx
|
||||
|
||||
@@ -78,3 +78,17 @@ zlt.wxpay.privateKeyPath=/data/zlt/cert/apiclient_key.pem
|
||||
zlt.wxpay.apiV3Key=aIt5Vw3cYXSCSd4L5h14kIyDsoXBow7r
|
||||
|
||||
zlt.tenant.id: webApp
|
||||
|
||||
# 选择服务商:TENCENT 或 ALIYUN
|
||||
sms.provider=ALIYUN
|
||||
|
||||
# 腾讯云短信配置
|
||||
sms.tencent.appId=1400xxxxxxx # 短信应用ID
|
||||
sms.tencent.secretId=AKIDxxxxxxx # 控制台API密钥
|
||||
sms.tencent.secretKey=xxxxxxxxxxxx # 控制台API密钥
|
||||
sms.tencent.signName=xxx
|
||||
|
||||
# 阿里云短信配置
|
||||
sms.aliyun.accessKeyId=xxx
|
||||
sms.aliyun.accessKeySecret=xxx
|
||||
sms.aliyun.signName=xxx
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
########################## bootstrap级别通用配置 ##########################
|
||||
# 默认开发环境
|
||||
spring.profiles.active=prod
|
||||
spring.profiles.active=dev
|
||||
|
||||
##### nacos(注册中心和配置中心)地址
|
||||
spring.cloud.nacos.server-addr=81.70.164.178:8848
|
||||
#spring.cloud.nacos.server-addr=127.0.0.1:8848
|
||||
#spring.cloud.nacos.server-addr=81.70.164.178:8848
|
||||
spring.cloud.nacos.server-addr=127.0.0.1:8848
|
||||
spring.cloud.nacos.username=nacos
|
||||
#spring.cloud.nacos.password=nacos
|
||||
spring.cloud.nacos.password=nacosGFLY
|
||||
spring.cloud.nacos.password=nacos
|
||||
#spring.cloud.nacos.password=nacosGFLY
|
||||
spring.cloud.nacos.config.file-extension=yml
|
||||
spring.cloud.nacos.config.shared-configs[0].data-id=common.yml
|
||||
spring.cloud.nacos.config.shared-configs[0].refresh=true
|
||||
|
||||
Reference in New Issue
Block a user