Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
Overview
Overview
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
haoban3.0
haoban-manage3.0
Commits
b35769df
Commit
b35769df
authored
Apr 26, 2021
by
bilingfeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 新增消息单人发送通用接口
parent
3ad13fed
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
5 deletions
+67
-5
StaffDepartmentRelatedApiService.java
.../manage/api/service/StaffDepartmentRelatedApiService.java
+12
-0
StaffDepartmentRelatedApiServiceImpl.java
...ervice/out/impl/StaffDepartmentRelatedApiServiceImpl.java
+55
-5
No files found.
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/service/StaffDepartmentRelatedApiService.java
View file @
b35769df
...
...
@@ -36,6 +36,18 @@ public interface StaffDepartmentRelatedApiService {
//发送消息,单人发送
boolean
sendSingleMessage
(
String
clerkId
,
String
title
,
String
content
,
String
pageUrl
);
/**
* 单人消息发送通用方法
*
* @param clerkId : 接收人id
* @param title : 通知标题
* @param contentMap : 时间集合, key 为类型, value : 内容(例如 接收事件 : 事件内容)
* @param pageUrl : 跳转地址
* @return : 返回是否发送成功
*/
Boolean
sendSingleMessage
(
String
clerkId
,
String
title
,
Map
<
String
,
String
>
contentMap
,
String
pageUrl
);
//发送消息,带审核理由
public
boolean
sendAuditMessage
(
String
clerkId
,
String
title
,
String
content
,
String
pageUrl
,
int
auditStatus
,
String
auditReason
);
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/StaffDepartmentRelatedApiServiceImpl.java
View file @
b35769df
package
com
.
gic
.
haoban
.
manage
.
service
.
service
.
out
.
impl
;
import
java.net.URLEncoder
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.*
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.http.client.utils.URLEncodedUtils
;
...
...
@@ -47,6 +43,7 @@ import com.gic.wechat.api.dto.qywx.QywxXcxSendMessageDTO;
import
com.gic.wechat.api.service.qywx.QywxSuiteApiService
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
@Service
public
class
StaffDepartmentRelatedApiServiceImpl
implements
StaffDepartmentRelatedApiService
{
...
...
@@ -347,6 +344,59 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
logger
.
info
(
"发送===============》{}"
,
b
);
return
b
;
}
/**
* 单人消息发送通用方法
*
* @param clerkId : 接收人id
* @param title : 通知标题
* @param contentMap : 时间集合, key 为类型, value : 内容(例如 接收事件 : 事件内容)
* @param pageUrl : 跳转地址
* @return : 返回是否发送成功
*/
@Override
public
Boolean
sendSingleMessage
(
String
clerkId
,
String
title
,
Map
<
String
,
String
>
contentMap
,
String
pageUrl
)
{
if
(
StringUtils
.
isEmpty
(
clerkId
)){
logger
.
info
(
"消息接收人不存在"
);
return
Boolean
.
FALSE
;
}
if
(
CollectionUtils
.
isEmpty
(
contentMap
)){
logger
.
info
(
"发送事件内容不存在"
);
return
Boolean
.
FALSE
;
}
Map
<
String
,
String
>
map
=
this
.
getWxUserIdByClerkId
(
clerkId
);
String
wxUserId
=
map
.
get
(
"wxUserId"
);
String
corpId
=
map
.
get
(
"corpId"
);
String
name
=
map
.
get
(
"clerkName"
);
if
(
jodd
.
util
.
StringUtil
.
isEmpty
(
wxUserId
)){
logger
.
info
(
"接收人wxUserId不存在, clerkId : {}"
,
clerkId
);
return
Boolean
.
FALSE
;
}
//组装发送内容
List
<
ItemDTO
>
contentList
=
new
ArrayList
<>();
ItemDTO
dto
=
new
ItemDTO
();
dto
.
setKey
(
"接收人"
);
dto
.
setValue
(
name
);
contentList
.
add
(
dto
);
contentMap
.
forEach
((
key
,
value
)
->
{
ItemDTO
itemDTO
=
new
ItemDTO
();
itemDTO
.
setKey
(
key
);
String
content
=
value
.
length
()
>
30
?
value
.
substring
(
0
,
26
)
+
"..."
:
value
;
itemDTO
.
setValue
(
content
);
});
QywxXcxSendMessageDTO
messageDTO
=
new
QywxXcxSendMessageDTO
();
messageDTO
.
setAppid
(
this
.
config
.
getAppid
());
messageDTO
.
setUserIds
(
Collections
.
singletonList
(
wxUserId
));
messageDTO
.
setTitle
(
title
);
messageDTO
.
setItems
(
contentList
);
messageDTO
.
setPage
(
pageUrl
);
logger
.
info
(
"消息发送, corpId : {}, suitId : {}, messageDTO : {}"
,
corpId
,
config
.
getWxSuiteid
(),
JSONObject
.
toJSONString
(
messageDTO
));
boolean
sendResult
=
qywxSuiteApiService
.
sendMessage
(
corpId
,
config
.
getWxSuiteid
(),
messageDTO
);
logger
.
info
(
"消息发送结果, sendResult : {}"
,
sendResult
);
return
sendResult
;
}
@Override
public
boolean
sendAuditMessage
(
String
staffId
,
String
title
,
String
content
,
String
pageUrl
,
int
auditStatus
,
String
auditReason
)
{
...
...
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