新增七牛云短信平台
This commit is contained in:
parent
cc5f8cd58d
commit
0b580d2fe2
|
@ -1,31 +1,36 @@
|
||||||
<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"
|
||||||
<parent>
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<groupId>net.maku</groupId>
|
<parent>
|
||||||
<artifactId>fast-boot-module</artifactId>
|
<groupId>net.maku</groupId>
|
||||||
<version>${revision}</version>
|
<artifactId>fast-boot-module</artifactId>
|
||||||
</parent>
|
<version>${revision}</version>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
</parent>
|
||||||
<artifactId>fast-boot-message</artifactId>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<packaging>jar</packaging>
|
<artifactId>fast-boot-message</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.maku</groupId>
|
<groupId>net.maku</groupId>
|
||||||
<artifactId>fast-framework</artifactId>
|
<artifactId>fast-framework</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.aliyun</groupId>
|
<groupId>com.aliyun</groupId>
|
||||||
<artifactId>dysmsapi20170525</artifactId>
|
<artifactId>dysmsapi20170525</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.squareup.okhttp3</groupId>
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
<artifactId>okhttp</artifactId>
|
<artifactId>okhttp</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tencentcloudapi</groupId>
|
<groupId>com.tencentcloudapi</groupId>
|
||||||
<artifactId>tencentcloud-sdk-java</artifactId>
|
<artifactId>tencentcloud-sdk-java</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
<dependency>
|
||||||
|
<groupId>com.qiniu</groupId>
|
||||||
|
<artifactId>qiniu-java-sdk</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
16
pom.xml
16
pom.xml
|
@ -17,11 +17,11 @@
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>fast-boot-new</module>
|
<module>fast-boot-new</module>
|
||||||
<module>fast-boot-system</module>
|
<module>fast-boot-system</module>
|
||||||
<module>fast-boot-module</module>
|
<module>fast-boot-module</module>
|
||||||
<module>fast-boot-api</module>
|
<module>fast-boot-api</module>
|
||||||
<module>fast-framework</module>
|
<module>fast-framework</module>
|
||||||
<module>fast-server</module>
|
<module>fast-server</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
@ -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