mirror of
https://gitee.com/dromara/sms4j.git
synced 2025-12-06 17:08:40 +08:00
!7 新增容联云国内短信接入
Merge pull request !7 from Charles7c/Feat_cloopen 贡献者:Charles7c
This commit is contained in:
commit
ed0114d9a4
@ -35,6 +35,7 @@
|
|||||||
<module>sms-aggregation-yunpian</module>
|
<module>sms-aggregation-yunpian</module>
|
||||||
<module>sms-aggregation-huawei</module>
|
<module>sms-aggregation-huawei</module>
|
||||||
<module>sms-aggregation-jdcloud</module>
|
<module>sms-aggregation-jdcloud</module>
|
||||||
|
<module>sms-aggregation-cloopen</module>
|
||||||
</modules>
|
</modules>
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:git:https://gitee.com/MR-wind/sms_aggregation.git</connection>
|
<connection>scm:git:https://gitee.com/MR-wind/sms_aggregation.git</connection>
|
||||||
@ -55,6 +56,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<unisms.version>0.0.4</unisms.version>
|
<unisms.version>0.0.4</unisms.version>
|
||||||
<okhttp.version>3.14.9</okhttp.version>
|
<okhttp.version>3.14.9</okhttp.version>
|
||||||
|
<cloopen.version>1.0.4</cloopen.version>
|
||||||
<aliyun.version>2.0.23</aliyun.version>
|
<aliyun.version>2.0.23</aliyun.version>
|
||||||
<json.version>2.0.15</json.version>
|
<json.version>2.0.15</json.version>
|
||||||
<forest.version>1.5.30</forest.version>
|
<forest.version>1.5.30</forest.version>
|
||||||
@ -133,6 +135,11 @@
|
|||||||
<artifactId>sms-aggregation-jdcloud</artifactId>
|
<artifactId>sms-aggregation-jdcloud</artifactId>
|
||||||
<version>1.0.5</version>
|
<version>1.0.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>kim.wind</groupId>
|
||||||
|
<artifactId>sms-aggregation-cloopen</artifactId>
|
||||||
|
<version>1.0.5</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.aliyun</groupId>
|
<groupId>com.aliyun</groupId>
|
||||||
<artifactId>dysmsapi20170525</artifactId>
|
<artifactId>dysmsapi20170525</artifactId>
|
||||||
@ -192,6 +199,11 @@
|
|||||||
<artifactId>sms</artifactId>
|
<artifactId>sms</artifactId>
|
||||||
<version>${jdcloud.version}</version>
|
<version>${jdcloud.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.cloopen</groupId>
|
||||||
|
<artifactId>java-sms-sdk</artifactId>
|
||||||
|
<version>${cloopen.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.squareup.okhttp3</groupId>
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
<artifactId>okhttp</artifactId>
|
<artifactId>okhttp</artifactId>
|
||||||
|
|||||||
15
pom.xml
15
pom.xml
@ -22,6 +22,7 @@
|
|||||||
<module>sms-aggregation-yunpian</module>
|
<module>sms-aggregation-yunpian</module>
|
||||||
<module>sms-aggregation-huawei</module>
|
<module>sms-aggregation-huawei</module>
|
||||||
<module>sms-aggregation-jdcloud</module>
|
<module>sms-aggregation-jdcloud</module>
|
||||||
|
<module>sms-aggregation-cloopen</module>
|
||||||
</modules>
|
</modules>
|
||||||
<!-- 开源协议 apache 2.0 -->
|
<!-- 开源协议 apache 2.0 -->
|
||||||
<licenses>
|
<licenses>
|
||||||
@ -57,6 +58,7 @@
|
|||||||
<tencent.version>3.1.622</tencent.version>
|
<tencent.version>3.1.622</tencent.version>
|
||||||
<unisms.version>0.0.4</unisms.version>
|
<unisms.version>0.0.4</unisms.version>
|
||||||
<jdcloud.version>1.3.3</jdcloud.version>
|
<jdcloud.version>1.3.3</jdcloud.version>
|
||||||
|
<cloopen.version>1.0.4</cloopen.version>
|
||||||
<json.version>2.0.15</json.version>
|
<json.version>2.0.15</json.version>
|
||||||
<okhttp.version>3.14.9</okhttp.version>
|
<okhttp.version>3.14.9</okhttp.version>
|
||||||
<forest.version>1.5.30</forest.version>
|
<forest.version>1.5.30</forest.version>
|
||||||
@ -149,6 +151,12 @@
|
|||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>kim.wind</groupId>
|
||||||
|
<artifactId>sms-aggregation-cloopen</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- 阿里云短信依赖-->
|
<!-- 阿里云短信依赖-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.aliyun</groupId>
|
<groupId>com.aliyun</groupId>
|
||||||
@ -224,6 +232,13 @@
|
|||||||
<version>${jdcloud.version}</version>
|
<version>${jdcloud.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 容联云短信依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.cloopen</groupId>
|
||||||
|
<artifactId>java-sms-sdk</artifactId>
|
||||||
|
<version>${cloopen.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- okhttp依赖,防止出现java.lang.NoSuchFieldError: Companion异常-->
|
<!-- okhttp依赖,防止出现java.lang.NoSuchFieldError: Companion异常-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.squareup.okhttp3</groupId>
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package org.dromara.sms.autoimmit.config;
|
package org.dromara.sms.autoimmit.config;
|
||||||
|
|
||||||
import org.dromara.sms.aliyun.config.AlibabaConfig;
|
import org.dromara.sms.aliyun.config.AlibabaConfig;
|
||||||
|
import org.dromara.sms.cloopen.config.CloopenConfig;
|
||||||
import org.dromara.sms.core.config.SupplierFactory;
|
import org.dromara.sms.core.config.SupplierFactory;
|
||||||
import org.dromara.sms.huawei.config.HuaweiConfig;
|
import org.dromara.sms.huawei.config.HuaweiConfig;
|
||||||
import org.dromara.sms.jdcloud.config.JdCloudConfig;
|
import org.dromara.sms.jdcloud.config.JdCloudConfig;
|
||||||
@ -53,6 +54,13 @@ public class SupplierConfig {
|
|||||||
return SupplierFactory.getJdCloudConfig();
|
return SupplierFactory.getJdCloudConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 容联云短信差异化配置 */
|
||||||
|
@Bean
|
||||||
|
@ConfigurationProperties(prefix = "sms.cloopen")
|
||||||
|
protected CloopenConfig cloopenConfig(){
|
||||||
|
return SupplierFactory.getCloopenConfig();
|
||||||
|
}
|
||||||
|
|
||||||
/** 为的是延后执行*/
|
/** 为的是延后执行*/
|
||||||
protected void init(){
|
protected void init(){
|
||||||
|
|
||||||
|
|||||||
37
sms-aggregation-cloopen/.flattened-pom.xml
Normal file
37
sms-aggregation-cloopen/.flattened-pom.xml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>kim.wind</groupId>
|
||||||
|
<artifactId>sms_aggregation</artifactId>
|
||||||
|
<version>1.0.5</version>
|
||||||
|
</parent>
|
||||||
|
<groupId>kim.wind</groupId>
|
||||||
|
<artifactId>sms-aggregation-cloopen</artifactId>
|
||||||
|
<version>1.0.5</version>
|
||||||
|
<name>sms-aggregation-cloopen</name>
|
||||||
|
<description>sms-aggregation-cloopen</description>
|
||||||
|
<licenses>
|
||||||
|
<license>
|
||||||
|
<name>Apache 2</name>
|
||||||
|
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||||
|
<distribution>repo</distribution>
|
||||||
|
<comments>A business-friendly OSS license</comments>
|
||||||
|
</license>
|
||||||
|
</licenses>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.cloopen</groupId>
|
||||||
|
<artifactId>java-sms-sdk</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>kim.wind</groupId>
|
||||||
|
<artifactId>sms-aggregation-comm</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>kim.wind</groupId>
|
||||||
|
<artifactId>sms-aggregation-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
BIN
sms-aggregation-cloopen/.mvn/wrapper/maven-wrapper.jar
vendored
Normal file
BIN
sms-aggregation-cloopen/.mvn/wrapper/maven-wrapper.jar
vendored
Normal file
Binary file not shown.
18
sms-aggregation-cloopen/.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
18
sms-aggregation-cloopen/.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
# or more contributor license agreements. See the NOTICE file
|
||||||
|
# distributed with this work for additional information
|
||||||
|
# regarding copyright ownership. The ASF licenses this file
|
||||||
|
# to you under the Apache License, Version 2.0 (the
|
||||||
|
# "License"); you may not use this file except in compliance
|
||||||
|
# with the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing,
|
||||||
|
# software distributed under the License is distributed on an
|
||||||
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
# KIND, either express or implied. See the License for the
|
||||||
|
# specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip
|
||||||
|
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
|
||||||
35
sms-aggregation-cloopen/pom.xml
Normal file
35
sms-aggregation-cloopen/pom.xml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?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">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>kim.wind</groupId>
|
||||||
|
<artifactId>sms_aggregation</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>sms-aggregation-cloopen</artifactId>
|
||||||
|
<name>sms-aggregation-cloopen</name>
|
||||||
|
<description>sms-aggregation-cloopen</description>
|
||||||
|
<version>${revision}</version>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- 容联云短信依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.cloopen</groupId>
|
||||||
|
<artifactId>java-sms-sdk</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>kim.wind</groupId>
|
||||||
|
<artifactId>sms-aggregation-comm</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>kim.wind</groupId>
|
||||||
|
<artifactId>sms-aggregation-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
package org.dromara.sms.cloopen.config;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 容联云短信配置属性
|
||||||
|
*
|
||||||
|
* @author Charles7c
|
||||||
|
* @since 2023/4/10 22:10
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CloopenConfig {
|
||||||
|
|
||||||
|
/** Access Key */
|
||||||
|
private String accessKeyId;
|
||||||
|
|
||||||
|
/** Access Key Secret */
|
||||||
|
private String accessKeySecret;
|
||||||
|
|
||||||
|
/** 模板 ID */
|
||||||
|
private String templateId;
|
||||||
|
|
||||||
|
/** 应用 ID */
|
||||||
|
private String appId;
|
||||||
|
|
||||||
|
/** Rest URL 域名 */
|
||||||
|
private String serverIp;
|
||||||
|
|
||||||
|
/** Rest URL 端口 */
|
||||||
|
private String serverPort;
|
||||||
|
}
|
||||||
@ -0,0 +1,68 @@
|
|||||||
|
package org.dromara.sms.cloopen.config;
|
||||||
|
|
||||||
|
import com.cloopen.rest.sdk.BodyType;
|
||||||
|
import com.cloopen.rest.sdk.CCPRestSmsSDK;
|
||||||
|
import org.dromara.sms.cloopen.service.CloopenSmsImpl;
|
||||||
|
import org.dromara.sms.comm.factory.BeanFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 容联云短信配置
|
||||||
|
*
|
||||||
|
* @author Charles7c
|
||||||
|
* @since 2023/4/10 22:10
|
||||||
|
*/
|
||||||
|
public class CloopenSmsConfig {
|
||||||
|
|
||||||
|
private static CloopenSmsImpl cloopenSms;
|
||||||
|
|
||||||
|
private static CloopenSmsConfig cloopenSmsConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户端对象
|
||||||
|
*
|
||||||
|
* @param cloopenConfig 容联云短信配置属性
|
||||||
|
* @return 客户端对象
|
||||||
|
*/
|
||||||
|
public CCPRestSmsSDK client(CloopenConfig cloopenConfig) {
|
||||||
|
CCPRestSmsSDK sdk = new CCPRestSmsSDK();
|
||||||
|
sdk.init(cloopenConfig.getServerIp(), cloopenConfig.getServerPort());
|
||||||
|
sdk.setAccount(cloopenConfig.getAccessKeyId(), cloopenConfig.getAccessKeySecret());
|
||||||
|
sdk.setAppId(cloopenConfig.getAppId());
|
||||||
|
sdk.setBodyType(BodyType.Type_JSON);
|
||||||
|
return sdk;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建容联云短信实现
|
||||||
|
*/
|
||||||
|
public static CloopenSmsImpl createCloopenSms(CloopenConfig cloopenConfig) {
|
||||||
|
if (cloopenSmsConfig == null) {
|
||||||
|
cloopenSmsConfig = new CloopenSmsConfig();
|
||||||
|
}
|
||||||
|
if (cloopenSms == null) {
|
||||||
|
cloopenSms = new CloopenSmsImpl(
|
||||||
|
cloopenSmsConfig.client(cloopenConfig),
|
||||||
|
cloopenConfig,
|
||||||
|
BeanFactory.getExecutor(),
|
||||||
|
BeanFactory.getDelayedTime()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return cloopenSms;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 刷新对象
|
||||||
|
*/
|
||||||
|
public static CloopenSmsImpl refresh(CloopenConfig cloopenConfig) {
|
||||||
|
if (cloopenSmsConfig == null) {
|
||||||
|
cloopenSmsConfig = new CloopenSmsConfig();
|
||||||
|
}
|
||||||
|
cloopenSms = new CloopenSmsImpl(
|
||||||
|
cloopenSmsConfig.client(cloopenConfig),
|
||||||
|
cloopenConfig,
|
||||||
|
BeanFactory.getExecutor(),
|
||||||
|
BeanFactory.getDelayedTime()
|
||||||
|
);
|
||||||
|
return cloopenSms;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,169 @@
|
|||||||
|
package org.dromara.sms.cloopen.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.cloopen.rest.sdk.CCPRestSmsSDK;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.dromara.sms.api.SmsBlend;
|
||||||
|
import org.dromara.sms.api.callback.CallBack;
|
||||||
|
import org.dromara.sms.api.entity.SmsResponse;
|
||||||
|
import org.dromara.sms.cloopen.config.CloopenConfig;
|
||||||
|
import org.dromara.sms.comm.annotation.Restricted;
|
||||||
|
import org.dromara.sms.comm.delayedTime.DelayedTime;
|
||||||
|
import org.dromara.sms.comm.exception.SmsBlendException;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 容联云短信实现
|
||||||
|
*
|
||||||
|
* @author Charles7c
|
||||||
|
* @since 2023/4/10 22:10
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class CloopenSmsImpl implements SmsBlend {
|
||||||
|
|
||||||
|
private final CCPRestSmsSDK client;
|
||||||
|
|
||||||
|
private final CloopenConfig config;
|
||||||
|
|
||||||
|
private final Executor pool;
|
||||||
|
|
||||||
|
private final DelayedTime delayed;
|
||||||
|
|
||||||
|
public CloopenSmsImpl(CCPRestSmsSDK client, CloopenConfig config, Executor pool, DelayedTime delayed) {
|
||||||
|
this.client = client;
|
||||||
|
this.config = config;
|
||||||
|
this.pool = pool;
|
||||||
|
this.delayed = delayed;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Restricted
|
||||||
|
public SmsResponse sendMessage(String phone, String message) {
|
||||||
|
return massTexting(Collections.singletonList(phone), message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Restricted
|
||||||
|
public SmsResponse sendMessage(String phone, String templateId, LinkedHashMap<String, String> messages) {
|
||||||
|
return massTexting(Collections.singletonList(phone), templateId, messages);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Restricted
|
||||||
|
public SmsResponse massTexting(List<String> phones, String message) {
|
||||||
|
LinkedHashMap<String, String> map = new LinkedHashMap<>();
|
||||||
|
map.put(IdUtil.fastSimpleUUID(), message);
|
||||||
|
return massTexting(phones, config.getTemplateId(), map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Restricted
|
||||||
|
public SmsResponse massTexting(List<String> phones, String templateId, LinkedHashMap<String, String> messages) {
|
||||||
|
SmsResponse smsResponse = new SmsResponse();
|
||||||
|
Map<String, Object> result = null;
|
||||||
|
try {
|
||||||
|
String[] datas = messages.keySet().stream().map(messages::get).toArray(String[]::new);
|
||||||
|
result = client.sendTemplateSMS(String.join(",", phones), templateId, datas);
|
||||||
|
|
||||||
|
String statusCode = Convert.toStr(result.get("statusCode"));
|
||||||
|
String statusMsg = Convert.toStr(result.get("statusMsg"));
|
||||||
|
smsResponse.setData(result.get("data"));
|
||||||
|
smsResponse.setCode(statusCode);
|
||||||
|
smsResponse.setMessage(statusMsg);
|
||||||
|
boolean isSuccess = "000000".equals(statusCode);
|
||||||
|
if (!isSuccess) {
|
||||||
|
smsResponse.setErrMessage(statusMsg);
|
||||||
|
smsResponse.setErrorCode(statusCode);
|
||||||
|
} else {
|
||||||
|
Object bizId = JSONUtil.getByPath(JSONUtil.parse(result.get("data")), "templateSMS.smsMessageSid");
|
||||||
|
smsResponse.setBizId(Convert.toStr(bizId));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (result != null) {
|
||||||
|
smsResponse.setErrMessage(Convert.toStr(result.get("statusMsg")));
|
||||||
|
smsResponse.setErrorCode(Convert.toStr(result.get("statusCode")));
|
||||||
|
} else {
|
||||||
|
throw new SmsBlendException(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return smsResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Restricted
|
||||||
|
public void sendMessageAsync(String phone, String message, CallBack callBack) {
|
||||||
|
pool.execute(() -> {
|
||||||
|
SmsResponse smsResponse = sendMessage(phone, message);
|
||||||
|
callBack.callBack(smsResponse);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Restricted
|
||||||
|
public void sendMessageAsync(String phone, String message) {
|
||||||
|
pool.execute(() -> sendMessage(phone, message));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Restricted
|
||||||
|
public void sendMessageAsync(String phone, String templateId, LinkedHashMap<String, String> messages, CallBack callBack) {
|
||||||
|
pool.execute(() -> {
|
||||||
|
SmsResponse smsResponse = sendMessage(phone, templateId, messages);
|
||||||
|
callBack.callBack(smsResponse);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Restricted
|
||||||
|
public void sendMessageAsync(String phone, String templateId, LinkedHashMap<String, String> messages) {
|
||||||
|
pool.execute(() -> sendMessage(phone, templateId, messages));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Restricted
|
||||||
|
public void delayedMessage(String phone, String message, Long delayedTime) {
|
||||||
|
this.delayed.schedule(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
sendMessage(phone, message);
|
||||||
|
}
|
||||||
|
}, delayedTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Restricted
|
||||||
|
public void delayedMessage(String phone, String templateId, LinkedHashMap<String, String> messages, Long delayedTime) {
|
||||||
|
this.delayed.schedule(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
sendMessage(phone, templateId, messages);
|
||||||
|
}
|
||||||
|
}, delayedTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Restricted
|
||||||
|
public void delayMassTexting(List<String> phones, String message, Long delayedTime) {
|
||||||
|
this.delayed.schedule(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
massTexting(phones, message);
|
||||||
|
}
|
||||||
|
}, delayedTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Restricted
|
||||||
|
public void delayMassTexting(List<String> phones, String templateId, LinkedHashMap<String, String> messages, Long delayedTime) {
|
||||||
|
this.delayed.schedule(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
massTexting(phones, templateId, messages);
|
||||||
|
}
|
||||||
|
}, delayedTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
|
||||||
@ -19,6 +19,8 @@ public enum SupplierType {
|
|||||||
UNI_SMS("合一短信"),
|
UNI_SMS("合一短信"),
|
||||||
/** 京东云 */
|
/** 京东云 */
|
||||||
JD_CLOUD("京东云短信"),
|
JD_CLOUD("京东云短信"),
|
||||||
|
/** 容联云 */
|
||||||
|
CLOOPEN("容联云短信"),
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -45,6 +45,10 @@
|
|||||||
<groupId>kim.wind</groupId>
|
<groupId>kim.wind</groupId>
|
||||||
<artifactId>sms-aggregation-jdcloud</artifactId>
|
<artifactId>sms-aggregation-jdcloud</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>kim.wind</groupId>
|
||||||
|
<artifactId>sms-aggregation-cloopen</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build />
|
<build />
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@ -45,6 +45,11 @@
|
|||||||
<groupId>kim.wind</groupId>
|
<groupId>kim.wind</groupId>
|
||||||
<artifactId>sms-aggregation-jdcloud</artifactId>
|
<artifactId>sms-aggregation-jdcloud</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>kim.wind</groupId>
|
||||||
|
<artifactId>sms-aggregation-cloopen</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package org.dromara.sms.core.config;
|
package org.dromara.sms.core.config;
|
||||||
|
|
||||||
import org.dromara.sms.aliyun.config.AlibabaConfig;
|
import org.dromara.sms.aliyun.config.AlibabaConfig;
|
||||||
|
import org.dromara.sms.cloopen.config.CloopenConfig;
|
||||||
import org.dromara.sms.huawei.config.HuaweiConfig;
|
import org.dromara.sms.huawei.config.HuaweiConfig;
|
||||||
import org.dromara.sms.jdcloud.config.JdCloudConfig;
|
import org.dromara.sms.jdcloud.config.JdCloudConfig;
|
||||||
import org.dromara.sms.tencent.config.TencentConfig;
|
import org.dromara.sms.tencent.config.TencentConfig;
|
||||||
@ -35,6 +36,9 @@ public class SupplierFactory {
|
|||||||
/** 京东云短信差异配置 */
|
/** 京东云短信差异配置 */
|
||||||
private static JdCloudConfig jdCloudConfig;
|
private static JdCloudConfig jdCloudConfig;
|
||||||
|
|
||||||
|
/** 容联云短信差异配置 */
|
||||||
|
private static CloopenConfig cloopenConfig;
|
||||||
|
|
||||||
/** 阿里云配置获取*/
|
/** 阿里云配置获取*/
|
||||||
public static AlibabaConfig getAlibabaConfig() {
|
public static AlibabaConfig getAlibabaConfig() {
|
||||||
if (alibabaConfig == null){
|
if (alibabaConfig == null){
|
||||||
@ -82,4 +86,12 @@ public class SupplierFactory {
|
|||||||
}
|
}
|
||||||
return jdCloudConfig;
|
return jdCloudConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 容联云短信配置获取 */
|
||||||
|
public static CloopenConfig getCloopenConfig() {
|
||||||
|
if (cloopenConfig == null){
|
||||||
|
cloopenConfig = new CloopenConfig();
|
||||||
|
}
|
||||||
|
return cloopenConfig;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package org.dromara.sms.core.factory;
|
|||||||
|
|
||||||
import org.dromara.sms.aliyun.config.AlibabaSmsConfig;
|
import org.dromara.sms.aliyun.config.AlibabaSmsConfig;
|
||||||
import org.dromara.sms.api.SmsBlend;
|
import org.dromara.sms.api.SmsBlend;
|
||||||
|
import org.dromara.sms.cloopen.config.CloopenSmsConfig;
|
||||||
import org.dromara.sms.comm.enumerate.SupplierType;
|
import org.dromara.sms.comm.enumerate.SupplierType;
|
||||||
import org.dromara.sms.comm.exception.SmsBlendException;
|
import org.dromara.sms.comm.exception.SmsBlendException;
|
||||||
import org.dromara.sms.core.config.SupplierFactory;
|
import org.dromara.sms.core.config.SupplierFactory;
|
||||||
@ -37,6 +38,8 @@ public class SmsFactory {
|
|||||||
return TencentSmsConfig.createTencentSms(SupplierFactory.getTencentConfig());
|
return TencentSmsConfig.createTencentSms(SupplierFactory.getTencentConfig());
|
||||||
case JD_CLOUD:
|
case JD_CLOUD:
|
||||||
return JdCloudSmsConfig.createJdCloudSms(SupplierFactory.getJdCloudConfig());
|
return JdCloudSmsConfig.createJdCloudSms(SupplierFactory.getJdCloudConfig());
|
||||||
|
case CLOOPEN:
|
||||||
|
return CloopenSmsConfig.createCloopenSms(SupplierFactory.getCloopenConfig());
|
||||||
}
|
}
|
||||||
throw new SmsBlendException("An attempt to construct a SmsBlend object failed. Please check that the enumeration is valid");
|
throw new SmsBlendException("An attempt to construct a SmsBlend object failed. Please check that the enumeration is valid");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -73,7 +73,7 @@ public class JdCloudSmsImpl implements SmsBlend {
|
|||||||
request.setRegionId(config.getRegion());
|
request.setRegionId(config.getRegion());
|
||||||
request.setTemplateId(templateId);
|
request.setTemplateId(templateId);
|
||||||
request.setSignId(config.getSignature());
|
request.setSignId(config.getSignature());
|
||||||
List<String> params = messages.entrySet().stream().map(messages::get)
|
List<String> params = messages.keySet().stream().map(messages::get)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
request.setParams(params);
|
request.setParams(params);
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,7 @@ public class YunPianSmsConfig {
|
|||||||
|
|
||||||
|
|
||||||
public ForestConfiguration forestConfiguration(YunpianConfig yunpianConfig) {
|
public ForestConfiguration forestConfiguration(YunpianConfig yunpianConfig) {
|
||||||
return Forest.config().setBackendName("httpclient").setLogEnabled(yunpianConfig.getHttpLog());
|
return Forest.config().setBackendName("httpclient");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user