mirror of
https://gitee.com/dromara/sms4j.git
synced 2025-12-06 17:08:40 +08:00
Merge remote-tracking branch 'origin/dev-2.x' into dev-test
This commit is contained in:
commit
d5fa888919
@ -57,7 +57,6 @@
|
|||||||
<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>
|
||||||
@ -152,8 +151,8 @@
|
|||||||
<version>${aliyun.version}</version>
|
<version>${aliyun.version}</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>com.squareup.okhttp3</groupId>
|
|
||||||
<artifactId>okhttp</artifactId>
|
<artifactId>okhttp</artifactId>
|
||||||
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -184,8 +183,8 @@
|
|||||||
<version>${unisms.version}</version>
|
<version>${unisms.version}</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>com.squareup.okhttp3</groupId>
|
|
||||||
<artifactId>okhttp</artifactId>
|
<artifactId>okhttp</artifactId>
|
||||||
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -195,8 +194,8 @@
|
|||||||
<version>${tencent.version}</version>
|
<version>${tencent.version}</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>com.squareup.okhttp3</groupId>
|
|
||||||
<artifactId>okhttp</artifactId>
|
<artifactId>okhttp</artifactId>
|
||||||
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -205,11 +204,6 @@
|
|||||||
<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>
|
||||||
|
|||||||
BIN
.mvn/wrapper/maven-wrapper.jar
vendored
BIN
.mvn/wrapper/maven-wrapper.jar
vendored
Binary file not shown.
18
.mvn/wrapper/maven-wrapper.properties
vendored
18
.mvn/wrapper/maven-wrapper.properties
vendored
@ -1,18 +0,0 @@
|
|||||||
# 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
|
|
||||||
8
pom.xml
8
pom.xml
@ -60,7 +60,6 @@
|
|||||||
<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>
|
||||||
@ -240,13 +239,6 @@
|
|||||||
<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>
|
||||||
|
|||||||
@ -26,15 +26,11 @@
|
|||||||
<artifactId>dysmsapi20170525</artifactId>
|
<artifactId>dysmsapi20170525</artifactId>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>com.squareup.okhttp3</groupId>
|
|
||||||
<artifactId>okhttp</artifactId>
|
<artifactId>okhttp</artifactId>
|
||||||
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.squareup.okhttp3</groupId>
|
|
||||||
<artifactId>okhttp</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.dromara.sms4j</groupId>
|
<groupId>org.dromara.sms4j</groupId>
|
||||||
<artifactId>sms4j-comm</artifactId>
|
<artifactId>sms4j-comm</artifactId>
|
||||||
|
|||||||
BIN
sms4j-aliyun/.mvn/wrapper/maven-wrapper.jar
vendored
BIN
sms4j-aliyun/.mvn/wrapper/maven-wrapper.jar
vendored
Binary file not shown.
@ -1,18 +0,0 @@
|
|||||||
# 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
|
|
||||||
@ -30,11 +30,6 @@
|
|||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.squareup.okhttp3</groupId>
|
|
||||||
<artifactId>okhttp</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.dromara.sms4j</groupId>
|
<groupId>org.dromara.sms4j</groupId>
|
||||||
<artifactId>sms4j-comm</artifactId>
|
<artifactId>sms4j-comm</artifactId>
|
||||||
|
|||||||
BIN
sms4j-api/.mvn/wrapper/maven-wrapper.jar
vendored
BIN
sms4j-api/.mvn/wrapper/maven-wrapper.jar
vendored
Binary file not shown.
18
sms4j-api/.mvn/wrapper/maven-wrapper.properties
vendored
18
sms4j-api/.mvn/wrapper/maven-wrapper.properties
vendored
@ -1,18 +0,0 @@
|
|||||||
# 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
|
|
||||||
BIN
sms4j-autoimmit/.mvn/wrapper/maven-wrapper.jar
vendored
BIN
sms4j-autoimmit/.mvn/wrapper/maven-wrapper.jar
vendored
Binary file not shown.
@ -1,18 +0,0 @@
|
|||||||
# 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
|
|
||||||
@ -21,10 +21,6 @@
|
|||||||
</license>
|
</license>
|
||||||
</licenses>
|
</licenses>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>com.cloopen</groupId>
|
|
||||||
<artifactId>java-sms-sdk</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.dromara.sms4j</groupId>
|
<groupId>org.dromara.sms4j</groupId>
|
||||||
<artifactId>sms4j-comm</artifactId>
|
<artifactId>sms4j-comm</artifactId>
|
||||||
|
|||||||
BIN
sms4j-cloopen/.mvn/wrapper/maven-wrapper.jar
vendored
BIN
sms4j-cloopen/.mvn/wrapper/maven-wrapper.jar
vendored
Binary file not shown.
@ -1,18 +0,0 @@
|
|||||||
# 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
|
|
||||||
@ -16,12 +16,6 @@
|
|||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- 容联云短信依赖 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.cloopen</groupId>
|
|
||||||
<artifactId>java-sms-sdk</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.dromara.sms4j</groupId>
|
<groupId>org.dromara.sms4j</groupId>
|
||||||
<artifactId>sms4j-comm</artifactId>
|
<artifactId>sms4j-comm</artifactId>
|
||||||
|
|||||||
@ -0,0 +1,32 @@
|
|||||||
|
package org.dromara.sms4j.cloopen.api;
|
||||||
|
|
||||||
|
import com.dtflys.forest.annotation.Address;
|
||||||
|
import com.dtflys.forest.annotation.BaseRequest;
|
||||||
|
import com.dtflys.forest.annotation.Body;
|
||||||
|
import com.dtflys.forest.annotation.PostRequest;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 容联云 REST API
|
||||||
|
*
|
||||||
|
* @author Charles7c
|
||||||
|
* @since 2023/4/17 20:57
|
||||||
|
*/
|
||||||
|
@Address(basePath = "{baseUrl}")
|
||||||
|
@BaseRequest(headers = {
|
||||||
|
"Accept: application/json",
|
||||||
|
"Content-Type: application/json;charset=utf-8",
|
||||||
|
"Authorization: {authorization}",
|
||||||
|
})
|
||||||
|
public interface CloopenRestApi {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送模板短信
|
||||||
|
*
|
||||||
|
* @param paramMap 请求参数
|
||||||
|
* @return 响应结果
|
||||||
|
*/
|
||||||
|
@PostRequest("/Accounts/{accessKeyId}/SMS/TemplateSMS?sig={sign}")
|
||||||
|
Map<String, Object> sendSms(@Body Map<String, Object> paramMap);
|
||||||
|
}
|
||||||
@ -13,21 +13,46 @@ import lombok.experimental.Accessors;
|
|||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
public class CloopenConfig {
|
public class CloopenConfig {
|
||||||
|
|
||||||
/** Access Key */
|
/**
|
||||||
|
* Access Key
|
||||||
|
*/
|
||||||
private String accessKeyId;
|
private String accessKeyId;
|
||||||
|
|
||||||
/** Access Key Secret */
|
/**
|
||||||
|
* Access Key Secret
|
||||||
|
*/
|
||||||
private String accessKeySecret;
|
private String accessKeySecret;
|
||||||
|
|
||||||
/** 模板 ID */
|
/**
|
||||||
|
* 模板 ID
|
||||||
|
*/
|
||||||
private String templateId;
|
private String templateId;
|
||||||
|
|
||||||
/** 应用 ID */
|
/**
|
||||||
|
* 应用 ID
|
||||||
|
*/
|
||||||
private String appId;
|
private String appId;
|
||||||
|
|
||||||
/** Rest URL 域名 */
|
/**
|
||||||
|
* REST API Base URL
|
||||||
|
*/
|
||||||
|
private String baseUrl = "https://app.cloopen.com:8883/2013-12-26";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rest URL 域名
|
||||||
|
*
|
||||||
|
* @deprecated v2.0.1
|
||||||
|
* @see baseUrl
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
private String serverIp;
|
private String serverIp;
|
||||||
|
|
||||||
/** Rest URL 端口 */
|
/**
|
||||||
|
* Rest URL 端口
|
||||||
|
*
|
||||||
|
* @deprecated v2.0.1
|
||||||
|
* @see baseUrl
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
private String serverPort;
|
private String serverPort;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
package org.dromara.sms4j.cloopen.config;
|
package org.dromara.sms4j.cloopen.config;
|
||||||
|
|
||||||
import com.cloopen.rest.sdk.BodyType;
|
import lombok.AccessLevel;
|
||||||
import com.cloopen.rest.sdk.CCPRestSmsSDK;
|
import lombok.NoArgsConstructor;
|
||||||
import org.dromara.sms4j.cloopen.service.CloopenSmsImpl;
|
import org.dromara.sms4j.cloopen.service.CloopenSmsImpl;
|
||||||
import org.dromara.sms4j.comm.factory.BeanFactory;
|
import org.dromara.sms4j.comm.factory.BeanFactory;
|
||||||
|
|
||||||
@ -11,27 +11,13 @@ import org.dromara.sms4j.comm.factory.BeanFactory;
|
|||||||
* @author Charles7c
|
* @author Charles7c
|
||||||
* @since 2023/4/10 22:10
|
* @since 2023/4/10 22:10
|
||||||
*/
|
*/
|
||||||
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
public class CloopenSmsConfig {
|
public class CloopenSmsConfig {
|
||||||
|
|
||||||
private static CloopenSmsImpl cloopenSms;
|
private static CloopenSmsImpl cloopenSms;
|
||||||
|
|
||||||
private static CloopenSmsConfig cloopenSmsConfig;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建容联云短信实现
|
* 创建容联云短信实现
|
||||||
*/
|
*/
|
||||||
@ -40,12 +26,7 @@ public class CloopenSmsConfig {
|
|||||||
cloopenSmsConfig = new CloopenSmsConfig();
|
cloopenSmsConfig = new CloopenSmsConfig();
|
||||||
}
|
}
|
||||||
if (cloopenSms == null) {
|
if (cloopenSms == null) {
|
||||||
cloopenSms = new CloopenSmsImpl(
|
cloopenSms = new CloopenSmsImpl(cloopenConfig, BeanFactory.getExecutor(), BeanFactory.getDelayedTime());
|
||||||
cloopenSmsConfig.client(cloopenConfig),
|
|
||||||
cloopenConfig,
|
|
||||||
BeanFactory.getExecutor(),
|
|
||||||
BeanFactory.getDelayedTime()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return cloopenSms;
|
return cloopenSms;
|
||||||
}
|
}
|
||||||
@ -57,12 +38,7 @@ public class CloopenSmsConfig {
|
|||||||
if (cloopenSmsConfig == null) {
|
if (cloopenSmsConfig == null) {
|
||||||
cloopenSmsConfig = new CloopenSmsConfig();
|
cloopenSmsConfig = new CloopenSmsConfig();
|
||||||
}
|
}
|
||||||
cloopenSms = new CloopenSmsImpl(
|
cloopenSms = new CloopenSmsImpl(cloopenConfig, BeanFactory.getExecutor(), BeanFactory.getDelayedTime());
|
||||||
cloopenSmsConfig.client(cloopenConfig),
|
|
||||||
cloopenConfig,
|
|
||||||
BeanFactory.getExecutor(),
|
|
||||||
BeanFactory.getDelayedTime()
|
|
||||||
);
|
|
||||||
return cloopenSms;
|
return cloopenSms;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
package org.dromara.sms4j.cloopen.service;
|
package org.dromara.sms4j.cloopen.service;
|
||||||
|
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import com.dtflys.forest.Forest;
|
||||||
import com.cloopen.rest.sdk.CCPRestSmsSDK;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.dromara.sms4j.api.SmsBlend;
|
import org.dromara.sms4j.api.SmsBlend;
|
||||||
import org.dromara.sms4j.api.callback.CallBack;
|
import org.dromara.sms4j.api.callback.CallBack;
|
||||||
import org.dromara.sms4j.api.entity.SmsResponse;
|
import org.dromara.sms4j.api.entity.SmsResponse;
|
||||||
|
import org.dromara.sms4j.cloopen.api.CloopenRestApi;
|
||||||
import org.dromara.sms4j.cloopen.config.CloopenConfig;
|
import org.dromara.sms4j.cloopen.config.CloopenConfig;
|
||||||
|
import org.dromara.sms4j.cloopen.util.CloopenHelper;
|
||||||
import org.dromara.sms4j.comm.annotation.Restricted;
|
import org.dromara.sms4j.comm.annotation.Restricted;
|
||||||
import org.dromara.sms4j.comm.delayedTime.DelayedTime;
|
import org.dromara.sms4j.comm.delayedTime.DelayedTime;
|
||||||
import org.dromara.sms4j.comm.exception.SmsBlendException;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
@ -25,7 +25,7 @@ import java.util.concurrent.Executor;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class CloopenSmsImpl implements SmsBlend {
|
public class CloopenSmsImpl implements SmsBlend {
|
||||||
|
|
||||||
private final CCPRestSmsSDK client;
|
private final CloopenRestApi cloopenRestApi;
|
||||||
|
|
||||||
private final CloopenConfig config;
|
private final CloopenConfig config;
|
||||||
|
|
||||||
@ -33,11 +33,11 @@ public class CloopenSmsImpl implements SmsBlend {
|
|||||||
|
|
||||||
private final DelayedTime delayed;
|
private final DelayedTime delayed;
|
||||||
|
|
||||||
public CloopenSmsImpl(CCPRestSmsSDK client, CloopenConfig config, Executor pool, DelayedTime delayed) {
|
public CloopenSmsImpl(CloopenConfig config, Executor pool, DelayedTime delayed) {
|
||||||
this.client = client;
|
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.pool = pool;
|
this.pool = pool;
|
||||||
this.delayed = delayed;
|
this.delayed = delayed;
|
||||||
|
cloopenRestApi = Forest.client(CloopenRestApi.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -63,34 +63,13 @@ public class CloopenSmsImpl implements SmsBlend {
|
|||||||
@Override
|
@Override
|
||||||
@Restricted
|
@Restricted
|
||||||
public SmsResponse massTexting(List<String> phones, String templateId, LinkedHashMap<String, String> messages) {
|
public SmsResponse massTexting(List<String> phones, String templateId, LinkedHashMap<String, String> messages) {
|
||||||
SmsResponse smsResponse = new SmsResponse();
|
CloopenHelper helper = new CloopenHelper(config);
|
||||||
Map<String, Object> result = null;
|
Map<String, Object> paramMap = MapUtil.newHashMap(4);
|
||||||
try {
|
paramMap.put("to", String.join(",", phones));
|
||||||
String[] datas = messages.keySet().stream().map(messages::get).toArray(String[]::new);
|
paramMap.put("appId", config.getAppId());
|
||||||
result = client.sendTemplateSMS(String.join(",", phones), templateId, datas);
|
paramMap.put("templateId", templateId);
|
||||||
|
paramMap.put("datas", messages.keySet().stream().map(messages::get).toArray(String[]::new));
|
||||||
String statusCode = Convert.toStr(result.get("statusCode"));
|
return helper.request(cloopenRestApi::sendSms, paramMap);
|
||||||
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
|
@Override
|
||||||
|
|||||||
@ -0,0 +1,112 @@
|
|||||||
|
package org.dromara.sms4j.cloopen.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.codec.Base64;
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.crypto.SecureUtil;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.dtflys.forest.Forest;
|
||||||
|
import com.dtflys.forest.config.ForestConfiguration;
|
||||||
|
import org.dromara.sms4j.api.entity.SmsResponse;
|
||||||
|
import org.dromara.sms4j.cloopen.config.CloopenConfig;
|
||||||
|
import org.dromara.sms4j.comm.exception.SmsBlendException;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 容联云 Helper
|
||||||
|
*
|
||||||
|
* @author Charles7c
|
||||||
|
* @since 2023/4/17 20:57
|
||||||
|
*/
|
||||||
|
public class CloopenHelper {
|
||||||
|
|
||||||
|
private final CloopenConfig cloopenConfig;
|
||||||
|
|
||||||
|
public CloopenHelper(CloopenConfig cloopenConfig) {
|
||||||
|
this.cloopenConfig = cloopenConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发起 REST 请求
|
||||||
|
*
|
||||||
|
* @param restApiFunction REST API 函数式接口
|
||||||
|
* @param paramMap 请求参数
|
||||||
|
* @param <R> 响应类型
|
||||||
|
* @return 响应信息
|
||||||
|
*/
|
||||||
|
public <R> SmsResponse request(CloopenRestApiFunction<Map<String, Object>, R> restApiFunction, Map<String, Object> paramMap) {
|
||||||
|
SmsResponse smsResponse = new SmsResponse();
|
||||||
|
try {
|
||||||
|
String timestamp = DateUtil.format(new Date(), DatePattern.PURE_DATETIME_PATTERN);
|
||||||
|
// 设置全局变量
|
||||||
|
ForestConfiguration forestConfiguration = Forest.config();
|
||||||
|
forestConfiguration.setVariableValue("baseUrl", (method) -> cloopenConfig.getBaseUrl());
|
||||||
|
forestConfiguration.setVariableValue("accessKeyId", (method) -> cloopenConfig.getAccessKeyId());
|
||||||
|
forestConfiguration.setVariableValue("sign", this.generateSign(cloopenConfig.getAccessKeyId(), cloopenConfig.getAccessKeySecret(), timestamp));
|
||||||
|
forestConfiguration.setVariableValue("authorization", this.generateAuthorization(cloopenConfig.getAccessKeyId(), timestamp));
|
||||||
|
|
||||||
|
// 调用请求
|
||||||
|
R response = restApiFunction.apply(paramMap);
|
||||||
|
|
||||||
|
// 解析结果
|
||||||
|
Map<String, Object> responseMap = Optional.ofNullable(response)
|
||||||
|
.map(JSONUtil::parseObj)
|
||||||
|
.map(obj -> (Map<String, Object>) obj)
|
||||||
|
.orElse(Collections.emptyMap());
|
||||||
|
String statusCode = Convert.toStr(responseMap.get("statusCode"));
|
||||||
|
String statusMsg = Convert.toStr(responseMap.get("statusMsg"));
|
||||||
|
boolean isSuccess = "000000".equals(statusCode);
|
||||||
|
if (isSuccess) {
|
||||||
|
smsResponse.setCode(statusCode);
|
||||||
|
smsResponse.setMessage(statusMsg);
|
||||||
|
smsResponse.setData(response);
|
||||||
|
Object bizId = JSONUtil.getByPath(JSONUtil.parse(responseMap), "templateSMS.smsMessageSid");
|
||||||
|
smsResponse.setBizId(Convert.toStr(bizId));
|
||||||
|
} else {
|
||||||
|
smsResponse.setErrMessage(statusMsg);
|
||||||
|
smsResponse.setErrorCode(statusCode);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new SmsBlendException(e.getMessage());
|
||||||
|
}
|
||||||
|
return smsResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成签名
|
||||||
|
* <p>
|
||||||
|
* 1.使用 MD5 加密(账户 Id + 账户授权令牌 + 时间戳)。其中账户 Id 和账户授权令牌根据 url 的验证级别对应主账户。<br>
|
||||||
|
* 时间戳是当前系统时间,格式 "yyyyMMddHHmmss"。时间戳有效时间为 24 小时,如:20140416142030 <br>
|
||||||
|
* 2.参数需要大写
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param accessKeyId /
|
||||||
|
* @param accessKeySecret /
|
||||||
|
* @param timestamp 时间戳
|
||||||
|
* @return 签名
|
||||||
|
*/
|
||||||
|
private String generateSign(String accessKeyId, String accessKeySecret, String timestamp) {
|
||||||
|
return SecureUtil.md5(accessKeyId + accessKeySecret + timestamp).toUpperCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成验证信息
|
||||||
|
* <p>
|
||||||
|
* 1.使用 Base64 编码(账户 Id + 冒号 + 时间戳)其中账户 Id 根据 url 的验证级别对应主账户<br>
|
||||||
|
* 2.冒号为英文冒号<br>
|
||||||
|
* 3.时间戳是当前系统时间,格式 "yyyyMMddHHmmss",需与签名中时间戳相同。
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param accessKeyId /
|
||||||
|
* @param timestamp 时间戳
|
||||||
|
* @return 验证信息
|
||||||
|
*/
|
||||||
|
private String generateAuthorization(String accessKeyId, String timestamp) {
|
||||||
|
return Base64.encode(accessKeyId + ":" + timestamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package org.dromara.sms4j.cloopen.util;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 容联云 REST API 函数式接口
|
||||||
|
*
|
||||||
|
* @param <P> 请求参数
|
||||||
|
* @param <R> 响应
|
||||||
|
* @author Charles7c
|
||||||
|
* @since 2023/4/17 20:57
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface CloopenRestApiFunction<P, R> extends Serializable {
|
||||||
|
R apply(P param);
|
||||||
|
}
|
||||||
BIN
sms4j-comm/.mvn/wrapper/maven-wrapper.jar
vendored
BIN
sms4j-comm/.mvn/wrapper/maven-wrapper.jar
vendored
Binary file not shown.
18
sms4j-comm/.mvn/wrapper/maven-wrapper.properties
vendored
18
sms4j-comm/.mvn/wrapper/maven-wrapper.properties
vendored
@ -1,18 +0,0 @@
|
|||||||
# 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
|
|
||||||
@ -6,6 +6,7 @@ import org.dromara.sms4j.comm.enumerate.SupplierType;
|
|||||||
import org.dromara.sms4j.comm.utils.JDBCTool;
|
import org.dromara.sms4j.comm.utils.JDBCTool;
|
||||||
import org.dromara.sms4j.comm.utils.SmsUtil;
|
import org.dromara.sms4j.comm.utils.SmsUtil;
|
||||||
import org.dromara.sms4j.core.config.SupplierFactory;
|
import org.dromara.sms4j.core.config.SupplierFactory;
|
||||||
|
import org.dromara.sms4j.emay.config.EmayConfig;
|
||||||
import org.dromara.sms4j.huawei.config.HuaweiConfig;
|
import org.dromara.sms4j.huawei.config.HuaweiConfig;
|
||||||
import org.dromara.sms4j.jdcloud.config.JdCloudConfig;
|
import org.dromara.sms4j.jdcloud.config.JdCloudConfig;
|
||||||
import org.dromara.sms4j.tencent.config.TencentConfig;
|
import org.dromara.sms4j.tencent.config.TencentConfig;
|
||||||
@ -40,6 +41,7 @@ public class SupplierSqlConfig {
|
|||||||
uniSms();
|
uniSms();
|
||||||
yunPian();
|
yunPian();
|
||||||
cloopen();
|
cloopen();
|
||||||
|
emay();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -104,7 +106,7 @@ public class SupplierSqlConfig {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* cloopen
|
* cloopen
|
||||||
* <p>数据库读取并设置荣联云短信
|
* <p>数据库读取并设置容联云短信
|
||||||
* @author :Wind
|
* @author :Wind
|
||||||
*/
|
*/
|
||||||
public static void cloopen(){
|
public static void cloopen(){
|
||||||
@ -112,4 +114,12 @@ public class SupplierSqlConfig {
|
|||||||
SmsUtil.copyBean(cloopenConfig,SupplierFactory.getCloopenConfig());
|
SmsUtil.copyBean(cloopenConfig,SupplierFactory.getCloopenConfig());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* emay
|
||||||
|
* <p>数据库读取并设置亿美软通短信
|
||||||
|
*/
|
||||||
|
public static void emay() {
|
||||||
|
EmayConfig emayConfig = SmsUtil.jsonForObject(select.get(SupplierType.EMAY.getName()), EmayConfig.class);
|
||||||
|
SmsUtil.copyBean(emayConfig, SupplierFactory.getEmayConfig());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
sms4j-emay/.mvn/wrapper/maven-wrapper.jar
vendored
BIN
sms4j-emay/.mvn/wrapper/maven-wrapper.jar
vendored
Binary file not shown.
18
sms4j-emay/.mvn/wrapper/maven-wrapper.properties
vendored
18
sms4j-emay/.mvn/wrapper/maven-wrapper.properties
vendored
@ -1,18 +0,0 @@
|
|||||||
# 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
|
|
||||||
BIN
sms4j-huawei/.mvn/wrapper/maven-wrapper.jar
vendored
BIN
sms4j-huawei/.mvn/wrapper/maven-wrapper.jar
vendored
Binary file not shown.
@ -1,18 +0,0 @@
|
|||||||
# 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
|
|
||||||
BIN
sms4j-jdcloud/.mvn/wrapper/maven-wrapper.jar
vendored
BIN
sms4j-jdcloud/.mvn/wrapper/maven-wrapper.jar
vendored
Binary file not shown.
@ -1,18 +0,0 @@
|
|||||||
# 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
|
|
||||||
Loading…
x
Reference in New Issue
Block a user