diff --git a/fast-boot-module/fast-boot-message/pom.xml b/fast-boot-module/fast-boot-message/pom.xml index 0f4aef8..de65482 100644 --- a/fast-boot-module/fast-boot-message/pom.xml +++ b/fast-boot-module/fast-boot-message/pom.xml @@ -1,31 +1,36 @@ - - - net.maku - fast-boot-module - ${revision} - - 4.0.0 - fast-boot-message - jar + + + net.maku + fast-boot-module + ${revision} + + 4.0.0 + fast-boot-message + jar - - - net.maku - fast-framework - ${revision} - - - com.aliyun - dysmsapi20170525 - - - com.squareup.okhttp3 - okhttp - - - com.tencentcloudapi - tencentcloud-sdk-java - - + + + net.maku + fast-framework + ${revision} + + + com.aliyun + dysmsapi20170525 + + + com.squareup.okhttp3 + okhttp + + + com.tencentcloudapi + tencentcloud-sdk-java + + + com.qiniu + qiniu-java-sdk + + \ No newline at end of file diff --git a/fast-boot-module/fast-boot-message/src/main/java/net/maku/message/sms/QiniuSmsStrategy.java b/fast-boot-module/fast-boot-message/src/main/java/net/maku/message/sms/QiniuSmsStrategy.java new file mode 100644 index 0000000..736fdc6 --- /dev/null +++ b/fast-boot-module/fast-boot-message/src/main/java/net/maku/message/sms/QiniuSmsStrategy.java @@ -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 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); + } + } +} diff --git a/pom.xml b/pom.xml index 1268caa..51d00f6 100644 --- a/pom.xml +++ b/pom.xml @@ -17,11 +17,11 @@ - fast-boot-new - fast-boot-system - fast-boot-module - fast-boot-api - fast-framework + fast-boot-new + fast-boot-system + fast-boot-module + fast-boot-api + fast-framework fast-server @@ -42,6 +42,7 @@ 3.8.0 2.0.18 3.1.574 + 7.11.0 @@ -131,6 +132,11 @@ tencentcloud-sdk-java ${tencentcloud.sdk.version} + + com.qiniu + qiniu-java-sdk + ${qiniu.version} +