Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-notifycenter
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit bf62185f
authored
Apr 13, 2022
by
levphon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
通知服务-新增发短信接口
1 parent
b1936c9f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
5 deletions
src/main/java/cn/com/glsx/notify/modules/entity/MessageTemplate.java
src/main/java/cn/com/glsx/notify/modules/service/SmsService.java
src/main/resources/mapper/MessageTemplateMapper.xml
src/main/java/cn/com/glsx/notify/modules/entity/MessageTemplate.java
View file @
bf62185
...
...
@@ -16,9 +16,20 @@ public class MessageTemplate extends BaseEntity {
private
String
content
;
/**
* 消息类型:短信SMS、邮件MAIL、公众号WXMP、小程序WXMA
*/
@Column
(
name
=
"send_type"
)
private
String
sendType
;
/**
* 短信发送通道
*/
private
String
source
;
/**
* 消息类型:根据send_type具体来看 短信类型:1:通知短信;2验证码短信
*/
private
Integer
type
;
}
\ No newline at end of file
src/main/java/cn/com/glsx/notify/modules/service/SmsService.java
View file @
bf62185
...
...
@@ -6,6 +6,7 @@ import cn.com.glsx.notify.modules.entity.MessageTemplate;
import
cn.com.glsx.notify.modules.mapper.MessageLogMapper
;
import
cn.com.glsx.notify.modules.mapper.MessageTemplateMapper
;
import
cn.com.glsx.notify.modules.utils.RopHttpUtil
;
import
com.glsx.plat.common.utils.StringUtils
;
import
com.glsx.plat.sms.properties.SMSProperties
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -47,12 +48,16 @@ public class SmsService {
log
.
warn
(
"短信模板{}不存在"
,
template
);
return
;
}
if
(
StringUtils
.
isNullOrEmpty
(
mt
.
getSource
()))
{
log
.
warn
(
"短信模板{}发送通道为空"
,
template
);
return
;
}
String
content
=
MessageFormat
.
format
(
mt
.
getContent
(),
arg
);
String
[]
phones
=
phone
.
split
(
";"
);
Arrays
.
asList
(
phones
).
forEach
(
pno
->
sendMessage
(
pno
,
String
.
valueOf
(
mt
.
getType
()),
content
));
Arrays
.
asList
(
phones
).
forEach
(
pno
->
sendMessage
(
pno
,
mt
.
getSource
(),
String
.
valueOf
(
mt
.
getType
()),
content
));
MessageLog
log
=
new
MessageLog
();
log
.
setToUser
(
phone
);
...
...
@@ -67,15 +72,16 @@ public class SmsService {
* 发送短信
*
* @param phone 电话号码,批量用逗号隔开
* @param source 发送通道
* @param type 类型
* @param context 发送内容
*/
public
void
sendMessage
(
String
phone
,
String
type
,
String
context
)
{
public
void
sendMessage
(
String
phone
,
String
source
,
String
type
,
String
context
)
{
MultiValueMap
<
String
,
String
>
params
=
new
LinkedMultiValueMap
<>(
5
);
try
{
params
.
add
(
"phone"
,
phone
);
params
.
add
(
"source"
,
properties
.
getSource
()
);
params
.
add
(
"messageSource"
,
properties
.
getSource
()
);
params
.
add
(
"source"
,
source
);
params
.
add
(
"messageSource"
,
source
);
params
.
add
(
"type"
,
type
);
params
.
add
(
"context"
,
context
);
...
...
src/main/resources/mapper/MessageTemplateMapper.xml
View file @
bf62185
...
...
@@ -10,6 +10,7 @@
<result
column=
"subject"
jdbcType=
"VARCHAR"
property=
"subject"
/>
<result
column=
"content"
jdbcType=
"VARCHAR"
property=
"content"
/>
<result
column=
"send_type"
jdbcType=
"VARCHAR"
property=
"sendType"
/>
<result
column=
"source"
jdbcType=
"VARCHAR"
property=
"source"
/>
<result
column=
"type"
jdbcType=
"INTEGER"
property=
"type"
/>
<result
column=
"del_flag"
jdbcType=
"INTEGER"
property=
"delFlag"
/>
<result
column=
"created_date"
jdbcType=
"TIMESTAMP"
property=
"createdDate"
/>
...
...
@@ -21,7 +22,7 @@
<!--
WARNING - @mbg.generated
-->
id, `template`, subject, content, send_type, `type`, del_flag, created_date,
id, `template`, subject, content, send_type, `
source`, `
type`, del_flag, created_date,
created_by, updated_date, updated_by
</sql>
<select
id=
"findByTemplate"
resultMap=
"BaseResultMap"
>
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment