Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
C
communication
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
耿迪迪
communication
Commits
a0d5103c
Commit
a0d5103c
authored
Jul 02, 2021
by
耿迪迪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
语音服务修改 gengdidi
parent
85a19eb0
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
31 deletions
+27
-31
SendBatchSms.java
...ain/java/com/zehong/communication/model/SendBatchSms.java
+7
-0
SendSms.java
src/main/java/com/zehong/communication/model/SendSms.java
+6
-0
SmsServiceImpl.java
...com/zehong/communication/service/impl/SmsServiceImpl.java
+9
-22
application.yml
src/main/resources/application.yml
+1
-5
log4j.properties
src/main/resources/log4j.properties
+4
-4
No files found.
src/main/java/com/zehong/communication/model/SendBatchSms.java
View file @
a0d5103c
...
...
@@ -19,6 +19,13 @@ public class SendBatchSms extends BaseRequestModel{
@NotBlank
(
message
=
"短信模板不能为空"
)
private
String
templateCode
;
/**
* 群发短信签名
* [\"泽宏云\",\"泽宏云\"]
*/
@NotBlank
(
message
=
"短信签名不能为空"
)
private
String
signNameJson
;
/**
* [{\"变量1\":\"值1\",\"变量2\":\"值2\",\"变量3\":\"值3\"},{\"变量1\":\"值1\",\"变量2\":\"值2\",\"变量3\":\"值3\"}]
* 群发短信变量
...
...
src/main/java/com/zehong/communication/model/SendSms.java
View file @
a0d5103c
...
...
@@ -22,6 +22,12 @@ public class SendSms extends BaseRequestModel {
@NotBlank
(
message
=
"短信模板不能为空"
)
private
String
templateCode
;
/**
* 短信签名
*/
@NotBlank
(
message
=
"短信签名不能为空"
)
private
String
signName
;
/**
* 模板变量
* {\"变量1\":\"值1\",\"变量2\":\"值2\",\"变量3\":\"值3\"}
...
...
src/main/java/com/zehong/communication/service/impl/SmsServiceImpl.java
View file @
a0d5103c
package
com
.
zehong
.
communication
.
service
.
impl
;
import
com.alibaba.fastjson.JSONArray
;
import
com.aliyuncs.DefaultAcsClient
;
import
com.aliyuncs.IAcsClient
;
import
com.aliyuncs.dysmsapi.model.v20170525.SendBatchSmsRequest
;
...
...
@@ -20,8 +19,6 @@ import org.apache.commons.lang.StringUtils;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
java.util.Arrays
;
@Service
public
class
SmsServiceImpl
implements
SmsService
{
...
...
@@ -31,12 +28,6 @@ public class SmsServiceImpl implements SmsService {
@Value
(
"${accessKeySecret}"
)
private
String
accessKeySecret
;
@Value
(
"${signName}"
)
private
String
signName
;
@Value
(
"${signNameJson}"
)
private
String
signNameJson
;
/**
* 短信API产品名称(短信产品名固定,无需修改)
*/
...
...
@@ -58,7 +49,14 @@ public class SmsServiceImpl implements SmsService {
accessKeySecret
);
DefaultProfile
.
addEndpoint
(
"cn-hangzhou"
,
"cn-hangzhou"
,
PRODUCT
,
DOMAIN
);
IAcsClient
acsClient
=
new
DefaultAcsClient
(
profile
);
SendSmsRequest
request
=
getSmsRequest
();
//组装请求对象
SendSmsRequest
request
=
new
SendSmsRequest
();
//使用post提交
request
.
setMethod
(
MethodType
.
POST
);
//必填:短信签名-可在短信控制台中找到
request
.
setSignName
(
sendSms
.
getSignName
());
//可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者
request
.
setOutId
(
"yourOutId"
);
//必填:待发送手机号。支持以逗号分隔的形式进行批量调用,批量上限为1000个手机号码,批量调用相对于单条调用及时性稍有延迟,验证码类型的短信推荐使用单条调用的方式;发送国际/港澳台消息时,接收号码格式为国际区号+号码,如“85200000000”
request
.
setPhoneNumbers
(
sendSms
.
getPhoneNumber
());
//必填:短信模板-可在短信控制台中找到,发送国际/港澳台消息时,请使用国际/港澳台短信模版
...
...
@@ -97,7 +95,7 @@ public class SmsServiceImpl implements SmsService {
//"[\"1500000000\",\"1500000001\"]"
request
.
setPhoneNumberJson
(
sendBatchSms
.
getPhoneNumberJson
());
//必填:短信签名-支持不同的号码发送不同的短信签名
request
.
setSignNameJson
(
s
ignNameJson
);
request
.
setSignNameJson
(
s
endBatchSms
.
getSignNameJson
()
);
//必填:短信模板-可在短信控制台中找到
request
.
setTemplateCode
(
sendBatchSms
.
getTemplateCode
());
//必填:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
...
...
@@ -116,15 +114,4 @@ public class SmsServiceImpl implements SmsService {
return
new
Result
(
ResultEnum
.
FAIL
.
getCode
(),
sendSmsResponse
.
getMessage
());
}
private
SendSmsRequest
getSmsRequest
(){
//组装请求对象
SendSmsRequest
request
=
new
SendSmsRequest
();
//使用post提交
request
.
setMethod
(
MethodType
.
POST
);
//必填:短信签名-可在短信控制台中找到
request
.
setSignName
(
signName
);
//可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者
request
.
setOutId
(
"yourOutId"
);
return
request
;
}
}
src/main/resources/application.yml
View file @
a0d5103c
...
...
@@ -33,13 +33,9 @@ appKey: IE5F7Jih
#批量发送语音
batchVoiceNotifyURL
:
https://api.253.com/open/notify/batch-voice-notify
#阿里云发送短信
#阿里云发送短信
或批量发送短信
accessKeyId
:
LTAI2xiZNF3iV2aV
accessKeySecret
:
bprEWwn1M0xgglRQCQEMYSPiYctDk4
signName
:
泽宏云
#阿里批量发送短信
signNameJson
:
"
[
\"
泽宏云
\"
]"
#ip白名单
iPWhite
:
192.168.2.23
...
...
src/main/resources/log4j.properties
View file @
a0d5103c
...
...
@@ -5,8 +5,8 @@ log4j.appender.Console.layout = org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern
=
[%p] [%d{yyyy-MM-dd HH
\:
mm
\:
ss}][%c - %L]%m%n
log4j.appender.File
=
org.apache.log4j.DailyRollingFileAppender
#log4j.appender.File.File = E:/java/work/info.log
log4j.appender.File.File
=
/data/java/communication/log/info
log4j.appender.File.File
=
E:/java/work/info
#
log4j.appender.File.File = /data/java/communication/log/info
log4j.appender.File.DatePattern
=
_yyyy-MM-dd'.log'
log4j.appender.File.Append
=
true
log4j.appender.File.File.MaxFileSize
=
30MB
...
...
@@ -18,8 +18,8 @@ log4j.appender.File.layout.ConversionPattern =[%p] [%d{yyyy-MM-dd HH\:mm\:ss}][%
log4j.logger.RequestLog
=
INFO,S
log4j.additivity.RequestLog
=
false
log4j.appender.S
=
org.apache.log4j.DailyRollingFileAppender
#log4j.appender.S.File =E:/java/work/log.l
og
log4j.appender.S.File
=
/data/java/communication/log/requestLog
log4j.appender.S.File
=
E:/java/work/requestL
og
#
log4j.appender.S.File = /data/java/communication/log/requestLog
log4j.appender.S.DatePattern
=
_yyyy-MM-dd'.log'
log4j.appender.S.Append
=
true
log4j.appender.S.Threshold
=
info
...
...
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