Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jiedao-api-boot-master
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lanbaoming
jiedao-api-boot-master
Commits
3bed07dc
Commit
3bed07dc
authored
Nov 22, 2024
by
honghy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整标签
parent
7eb2928e
Changes
27
Show whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
95 additions
and
108 deletions
+95
-108
SendChampHttp.java
...va/cn/iocoder/yudao/framework/http/sms/SendChampHttp.java
+9
-9
SmsClient.java
...cn/iocoder/yudao/framework/sms/core/client/SmsClient.java
+0
-2
SmsCommonResult.java
...oder/yudao/framework/sms/core/client/SmsCommonResult.java
+3
-3
SmsReceiveRespDTO.java
...udao/framework/sms/core/client/dto/SmsReceiveRespDTO.java
+1
-1
SmsTemplateRespDTO.java
...dao/framework/sms/core/client/dto/SmsTemplateRespDTO.java
+1
-1
SmsClientFactoryImpl.java
.../framework/sms/core/client/impl/SmsClientFactoryImpl.java
+2
-2
AliyunSmsClient.java
...ramework/sms/core/client/impl/aliyun/AliyunSmsClient.java
+3
-3
AliyunSmsCodeMapping.java
...ork/sms/core/client/impl/aliyun/AliyunSmsCodeMapping.java
+2
-2
SendChampSmsClient.java
...rk/sms/core/client/impl/sendchamp/SendChampSmsClient.java
+18
-19
SendChampSmsCodeMapping.java
...s/core/client/impl/sendchamp/SendChampSmsCodeMapping.java
+8
-6
YCloudSmsClient.java
...ramework/sms/core/client/impl/yCloud/YCloudSmsClient.java
+9
-7
YCloudSmsCodeMapping.java
...ork/sms/core/client/impl/yCloud/YCloudSmsCodeMapping.java
+3
-3
ReceiveStatusEnum.java
...der/yudao/framework/sms/core/enums/ReceiveStatusEnum.java
+2
-2
SmsCountryCodeEnum.java
...der/yudao/module/system/enums/sms/SmsCountryCodeEnum.java
+2
-6
SmsIsOrdersEnum.java
...ocoder/yudao/module/system/enums/sms/SmsIsOrdersEnum.java
+2
-2
SmsIsTransportEnum.java
...der/yudao/module/system/enums/sms/SmsIsTransportEnum.java
+2
-2
SmsMessageTypeEnum.java
...der/yudao/module/system/enums/sms/SmsMessageTypeEnum.java
+2
-2
SystemStatusEnum.java
...coder/yudao/module/system/enums/sms/SystemStatusEnum.java
+2
-2
SmsCallbackController.java
...le/system/controller/admin/sms/SmsCallbackController.java
+6
-4
SmsProducer.java
...oder/yudao/module/system/mq/producer/sms/SmsProducer.java
+5
-5
SmsCodeServiceImpl.java
...r/yudao/module/system/service/sms/SmsCodeServiceImpl.java
+0
-10
SmsLogService.java
...ocoder/yudao/module/system/service/sms/SmsLogService.java
+2
-2
SmsLogServiceImpl.java
...er/yudao/module/system/service/sms/SmsLogServiceImpl.java
+2
-2
SmsNodeService.java
...coder/yudao/module/system/service/sms/SmsNodeService.java
+1
-1
SmsNodeServiceImpl.java
...r/yudao/module/system/service/sms/SmsNodeServiceImpl.java
+4
-4
SmsSendServiceImpl.java
...r/yudao/module/system/service/sms/SmsSendServiceImpl.java
+3
-4
SmsTemplateServiceImpl.java
...dao/module/system/service/sms/SmsTemplateServiceImpl.java
+1
-2
No files found.
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/http/sms/Send
c
hampHttp.java
→
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/http/sms/Send
C
hampHttp.java
View file @
3bed07dc
...
...
@@ -17,7 +17,7 @@ import java.util.Map;
* @since 2024-10-23
**/
@Slf4j
public
class
Send
c
hampHttp
{
public
class
Send
C
hampHttp
{
private
static
final
String
SMS_URL
=
"https://api.sendchamp.com/api/v1/sms/send"
;
...
...
@@ -52,7 +52,7 @@ public class SendchampHttp {
}
@NotNull
public
static
Map
<
String
,
String
>
setHeader
(
String
apiKey
)
{
public
Map
<
String
,
String
>
setHeader
(
String
apiKey
)
{
Map
<
String
,
String
>
header
=
new
HashMap
<>();
header
.
put
(
"Accept"
,
"application/json,text/plain,*/*"
);
header
.
put
(
"Content-Type"
,
"application/json"
);
...
...
@@ -61,7 +61,7 @@ public class SendchampHttp {
}
@NotNull
public
static
Map
<
String
,
Object
>
setParams
(
String
to
,
String
message
,
String
senderName
)
{
public
Map
<
String
,
Object
>
setParams
(
String
to
,
String
message
,
String
senderName
)
{
Map
<
String
,
Object
>
param
=
new
HashMap
<>();
param
.
put
(
"to"
,
to
);
param
.
put
(
"message"
,
message
);
...
...
@@ -71,19 +71,19 @@ public class SendchampHttp {
}
public
static
void
main
(
String
[]
args
)
{
Send
champHttp
test
=
new
Sendc
hampHttp
();
Send
ChampHttp
test
=
new
SendC
hampHttp
();
// String to = "2348140352000";
String
to
=
"8618926674857"
;
String
senderName
=
"
Sendchamp
"
;
String
senderName
=
"
ECLogistics
"
;
//信息如果超过200字符,需要拆成多条短信,多次发送
String
message
=
"Good day!This is E&C logistics(ship from China to Nigeria),It has been a while since we last worked together, and we would like to reestablish our partnership. Our main service: GROUPAGE/FULL CONTAINE"
;
Map
<
String
,
Object
>
param
=
setParams
(
to
,
message
,
senderName
);
Map
<
String
,
Object
>
param
=
test
.
setParams
(
to
,
message
,
senderName
);
String
apiKey
=
"Bearer sendchamp_live_$2a$10$vQPdaDjl96Ybc5tzFmZYg.nqGirXuJBGDqJArthZnFR8P9mM5Z/JO"
;
Map
<
String
,
String
>
header
=
setHeader
(
apiKey
);
test
.
getReceiveStatus
(
header
,
"66e6e9df-b454-4df7-a968-af944a535757"
);
Map
<
String
,
String
>
header
=
test
.
setHeader
(
apiKey
);
//
test.getReceiveStatus(header, "66e6e9df-b454-4df7-a968-af944a535757");
test
.
postReq
(
param
,
header
);
}
...
...
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/sms/core/client/SmsClient.java
View file @
3bed07dc
...
...
@@ -64,8 +64,6 @@ public interface SmsClient {
/**
* 查询短信发送状态
*
* @param smsLogDO
* @return
*/
SmsLogDTO
getReceiveStatus
(
SmsLogDTO
smsLogDO
);
}
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/sms/core/client/SmsCommonResult.java
View file @
3bed07dc
...
...
@@ -11,9 +11,9 @@ import lombok.ToString;
/**
* 短信的 CommonResult 拓展类
*
*
<p>
* 考虑到不同的平台,返回的 code 和 msg 是不同的,所以统一额外返回 {@link #apiCode} 和 {@link #apiMsg} 字段
*
*
<p>
* 另外,一些短信平台(例如说阿里云、腾讯云)会返回一个请求编号,用于排查请求失败的问题,我们设置到 {@link #apiRequestId} 字段
*
* @author 捷道源码
...
...
@@ -25,7 +25,7 @@ public class SmsCommonResult<T> extends CommonResult<T> {
/**
* API 返回错误码
*
*
<p>
* 由于第三方的错误码可能是字符串,所以使用 String 类型
*/
private
String
apiCode
;
...
...
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/sms/core/client/dto/SmsReceiveRespDTO.java
View file @
3bed07dc
...
...
@@ -40,7 +40,7 @@ public class SmsReceiveRespDTO {
private
String
serialNo
;
/**
* 短信日志编号
*
*
<p>
* 对应 SysSmsLogDO 的编号
*/
private
Long
logId
;
...
...
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/sms/core/client/dto/SmsTemplateRespDTO.java
View file @
3bed07dc
...
...
@@ -21,7 +21,7 @@ public class SmsTemplateRespDTO {
private
String
content
;
/**
* 审核状态
*
*
<p>
* 枚举 {@link SmsTemplateAuditStatusEnum}
*/
private
Integer
auditStatus
;
...
...
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/sms/core/client/impl/SmsClientFactoryImpl.java
View file @
3bed07dc
...
...
@@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.sms.core.client.SmsClient;
import
cn.iocoder.yudao.framework.sms.core.client.SmsClientFactory
;
import
cn.iocoder.yudao.framework.sms.core.client.impl.aliyun.AliyunSmsClient
;
import
cn.iocoder.yudao.framework.sms.core.client.impl.debug.DebugDingTalkSmsClient
;
import
cn.iocoder.yudao.framework.sms.core.client.impl.sendchamp.Send
c
hampSmsClient
;
import
cn.iocoder.yudao.framework.sms.core.client.impl.sendchamp.Send
C
hampSmsClient
;
import
cn.iocoder.yudao.framework.sms.core.client.impl.yCloud.YCloudSmsClient
;
import
cn.iocoder.yudao.framework.sms.core.client.impl.yunpian.YunpianSmsClient
;
import
cn.iocoder.yudao.framework.sms.core.enums.SmsChannelEnum
;
...
...
@@ -87,7 +87,7 @@ public class SmsClientFactoryImpl implements SmsClientFactory {
case
DEBUG_DING_TALK:
return
new
DebugDingTalkSmsClient
(
properties
);
case
SENDCHAMP:
return
new
Send
c
hampSmsClient
(
properties
);
return
new
Send
C
hampSmsClient
(
properties
);
case
YCLOUD:
return
new
YCloudSmsClient
(
properties
);
}
...
...
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/sms/core/client/impl/aliyun/AliyunSmsClient.java
View file @
3bed07dc
...
...
@@ -92,7 +92,7 @@ public class AliyunSmsClient extends AbstractSmsClient {
}
@Override
protected
List
<
SmsReceiveRespDTO
>
doParseSmsReceiveStatus
(
String
text
)
throws
Throwable
{
protected
List
<
SmsReceiveRespDTO
>
doParseSmsReceiveStatus
(
String
text
)
{
List
<
SmsReceiveStatus
>
statuses
=
JsonUtils
.
parseArray
(
text
,
SmsReceiveStatus
.
class
);
return
statuses
.
stream
().
map
(
status
->
{
SmsReceiveRespDTO
resp
=
new
SmsReceiveRespDTO
();
...
...
@@ -196,7 +196,7 @@ public class AliyunSmsClient extends AbstractSmsClient {
querySendDetailsRequest
.
setBizId
(
smsLogDO
.
getApiSerialNo
());
// 初始化查询响应对象
QuerySendDetailsResponse
acsResponse
=
null
;
QuerySendDetailsResponse
acsResponse
;
try
{
// 发起查询请求并获取响应
acsResponse
=
client
.
getAcsResponse
(
querySendDetailsRequest
);
...
...
@@ -249,7 +249,7 @@ public class AliyunSmsClient extends AbstractSmsClient {
/**
* 短信接收状态
* <p>
* 参见
https://help.aliyun.com/document_detail/101867.html
文档
* 参见
<a href="https://help.aliyun.com/document_detail/101867.html">...</a>
文档
*
* @author 捷道源码
*/
...
...
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/sms/core/client/impl/aliyun/AliyunSmsCodeMapping.java
View file @
3bed07dc
...
...
@@ -7,8 +7,8 @@ import cn.iocoder.yudao.framework.sms.core.enums.SmsFrameworkErrorCodeConstants;
/**
* 阿里云的 SmsCodeMapping 实现类
*
* 参见
https://help.aliyun.com/document_detail/101346.htm
文档
*
<p>
* 参见
<a href="https://help.aliyun.com/document_detail/101346.htm">...</a>
文档
*
* @author 捷道源码
*/
...
...
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/sms/core/client/impl/sendchamp/Send
c
hampSmsClient.java
→
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/sms/core/client/impl/sendchamp/Send
C
hampSmsClient.java
View file @
3bed07dc
package
cn
.
iocoder
.
yudao
.
framework
.
sms
.
core
.
client
.
impl
.
sendchamp
;
import
cn.hutool.core.lang.Assert
;
import
cn.iocoder.yudao.framework.common.util.json.JsonUtils
;
import
cn.iocoder.yudao.framework.common.util.json.core.KeyValue
;
import
cn.iocoder.yudao.framework.http.core.Response
;
import
cn.iocoder.yudao.framework.http.sms.Send
c
hampHttp
;
import
cn.iocoder.yudao.framework.http.sms.Send
C
hampHttp
;
import
cn.iocoder.yudao.framework.sms.core.client.SmsCommonResult
;
import
cn.iocoder.yudao.framework.sms.core.client.dto.*
;
import
cn.iocoder.yudao.framework.sms.core.client.impl.AbstractSmsClient
;
import
cn.iocoder.yudao.framework.sms.core.enums.ReceiveStatusEnum
;
import
cn.iocoder.yudao.framework.sms.core.enums.SmsTemplateAuditStatusEnum
;
import
cn.iocoder.yudao.framework.sms.core.property.SmsChannelProperties
;
import
com.alibaba.fastjson.JSON
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -22,18 +22,18 @@ import java.util.regex.Matcher;
import
java.util.regex.Pattern
;
/**
* Sendchamp客户端
* SendChamp客户端
* @author jayden
*/
@Slf4j
public
class
Send
c
hampSmsClient
extends
AbstractSmsClient
{
public
class
Send
C
hampSmsClient
extends
AbstractSmsClient
{
// 创建HTTP客户端实例,用于发送短信
private
final
Send
champHttp
sendchampHttp
=
new
Sendc
hampHttp
();
private
final
Send
ChampHttp
sendchampHttp
=
new
SendC
hampHttp
();
// 定义发送方名称,此处为固定值
private
final
String
senderName
=
"Sendchamp"
;
public
Send
c
hampSmsClient
(
SmsChannelProperties
properties
)
{
super
(
properties
,
new
Send
c
hampSmsCodeMapping
());
public
Send
C
hampSmsClient
(
SmsChannelProperties
properties
)
{
super
(
properties
,
new
Send
C
hampSmsCodeMapping
());
Assert
.
notEmpty
(
properties
.
getApiKey
(),
"apiKey 不能为空"
);
Assert
.
notEmpty
(
properties
.
getApiSecret
(),
"apiSecret 不能为空"
);
}
...
...
@@ -44,7 +44,7 @@ public class SendchampSmsClient extends AbstractSmsClient {
}
@Override
protected
SmsCommonResult
<
SmsSendRespDTO
>
doSendSms
(
Long
sendLogId
,
String
mobile
,
String
apiTemplateId
,
List
<
KeyValue
<
String
,
Object
>>
templateParams
)
throws
Throwable
{
protected
SmsCommonResult
<
SmsSendRespDTO
>
doSendSms
(
Long
sendLogId
,
String
mobile
,
String
apiTemplateId
,
List
<
KeyValue
<
String
,
Object
>>
templateParams
)
{
return
null
;
}
...
...
@@ -80,10 +80,10 @@ public class SendchampSmsClient extends AbstractSmsClient {
try
{
// 如果信息超过200字符,需要拆分成多条短信发送
List
<
String
>
messages
=
splitContent
(
content
,
200
);
List
<
String
>
messages
=
splitContent
(
content
);
for
(
String
message
:
messages
)
{
// 设置发送短信所需的参数
Map
<
String
,
Object
>
param
=
sendchampHttp
.
setParams
(
mobile
,
message
,
senderName
);
Map
<
String
,
Object
>
param
=
sendchampHttp
.
setParams
(
mobile
,
message
,
"Sendchamp"
);
// 设置请求头,包含认证信息
Map
<
String
,
String
>
header
=
sendchampHttp
.
setHeader
(
"Bearer "
+
properties
.
getApiSecret
());
// 发送POST请求
...
...
@@ -91,8 +91,8 @@ public class SendchampSmsClient extends AbstractSmsClient {
// 获取响应体
String
result
=
response
.
getBody
();
// 解析响应结果
Map
<?,
?>
responseObj
=
J
sonUtils
.
parseObject
(
result
,
Map
.
class
);
Map
<
String
,
Object
>
data
=
(
Map
<
String
,
Object
>)
responseObj
.
get
(
"data"
);
Map
<?,
?>
responseObj
=
J
SON
.
parseObject
(
result
,
Map
.
class
);
Map
<
?,
?>
data
=
(
Map
<?,
?
>)
responseObj
.
get
(
"data"
);
// 构建发送结果
String
id
=
String
.
valueOf
(
data
.
get
(
"business_id"
));
if
(
"null"
.
equals
(
id
))
{
...
...
@@ -149,14 +149,13 @@ public class SendchampSmsClient extends AbstractSmsClient {
* 将内容拆分成多个部分,每个部分不超过 maxLength 字符
*
* @param content 待拆分的内容
* @param maxLength 每个部分的最大长度
* @return 拆分后的内容列表
*/
private
List
<
String
>
splitContent
(
String
content
,
int
maxLength
)
{
private
List
<
String
>
splitContent
(
String
content
)
{
List
<
String
>
messages
=
new
ArrayList
<>();
int
start
=
0
;
while
(
start
<
content
.
length
())
{
int
end
=
Math
.
min
(
start
+
maxLength
,
content
.
length
());
int
end
=
Math
.
min
(
start
+
200
,
content
.
length
());
messages
.
add
(
content
.
substring
(
start
,
end
));
start
=
end
;
}
...
...
@@ -164,12 +163,12 @@ public class SendchampSmsClient extends AbstractSmsClient {
}
@Override
protected
List
<
SmsReceiveRespDTO
>
doParseSmsReceiveStatus
(
String
text
)
throws
Throwable
{
protected
List
<
SmsReceiveRespDTO
>
doParseSmsReceiveStatus
(
String
text
)
{
return
null
;
}
@Override
protected
SmsCommonResult
<
SmsTemplateRespDTO
>
doGetSmsTemplate
(
String
apiTemplateId
)
throws
Throwable
{
protected
SmsCommonResult
<
SmsTemplateRespDTO
>
doGetSmsTemplate
(
String
apiTemplateId
)
{
SmsTemplateRespDTO
data
=
new
SmsTemplateRespDTO
().
setId
(
apiTemplateId
).
setContent
(
""
)
.
setAuditStatus
(
SmsTemplateAuditStatusEnum
.
SUCCESS
.
getStatus
()).
setAuditReason
(
""
);
return
SmsCommonResult
.
build
(
"accepted"
,
"accepted"
,
null
,
data
,
codeMapping
);
...
...
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/sms/core/client/impl/sendchamp/Send
c
hampSmsCodeMapping.java
→
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/sms/core/client/impl/sendchamp/Send
C
hampSmsCodeMapping.java
View file @
3bed07dc
...
...
@@ -6,16 +6,18 @@ import cn.iocoder.yudao.framework.sms.core.client.SmsCodeMapping;
import
cn.iocoder.yudao.framework.sms.core.enums.SmsFrameworkErrorCodeConstants
;
/**
* sendchamp SmsCodeMapping 实现类
* SendChamp SmsCodeMapping 实现类
* @author Jayden
*/
public
class
Send
c
hampSmsCodeMapping
implements
SmsCodeMapping
{
public
class
Send
C
hampSmsCodeMapping
implements
SmsCodeMapping
{
@Override
public
ErrorCode
apply
(
String
apiCode
)
{
switch
(
apiCode
)
{
case
"accepted"
:
return
GlobalErrorCodeConstants
.
SUCCESS
;
case
"processing"
:
return
GlobalErrorCodeConstants
.
SUCCESS
;
case
"send"
:
return
GlobalErrorCodeConstants
.
SUCCESS
;
case
"delivered"
:
return
GlobalErrorCodeConstants
.
SUCCESS
;
case
"accepted"
:
case
"processing"
:
case
"send"
:
case
"delivered"
:
return
GlobalErrorCodeConstants
.
SUCCESS
;
}
return
SmsFrameworkErrorCodeConstants
.
SMS_UNKNOWN
;
}
...
...
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/sms/core/client/impl/yCloud/YCloudSmsClient.java
View file @
3bed07dc
package
cn
.
iocoder
.
yudao
.
framework
.
sms
.
core
.
client
.
impl
.
yCloud
;
import
cn.hutool.core.lang.Assert
;
import
cn.iocoder.yudao.framework.common.util.json.JsonUtils
;
import
cn.iocoder.yudao.framework.common.util.json.core.KeyValue
;
import
cn.iocoder.yudao.framework.http.core.Response
;
import
cn.iocoder.yudao.framework.http.sms.YCloudWhatsappHttp
;
import
cn.iocoder.yudao.framework.sms.core.client.SmsCommonResult
;
import
cn.iocoder.yudao.framework.sms.core.client.dto.*
;
import
cn.iocoder.yudao.framework.sms.core.client.impl.AbstractSmsClient
;
import
cn.iocoder.yudao.framework.sms.core.client.impl.sendchamp.SendchampSmsCodeMapping
;
import
cn.iocoder.yudao.framework.sms.core.enums.ReceiveStatusEnum
;
import
cn.iocoder.yudao.framework.sms.core.enums.SmsTemplateAuditStatusEnum
;
import
cn.iocoder.yudao.framework.sms.core.property.SmsChannelProperties
;
import
com.alibaba.fastjson.JSON
;
import
lombok.extern.slf4j.Slf4j
;
import
java.time.ZoneId
;
...
...
@@ -34,7 +33,7 @@ public class YCloudSmsClient extends AbstractSmsClient {
private
final
YCloudWhatsappHttp
yCloudWhatsappHttp
=
new
YCloudWhatsappHttp
();
public
YCloudSmsClient
(
SmsChannelProperties
properties
)
{
super
(
properties
,
new
Sendchamp
SmsCodeMapping
());
super
(
properties
,
new
YCloud
SmsCodeMapping
());
Assert
.
notEmpty
(
properties
.
getApiKey
(),
"apiKey 不能为空"
);
Assert
.
notEmpty
(
properties
.
getApiSecret
(),
"apiSecret 不能为空"
);
}
...
...
@@ -45,7 +44,7 @@ public class YCloudSmsClient extends AbstractSmsClient {
}
@Override
protected
SmsCommonResult
<
SmsSendRespDTO
>
doSendSms
(
Long
sendLogId
,
String
mobile
,
String
apiTemplateId
,
List
<
KeyValue
<
String
,
Object
>>
templateParams
)
throws
Throwable
{
protected
SmsCommonResult
<
SmsSendRespDTO
>
doSendSms
(
Long
sendLogId
,
String
mobile
,
String
apiTemplateId
,
List
<
KeyValue
<
String
,
Object
>>
templateParams
)
{
return
null
;
}
...
...
@@ -76,7 +75,7 @@ public class YCloudSmsClient extends AbstractSmsClient {
yCloudWhatsappHttp
.
setParams
(
code
,
smsTemplateDTO
.
getApiTemplateId
(),
smsTemplateDTO
.
getLanguage
(),
mobile
));
// 解析结果
Map
<
String
,
Object
>
responseObj
=
JsonUtils
.
parseObject
(
response
.
getBody
(),
Map
.
class
);
Map
<
?,
?>
responseObj
=
JSON
.
parseObject
(
response
.
getBody
(),
Map
.
class
);
// 构建短信发送结果对象
SmsCommonResult
<
SmsSendRespDTO
>
smsCommonResult
=
SmsCommonResult
.
build
(
String
.
valueOf
(
responseObj
.
get
(
"status"
)),
String
.
valueOf
(
responseObj
.
get
(
"status"
)),
String
.
valueOf
(
responseObj
.
get
(
"id"
)),
null
,
codeMapping
);
// 设置短信发送结果的详细信息
...
...
@@ -102,11 +101,14 @@ public class YCloudSmsClient extends AbstractSmsClient {
// 发送短信并获取响应
Response
response
=
yCloudWhatsappHttp
.
getReceiveStatus
(
yCloudWhatsappHttp
.
setHeader
(
properties
.
getApiSecret
()),
smsLogDO
.
getApiSerialNo
());
// 解析响应内容为Map对象,以便后续处理
Map
<
String
,
Object
>
responseObj
=
JsonUtils
.
parseObject
(
response
.
getBody
(),
Map
.
class
);
Map
<
?,
?>
responseObj
=
JSON
.
parseObject
(
response
.
getBody
(),
Map
.
class
);
// 获取短信状态
String
status
=
(
String
)
responseObj
.
get
(
"status"
);
if
(
status
==
null
){
return
smsLogDTO
;
}
// 如果短信状态为已送达或已读取,则进一步处理
if
(
status
!=
null
&&
(
"delivered"
.
equals
(
status
)
||
"read"
.
equals
(
status
)
))
{
if
(
"delivered"
.
equals
(
status
)
||
"read"
.
equals
(
status
))
{
// 获取送达时间
String
deliverTime
=
(
String
)
responseObj
.
get
(
"deliverTime"
);
// 解析并转换送达时间为本地时间
...
...
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/sms/core/client/impl/yCloud/YCloudSmsCodeMapping.java
View file @
3bed07dc
...
...
@@ -14,8 +14,8 @@ import cn.iocoder.yudao.framework.sms.core.enums.SmsFrameworkErrorCodeConstants;
public
class
YCloudSmsCodeMapping
implements
SmsCodeMapping
{
@Override
public
ErrorCode
apply
(
String
apiCode
)
{
switch
(
apiCode
)
{
case
"success"
:
return
GlobalErrorCodeConstants
.
SUCCESS
;
if
(
"success"
.
equals
(
apiCode
)
)
{
return
GlobalErrorCodeConstants
.
SUCCESS
;
}
return
SmsFrameworkErrorCodeConstants
.
SMS_UNKNOWN
;
}
...
...
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/sms/core/enums/ReceiveStatusEnum.java
View file @
3bed07dc
...
...
@@ -16,7 +16,7 @@ public enum ReceiveStatusEnum {
Receive_STATUS_10
(
"接收成功"
,
10
),
Receive_STATUS_20
(
"接收失败"
,
20
);
private
String
name
;
private
final
String
name
;
private
Integer
value
;
private
final
Integer
value
;
}
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/sms/SmsCountryCodeEnum.java
View file @
3bed07dc
package
cn
.
iocoder
.
yudao
.
module
.
system
.
enums
.
sms
;
import
cn.hutool.core.util.ArrayUtil
;
import
cn.iocoder.yudao.framework.common.util.json.core.IntArrayValuable
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
java.util.Arrays
;
/**
* 国家编号枚举
*
...
...
@@ -19,7 +15,7 @@ public enum SmsCountryCodeEnum {
SMS_COUNTRY_CODE_0
(
"全部"
,
"0"
),
SMS_COUNTRY_CODE_1
(
"其他"
,
"1"
);
private
String
name
;
private
final
String
name
;
private
String
value
;
private
final
String
value
;
}
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/sms/SmsIsOrdersEnum.java
View file @
3bed07dc
...
...
@@ -15,7 +15,7 @@ public enum SmsIsOrdersEnum {
SMS_ORDERS_0
(
"否"
,
0
),
SMS_ORDERS_1
(
"是"
,
1
);
private
String
name
;
private
final
String
name
;
private
Integer
value
;
private
final
Integer
value
;
}
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/sms/SmsIsTransportEnum.java
View file @
3bed07dc
...
...
@@ -15,7 +15,7 @@ public enum SmsIsTransportEnum {
SMS_ORDERS_0
(
"否"
,
0
),
SMS_ORDERS_1
(
"是"
,
1
);
private
String
name
;
private
final
String
name
;
private
Integer
value
;
private
final
Integer
value
;
}
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/sms/SmsMessageTypeEnum.java
View file @
3bed07dc
...
...
@@ -16,7 +16,7 @@ public enum SmsMessageTypeEnum {
SMS_MESSAGE_TYPE_2
(
"whatsapp"
,
2
),
SMS_MESSAGE_TYPE_3
(
"email"
,
3
);
private
String
name
;
private
final
String
name
;
private
Integer
value
;
private
final
Integer
value
;
}
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/sms/SystemStatusEnum.java
View file @
3bed07dc
...
...
@@ -15,7 +15,7 @@ public enum SystemStatusEnum {
SYSTEM_STATUS_0
(
"开启"
,
0
),
SYSTEM_STATUS_1
(
"关闭"
,
1
);
private
String
name
;
private
final
String
name
;
private
Integer
value
;
private
final
Integer
value
;
}
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/sms/SmsCallbackController.java
View file @
3bed07dc
...
...
@@ -5,14 +5,13 @@ import cn.hutool.extra.servlet.ServletUtil;
import
cn.iocoder.yudao.framework.common.pojo.CommonResult
;
import
cn.iocoder.yudao.framework.common.util.json.JsonUtils
;
import
cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog
;
import
cn.iocoder.yudao.framework.sms.core.client.impl.sendchamp.Send
c
hampSmsClient
;
import
cn.iocoder.yudao.framework.sms.core.client.impl.sendchamp.Send
C
hampSmsClient
;
import
cn.iocoder.yudao.framework.sms.core.enums.SmsChannelEnum
;
import
cn.iocoder.yudao.module.system.service.sms.SmsLogService
;
import
cn.iocoder.yudao.module.system.service.sms.SmsSendService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
...
...
@@ -23,6 +22,9 @@ import javax.servlet.http.HttpServletRequest;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
pojo
.
CommonResult
.
success
;
/**
* @author ECIT-2
*/
@Api
(
tags
=
"管理后台 - 短信回调"
)
@RestController
@RequestMapping
(
"/system/sms/callback"
)
...
...
@@ -31,7 +33,7 @@ public class SmsCallbackController {
@Resource
private
SmsSendService
smsSendService
;
@
Autowired
@
Resource
private
SmsLogService
smsLogService
;
@PostMapping
(
"/yunpian"
)
...
...
@@ -58,7 +60,7 @@ public class SmsCallbackController {
@OperateLog
(
enable
=
false
)
public
CommonResult
<
Boolean
>
receiveSendchampSmsStatus
(
HttpServletRequest
request
)
{
String
text
=
ServletUtil
.
getBody
(
request
);
Send
champSmsClient
.
SmsReceiveStatus
smsReceiveStatus
=
JsonUtils
.
parseObject
(
text
,
Sendc
hampSmsClient
.
SmsReceiveStatus
.
class
);
Send
ChampSmsClient
.
SmsReceiveStatus
smsReceiveStatus
=
JsonUtils
.
parseObject
(
text
,
SendC
hampSmsClient
.
SmsReceiveStatus
.
class
);
smsLogService
.
updateSendchampReceive
(
smsReceiveStatus
);
return
success
(
true
);
}
...
...
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/mq/producer/sms/SmsProducer.java
View file @
3bed07dc
...
...
@@ -23,14 +23,14 @@ import java.util.List;
public
class
SmsProducer
{
@Resource
private
RedisMQTemplate
redisM
Q
Template
;
private
RedisMQTemplate
redisM
q
Template
;
/**
* 发送 {@link SmsChannelRefreshMessage} 消息
*/
public
void
sendSmsChannelRefreshMessage
()
{
SmsChannelRefreshMessage
message
=
new
SmsChannelRefreshMessage
();
redisM
Q
Template
.
send
(
message
);
redisM
q
Template
.
send
(
message
);
}
/**
...
...
@@ -38,7 +38,7 @@ public class SmsProducer {
*/
public
void
sendSmsTemplateRefreshMessage
()
{
SmsTemplateRefreshMessage
message
=
new
SmsTemplateRefreshMessage
();
redisM
Q
Template
.
send
(
message
);
redisM
q
Template
.
send
(
message
);
}
/**
...
...
@@ -54,10 +54,10 @@ public class SmsProducer {
Long
channelId
,
String
apiTemplateId
,
List
<
KeyValue
<
String
,
Object
>>
templateParams
)
{
SmsSendMessage
message
=
new
SmsSendMessage
().
setLogId
(
logId
).
setMobile
(
mobile
);
message
.
setChannelId
(
channelId
).
setApiTemplateId
(
apiTemplateId
).
setTemplateParams
(
templateParams
);
redisM
Q
Template
.
send
(
message
);
redisM
q
Template
.
send
(
message
);
}
public
void
sendSmsSendMessageV2
(
SmsSendMessageV2
message
)
{
redisM
Q
Template
.
send
(
message
);
redisM
q
Template
.
send
(
message
);
}
}
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/sms/SmsCodeServiceImpl.java
View file @
3bed07dc
...
...
@@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.system.service.sms;
import
cn.hutool.core.map.MapUtil
;
import
cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil
;
import
cn.iocoder.yudao.framework.web.config.BusinessProperties
;
import
cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeCheckReqDTO
;
import
cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeSendReqDTO
;
import
cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeUseReqDTO
;
...
...
@@ -36,17 +35,8 @@ public class SmsCodeServiceImpl implements SmsCodeService {
@Resource
private
SmsSendService
smsSendService
;
@Resource
private
BusinessProperties
businessProperties
;
@Override
public
void
sendSmsCode
(
SmsCodeSendReqDTO
reqDTO
)
{
// SmsSceneEnum sceneEnum = SmsSceneEnum.getCodeByScene(reqDTO.getScene());
// Assert.notNull(sceneEnum, "验证码场景({}) 查找不到配置", reqDTO.getScene());
// if (Objects.nonNull(businessProperties) && businessProperties.isDebug()) {
// // TODO debug业务模式下不需要生成发送验证码,固定使用9999
// return;
// }
// 创建验证码
String
code
=
createSmsCode
(
reqDTO
.
getMobile
(),
reqDTO
.
getNodeValue
(),
reqDTO
.
getCreateIp
());
// 发送验证码
...
...
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/sms/SmsLogService.java
View file @
3bed07dc
package
cn
.
iocoder
.
yudao
.
module
.
system
.
service
.
sms
;
import
cn.iocoder.yudao.framework.sms.core.client.impl.sendchamp.Send
c
hampSmsClient
;
import
cn.iocoder.yudao.framework.sms.core.client.impl.sendchamp.Send
C
hampSmsClient
;
import
cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogExportReqVO
;
import
cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogPageReqVO
;
import
cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsLogDO
;
...
...
@@ -118,5 +118,5 @@ public interface SmsLogService {
* 更新sendchamp回调状态
* @param smsReceiveStatus
*/
void
updateSendchampReceive
(
Send
c
hampSmsClient
.
SmsReceiveStatus
smsReceiveStatus
);
void
updateSendchampReceive
(
Send
C
hampSmsClient
.
SmsReceiveStatus
smsReceiveStatus
);
}
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/sms/SmsLogServiceImpl.java
View file @
3bed07dc
package
cn
.
iocoder
.
yudao
.
module
.
system
.
service
.
sms
;
import
cn.iocoder.yudao.framework.common.pojo.CommonResult
;
import
cn.iocoder.yudao.framework.sms.core.client.impl.sendchamp.Send
c
hampSmsClient
;
import
cn.iocoder.yudao.framework.sms.core.client.impl.sendchamp.Send
C
hampSmsClient
;
import
cn.iocoder.yudao.framework.sms.core.enums.ReceiveStatusEnum
;
import
cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogExportReqVO
;
import
cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogPageReqVO
;
...
...
@@ -160,7 +160,7 @@ public class SmsLogServiceImpl implements SmsLogService {
}
@Override
public
void
updateSendchampReceive
(
Send
c
hampSmsClient
.
SmsReceiveStatus
smsReceiveStatus
)
{
public
void
updateSendchampReceive
(
Send
C
hampSmsClient
.
SmsReceiveStatus
smsReceiveStatus
)
{
if
(
"delivered"
.
equals
(
smsReceiveStatus
.
getStatus
()))
{
List
<
SmsLogDO
>
smsLogDOS
=
smsLogMapper
.
selectList
(
new
SmsLogExportReqVO
().
setApiSerialNo
(
smsReceiveStatus
.
getReference
()));
if
(
smsLogDOS
!=
null
)
{
...
...
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/sms/SmsNodeService.java
View file @
3bed07dc
...
...
@@ -85,5 +85,5 @@ public interface SmsNodeService extends IService<SmsNodeDO> {
/**
* 短信重发定时任务
*/
public
void
scheduleReceiveRefresh
(
Integer
time
);
void
scheduleReceiveRefresh
(
Integer
time
);
}
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/sms/SmsNodeServiceImpl.java
View file @
3bed07dc
...
...
@@ -43,16 +43,16 @@ public class SmsNodeServiceImpl extends AbstractService<SmsNodeMapper, SmsNodeDO
@Resource
private
SmsNodeMapper
smsNodeMapper
;
@
Autowired
@
Resource
private
RedisHelper
redisHelper
;
@
Autowired
@
Resource
private
SmsLogService
smsLogService
;
@
Autowired
@
Resource
private
SmsClientFactory
smsClientFactory
;
@
Autowired
@
Resource
private
SmsSendService
smsSendService
;
/**
...
...
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/sms/SmsSendServiceImpl.java
View file @
3bed07dc
...
...
@@ -30,7 +30,6 @@ import cn.iocoder.yudao.module.system.mq.producer.sms.SmsProducer;
import
cn.iocoder.yudao.module.system.service.user.AdminUserService
;
import
com.alibaba.fastjson.JSON
;
import
com.google.common.annotations.VisibleForTesting
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.Assert
;
...
...
@@ -71,10 +70,10 @@ public class SmsSendServiceImpl implements SmsSendService {
@Resource
private
BusinessProperties
businessProperties
;
@
Autowired
@
Resource
private
SmsNodeService
smsNodeService
;
@
Autowired
@
Resource
private
RedisHelper
redisHelper
;
@Override
...
...
@@ -231,7 +230,7 @@ public class SmsSendServiceImpl implements SmsSendService {
/**
* 将参数模板,处理成有序的 KeyValue 数组
* <p>
* 原因是,部分短信平台并不是使用 key 作为参数,而是数组下标,例如说腾讯云
https://cloud.tencent.com/document/product/382/39023
* 原因是,部分短信平台并不是使用 key 作为参数,而是数组下标,例如说腾讯云
<a href="https://cloud.tencent.com/document/product/382/39023">...</a>
*
* @param template 短信模板
* @param templateParams 原始参数
...
...
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/sms/SmsTemplateServiceImpl.java
View file @
3bed07dc
...
...
@@ -23,7 +23,6 @@ import cn.iocoder.yudao.module.system.mq.producer.sms.SmsProducer;
import
com.alibaba.fastjson.JSON
;
import
com.google.common.annotations.VisibleForTesting
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.Assert
;
...
...
@@ -68,7 +67,7 @@ public class SmsTemplateServiceImpl implements SmsTemplateService {
@Resource
private
SmsProducer
smsProducer
;
@
Autowired
@
Resource
private
RedisHelper
redisHelper
;
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment