新增七牛云短信平台
This commit is contained in:
parent
cc5f8cd58d
commit
0b580d2fe2
|
@ -1,4 +1,5 @@
|
||||||
<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">
|
<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>
|
<parent>
|
||||||
<groupId>net.maku</groupId>
|
<groupId>net.maku</groupId>
|
||||||
<artifactId>fast-boot-module</artifactId>
|
<artifactId>fast-boot-module</artifactId>
|
||||||
|
@ -26,6 +27,10 @@
|
||||||
<groupId>com.tencentcloudapi</groupId>
|
<groupId>com.tencentcloudapi</groupId>
|
||||||
<artifactId>tencentcloud-sdk-java</artifactId>
|
<artifactId>tencentcloud-sdk-java</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.qiniu</groupId>
|
||||||
|
<artifactId>qiniu-java-sdk</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -0,0 +1,40 @@
|
||||||
|
package net.maku.message.sms;
|
||||||
|
|
||||||
|
import com.qiniu.http.Response;
|
||||||
|
import com.qiniu.sms.SmsManager;
|
||||||
|
import com.qiniu.util.Auth;
|
||||||
|
import net.maku.framework.common.exception.FastException;
|
||||||
|
import net.maku.message.sms.config.SmsConfig;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 七牛云短信
|
||||||
|
*
|
||||||
|
* @author 阿沐 babamu@126.com
|
||||||
|
*/
|
||||||
|
public class QiniuSmsStrategy implements SmsStrategy {
|
||||||
|
private final SmsConfig smsConfig;
|
||||||
|
private final SmsManager smsManager;
|
||||||
|
|
||||||
|
public QiniuSmsStrategy(SmsConfig smsConfig) {
|
||||||
|
this.smsConfig = smsConfig;
|
||||||
|
|
||||||
|
Auth auth = Auth.create(smsConfig.getAccessKey(), smsConfig.getSecretKey());
|
||||||
|
smsManager = new SmsManager(auth);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void send(String mobile, Map<String, String> params) {
|
||||||
|
try {
|
||||||
|
Response response = smsManager.sendSingleMessage(smsConfig.getTemplateId(), mobile, params);
|
||||||
|
|
||||||
|
// 是否发送成功
|
||||||
|
if (!response.isOK()) {
|
||||||
|
throw new FastException(response.error);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new FastException("短信发送失败:", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
6
pom.xml
6
pom.xml
|
@ -42,6 +42,7 @@
|
||||||
<aliyun.oss.version>3.8.0</aliyun.oss.version>
|
<aliyun.oss.version>3.8.0</aliyun.oss.version>
|
||||||
<aliyun.dysmsapi.version>2.0.18</aliyun.dysmsapi.version>
|
<aliyun.dysmsapi.version>2.0.18</aliyun.dysmsapi.version>
|
||||||
<tencentcloud.sdk.version>3.1.574</tencentcloud.sdk.version>
|
<tencentcloud.sdk.version>3.1.574</tencentcloud.sdk.version>
|
||||||
|
<qiniu.version>7.11.0</qiniu.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -131,6 +132,11 @@
|
||||||
<artifactId>tencentcloud-sdk-java</artifactId>
|
<artifactId>tencentcloud-sdk-java</artifactId>
|
||||||
<version>${tencentcloud.sdk.version}</version>
|
<version>${tencentcloud.sdk.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.qiniu</groupId>
|
||||||
|
<artifactId>qiniu-java-sdk</artifactId>
|
||||||
|
<version>${qiniu.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user