Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibznotify
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibznotify
提交
01d85850
提交
01d85850
编写于
9月 06, 2020
作者:
zhouweidong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
同步lab环境代码
上级
4535a485
变更
4
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
383 行增加
和
336 行删除
+383
-336
DevBootSecurityConfig.java
...rc/main/java/cn/ibizlab/config/DevBootSecurityConfig.java
+1
-6
NotifyCoreService.java
...cn/ibizlab/core/extensions/service/NotifyCoreService.java
+359
-306
apiSecurityConfig.java
...rc/main/java/cn/ibizlab/api/config/apiSecurityConfig.java
+1
-6
NotifyCoreResource.java
...va/cn/ibizlab/api/rest/extensions/NotifyCoreResource.java
+22
-18
未找到文件。
ibznotify-boot/src/main/java/cn/ibizlab/config/DevBootSecurityConfig.java
浏览文件 @
01d85850
...
...
@@ -115,12 +115,7 @@ public class DevBootSecurityConfig extends WebSecurityConfigurerAdapter {
.
antMatchers
(
"/"
+
uploadpath
).
permitAll
()
.
antMatchers
(
"/"
+
previewpath
+
"/**"
).
permitAll
()
//消息发送请求
.
antMatchers
(
"/SendMsg"
).
permitAll
()
.
antMatchers
(
"/createMsgTemplate"
).
permitAll
()
.
antMatchers
(
"/trade/pagepay"
).
permitAll
()
.
antMatchers
(
"/dingtalk/sendlinkmsg"
).
permitAll
()
.
antMatchers
(
"/dingtalk/createworkrecord"
).
permitAll
()
.
antMatchers
(
"/dingtalk/finishworkrecord"
).
permitAll
()
.
antMatchers
(
"/notify/**"
).
permitAll
()
.
anyRequest
().
authenticated
()
// 防止iframe 造成跨域
...
...
ibznotify-core/src/main/java/cn/ibizlab/core/extensions/service/NotifyCoreService.java
浏览文件 @
01d85850
package
cn
.
ibizlab
.
core
.
extensions
.
service
;
import
cn.ibizlab.core.extensions.domain.Msg
;
import
cn.ibizlab.core.extensions.domain.Template
;
import
cn.ibizlab.core.notify.domain.MsgBody
;
import
cn.ibizlab.core.notify.domain.MsgOpenAccess
;
import
cn.ibizlab.core.notify.domain.MsgTemplate
;
import
cn.ibizlab.core.notify.domain.MsgUserAccount
;
import
cn.ibizlab.core.notify.service.IMsgBodyService
;
import
cn.ibizlab.core.notify.service.IMsgOpenAccessService
;
import
cn.ibizlab.core.notify.service.IMsgTemplateService
;
import
cn.ibizlab.core.notify.service.IMsgUserAccountService
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
c
om.alibaba.fastjson.JSON
;
import
c
n.ibizlab.util.helper.CachedBeanCopier
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.aliyuncs.CommonRequest
;
...
...
@@ -17,27 +18,33 @@ import com.aliyuncs.CommonResponse;
import
com.aliyuncs.DefaultAcsClient
;
import
com.aliyuncs.IAcsClient
;
import
com.aliyuncs.dm.model.v20151123.SingleSendMailRequest
;
import
com.aliyuncs.dm.model.v20151123.SingleSendMailResponse
;
import
com.aliyuncs.http.MethodType
;
import
com.aliyuncs.profile.DefaultProfile
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.dingtalk.api.DefaultDingTalkClient
;
import
com.dingtalk.api.DingTalkClient
;
import
com.dingtalk.api.request.OapiGettokenRequest
;
import
com.dingtalk.api.request.OapiMessageCorpconversationAsyncsendV2Request
;
import
com.dingtalk.api.request.OapiWorkrecordAddRequest
;
import
com.dingtalk.api.request.OapiWorkrecordUpdateRequest
;
import
com.dingtalk.api.response.*
;
import
com.dingtalk.api.response.OapiGettokenResponse
;
import
com.dingtalk.api.response.OapiMessageCorpconversationAsyncsendV2Response
;
import
com.dingtalk.api.response.OapiWorkrecordAddResponse
;
import
com.dingtalk.api.response.OapiWorkrecordUpdateResponse
;
import
com.google.gson.Gson
;
import
lombok.SneakyThrows
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.scheduling.annotation.
Async
;
import
org.springframework.scheduling.annotation.
Scheduled
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.client.RestTemplate
;
import
java.sql.Timestamp
;
import
java.util.*
;
...
...
@@ -81,16 +88,6 @@ public class NotifyCoreService {
* 阿里短信服务单处理行为
*/
private
static
final
String
aliSendSmsVersion
=
"2017-05-25"
;
/**
* 消息类型
*/
enum
MsgType
{
dingtalk
,
aliyun
,
wechat
,
}
/**
* 平台消息类型代码表
*/
...
...
@@ -127,7 +124,11 @@ public class NotifyCoreService {
@Autowired
@Lazy
NotifyCoreService
notifyCoreService
;
NotifyCoreService
proxyService
;
@Autowired
@Lazy
IMsgBodyService
msgBodyService
;
/**
* 获取钉钉token
...
...
@@ -160,19 +161,101 @@ public class NotifyCoreService {
return
result
.
getBody
();
}
/**
* 设置新token及过期时间
* @param openAccess
* @return
*/
public
MsgOpenAccess
refreshToken
(
MsgOpenAccess
openAccess
){
String
tempToken
=
null
;
switch
(
openAccess
.
getOpenType
()){
case
"wechat"
:
tempToken
=
getWeChatToken
(
openAccess
);
break
;
case
"dingtalk"
:
tempToken
=
getDingTalkToken
(
openAccess
);
break
;
}
if
(!
StringUtils
.
isEmpty
(
tempToken
)){
JSONObject
objToken
=
JSONObject
.
parseObject
(
tempToken
);
if
(
objToken
!=
null
){
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
new
Date
());
calendar
.
add
(
Calendar
.
SECOND
,
Integer
.
parseInt
(
objToken
.
getString
(
"expires_in"
)));
Date
date
=
calendar
.
getTime
();
openAccess
.
setAccessToken
(
objToken
.
getString
(
"access_token"
));
openAccess
.
setExpiresTime
(
new
Timestamp
(
date
.
getTime
()));
}
}
return
openAccess
;
}
/**
* 发送消息服务
*/
@Scheduled
(
fixedRate
=
60000
)
public
void
sendMsgService
()
{
List
<
MsgBody
>
msgList
=
msgBodyService
.
list
(
Wrappers
.<
MsgBody
>
lambdaQuery
().
eq
(
MsgBody:
:
getIsSend
,
0
).
eq
(
MsgBody:
:
getIsError
,
0
));
List
<
MsgBody
>
dingtalk
=
new
ArrayList
<>();
List
<
MsgBody
>
wechat
=
new
ArrayList
<>();
List
<
MsgBody
>
email
=
new
ArrayList
<>();
List
<
MsgBody
>
sms
=
new
ArrayList
<>();
List
<
MsgBody
>
dingtalk_link
=
new
ArrayList
<>();
List
<
MsgBody
>
dingtalk_workRecord
=
new
ArrayList
<>();
for
(
MsgBody
msg:
msgList
){
switch
(
msg
.
getMsgType
()){
case
2
:
email
.
add
(
msg
);
break
;
case
4
:
sms
.
add
(
msg
);
break
;
case
32
:
wechat
.
add
(
msg
);
break
;
case
64
:
dingtalk
.
add
(
msg
);
break
;
case
65
:
dingtalk_link
.
add
(
msg
);
break
;
case
66
:
dingtalk_workRecord
.
add
(
msg
);
break
;
}
}
for
(
MsgBody
msg
:
email
){
aliEMailService
(
msg
);
}
for
(
MsgBody
msg
:
sms
){
aliSmsService
(
msg
);
}
for
(
MsgBody
msg
:
wechat
){
weChatMsgService
(
msg
);
}
for
(
MsgBody
msg
:
dingtalk
){
dingTalkMsgService
(
msg
);
}
for
(
MsgBody
msg
:
dingtalk_link
){
dingtalkLinkMsgService
(
msg
);
}
for
(
MsgBody
msg
:
dingtalk_workRecord
){
dingtalkWorkRecordService
(
msg
);
}
}
/**
* 发送钉钉消息
* @param msg
* @param tid
*/
@SneakyThrows
private
boolean
sendDingTalkMsg
(
Msg
msg
,
String
tid
){
String
authUserId
=
getAuthUserId
(
msg
.
getUserids
(),
MsgType
.
dingtalk
);
MsgTemplate
template
=
templateService
.
getById
(
tid
);
private
boolean
dingTalkMsgService
(
MsgBody
msg
){
String
msgUsers
=
getMsgUsers
(
msg
);
MsgTemplate
template
=
templateService
.
getById
(
msg
.
getTemplateId
()
);
MsgOpenAccess
openAccess
=
template
.
getOpenaccess
();
OapiMessageCorpconversationAsyncsendV2Request
req
=
new
OapiMessageCorpconversationAsyncsendV2Request
();
req
.
setAgentId
(
Long
.
parseLong
(
template
.
getTemplateId
()));
req
.
setUseridList
(
authUserId
);
req
.
setUseridList
(
msgUsers
);
OapiMessageCorpconversationAsyncsendV2Request
.
Msg
dingtalkMsg
=
new
OapiMessageCorpconversationAsyncsendV2Request
.
Msg
();
dingtalkMsg
.
setMsgtype
(
"text"
);
OapiMessageCorpconversationAsyncsendV2Request
.
Text
obj2
=
new
OapiMessageCorpconversationAsyncsendV2Request
.
Text
();
...
...
@@ -180,19 +263,19 @@ public class NotifyCoreService {
dingtalkMsg
.
setText
(
obj2
);
req
.
setMsg
(
dingtalkMsg
);
OapiMessageCorpconversationAsyncsendV2Response
rsp
=
sendMsgClient
.
execute
(
req
,
openAccess
.
getAccessToken
());
getResult
(
rsp
.
getBody
());
saveCallResult
(
msg
,
rsp
.
getBody
());
return
true
;
}
/**
* 发送阿里短信
* @param
tid
* @
param userId
* @param
msg
* @
return
*/
@SneakyThrows
private
boolean
sendAliSms
(
String
tid
,
String
userId
,
Map
templParams
){
String
authUserId
=
getAuthUserId
(
userId
,
MsgType
.
aliyun
);
MsgTemplate
template
=
templateService
.
getById
(
tid
);
private
boolean
aliSmsService
(
MsgBody
msg
){
String
msgUsers
=
getMsgUsers
(
msg
);
MsgTemplate
template
=
templateService
.
getById
(
msg
.
getTemplateId
()
);
MsgOpenAccess
openAccess
=
template
.
getOpenaccess
();
String
region
=
openAccess
.
getRegionId
();
String
accessKey
=
openAccess
.
getAccessKey
();
...
...
@@ -205,26 +288,26 @@ public class NotifyCoreService {
request
.
setSysAction
(
aliSendSmsAction
);
request
.
putQueryParameter
(
"RegionId"
,
region
);
request
.
putQueryParameter
(
"PhoneNumbers"
,
authUserId
);
request
.
putQueryParameter
(
"PhoneNumbers"
,
msgUsers
);
request
.
putQueryParameter
(
"SignName"
,
template
.
getTemplateName
());
request
.
putQueryParameter
(
"Version"
,
aliSendSmsVersion
);
request
.
putQueryParameter
(
"TemplateCode"
,
template
.
getTemplateId
());
request
.
putQueryParameter
(
"TemplateParam"
,
templParams
.
toString
());
request
.
putQueryParameter
(
"TemplateParam"
,
msg
.
getTemplateParams
());
CommonResponse
response
=
client
.
getCommonResponse
(
request
);
log
.
info
(
String
.
format
(
"成功向用户[%s]发送一条短信"
,
authUserId
));
saveCallResult
(
msg
,
new
Gson
().
toJson
(
response
));
log
.
info
(
String
.
format
(
"成功向用户[%s]发送一条短信"
,
msgUsers
));
return
true
;
}
/**
* 发送阿里邮件
* @param
tid
* @
param userId
* @param
msg
* @
return
*/
@SneakyThrows
private
boolean
sendAliEMail
(
String
tid
,
String
userId
){
String
authUserId
=
getAuthUserId
(
userId
,
MsgType
.
aliyun
);
MsgTemplate
template
=
templateService
.
getById
(
tid
);
private
boolean
aliEMailService
(
MsgBody
msg
){
String
msgUsers
=
getMsgUsers
(
msg
);
MsgTemplate
template
=
templateService
.
getById
(
msg
.
getTemplateId
());
MsgOpenAccess
openAccess
=
template
.
getOpenaccess
();
String
region
=
openAccess
.
getRegionId
();
String
accessKey
=
openAccess
.
getAccessKey
();
...
...
@@ -236,367 +319,337 @@ public class NotifyCoreService {
request
.
setAccountName
(
template
.
getTemplateId
());
request
.
setAddressType
(
1
);
request
.
setReplyToAddress
(
false
);
request
.
setToAddress
(
authUserId
);
request
.
setToAddress
(
msgUsers
);
request
.
setSubject
(
template
.
getTemplateName
());
request
.
setHtmlBody
(
template
.
getContent
());
client
.
getAcsResponse
(
request
);
log
.
info
(
String
.
format
(
"成功向用户[%s]发送一条邮件"
,
authUserId
));
SingleSendMailResponse
response
=
client
.
getAcsResponse
(
request
);
saveCallResult
(
msg
,
new
Gson
().
toJson
(
response
));
log
.
info
(
String
.
format
(
"成功向用户[%s]发送一条邮件"
,
msgUsers
));
return
true
;
}
/**
* 发送微信消息
* @param
tid
* @
param userId
* @param
msg
* @
return
*/
private
boolean
sendWeChatMsg
(
String
tid
,
String
userId
,
Map
templParams
){
String
authUserId
=
getAuthUserId
(
userId
,
MsgType
.
wechat
);
MsgTemplate
template
=
templateService
.
getById
(
tid
);
private
boolean
weChatMsgService
(
MsgBody
msg
){
String
msgUsers
=
getMsgUsers
(
msg
);
MsgTemplate
template
=
templateService
.
getById
(
msg
.
getTemplateId
()
);
MsgOpenAccess
openAccess
=
template
.
getOpenaccess
();
Map
templParams
=
new
HashMap
();
Map
paramMap
=
new
HashMap
();
paramMap
.
put
(
"template_id"
,
template
.
getTemplateId
());
paramMap
.
put
(
"touser"
,
authUserId
);
paramMap
.
put
(
"data"
,
templParams
);
paramMap
.
put
(
"touser"
,
msgUsers
);
paramMap
.
put
(
"data"
,
msg
.
getTemplateParams
()
);
JSONObject
obj
=
new
JSONObject
();
obj
.
put
(
"value"
,
"
birdle
test"
);
obj
.
put
(
"value"
,
"test"
);
templParams
.
put
(
"result"
,
obj
);
HttpEntity
request
=
new
HttpEntity
(
paramMap
);
ResponseEntity
<
String
>
result
=
restTemplate
.
postForEntity
(
String
.
format
(
weChatSendMsgApi
,
openAccess
.
getAccessToken
()),
request
,
String
.
class
);
getResult
(
result
.
getBody
());
saveCallResult
(
msg
,
result
.
getBody
());
return
true
;
}
/**
* 获取第三方用户标识
* @param userId
* 发送钉钉链接消息
* @return
*/
private
String
getAuthUserId
(
String
userId
,
MsgType
type
){
QueryWrapper
<
MsgUserAccount
>
qw
=
new
QueryWrapper
();
qw
.
eq
(
"identity_type"
,
type
);
if
(
userId
.
contains
(
","
)){
qw
.
in
(
"userid"
,
userId
.
split
(
","
));
List
<
MsgUserAccount
>
userAccounts
=
userAccountService
.
list
(
qw
);
if
(
userAccounts
==
null
||
userAccounts
.
size
()==
0
)
throw
new
BadRequestAlertException
(
"未能获取到授权用户"
,
"NotifyCoreService"
,
"sendDingTalkMsg"
);
StringBuffer
authUserIds
=
new
StringBuffer
();
for
(
MsgUserAccount
userAccount:
userAccounts
){
if
(
StringUtils
.
isEmpty
(
authUserIds
.
toString
())){
authUserIds
.
append
(
userAccount
.
getIdentifier
());
}
else
{
authUserIds
.
append
(
","
+
userAccount
.
getIdentifier
());
}
}
return
authUserIds
.
toString
();
}
else
{
qw
.
eq
(
"userid"
,
userId
);
MsgUserAccount
userAccount
=
userAccountService
.
getOne
(
qw
);
if
(
userAccount
==
null
||
StringUtils
.
isEmpty
(
userAccount
.
getIdentifier
()))
throw
new
BadRequestAlertException
(
"未能获取到授权用户"
,
"NotifyCoreService"
,
"sendDingTalkMsg"
);
return
userAccount
.
getIdentifier
();
@SneakyThrows
public
Long
dingtalkLinkMsgService
(
MsgBody
msg
){
String
msgUsers
=
getMsgUsers
(
msg
);
MsgTemplate
template
=
templateService
.
getById
(
msg
.
getTemplateId
());
if
(
template
==
null
){
throw
new
BadRequestAlertException
(
String
.
format
(
"发送链接消息失败,无法获取到[%s]对应的rt模板"
,
msg
.
getTemplateId
()),
""
,
""
);
}
MsgOpenAccess
openAccess
=
template
.
getOpenaccess
();
if
(
openAccess
==
null
){
openAccess
=
openAccessService
.
get
(
template
.
getAccessId
());
}
OapiMessageCorpconversationAsyncsendV2Request
req
=
new
OapiMessageCorpconversationAsyncsendV2Request
();
req
.
setAgentId
(
Long
.
parseLong
(
template
.
getTemplateId
()));
req
.
setUseridList
(
msgUsers
);
OapiMessageCorpconversationAsyncsendV2Request
.
Msg
dingtalkMsg
=
new
OapiMessageCorpconversationAsyncsendV2Request
.
Msg
();
dingtalkMsg
.
setMsgtype
(
"link"
);
dingtalkMsg
.
setLink
(
new
OapiMessageCorpconversationAsyncsendV2Request
.
Link
());
dingtalkMsg
.
getLink
().
setTitle
(
StringUtils
.
isEmpty
(
msg
.
getSubject
())?
template
.
getTemplateName
():
msg
.
getSubject
());
dingtalkMsg
.
getLink
().
setText
(
StringUtils
.
isEmpty
(
msg
.
getContent
())?
template
.
getContent
():
msg
.
getContent
());
dingtalkMsg
.
getLink
().
setMessageUrl
(
StringUtils
.
isEmpty
(
msg
.
getMsgLink
())?
template
.
getTemplateUrl
():
msg
.
getMsgLink
());
dingtalkMsg
.
getLink
().
setPicUrl
(
"test"
);
req
.
setMsg
(
dingtalkMsg
);
OapiMessageCorpconversationAsyncsendV2Response
rsp
=
sendMsgClient
.
execute
(
req
,
openAccess
.
getAccessToken
());
saveCallResult
(
msg
,
rsp
.
getBody
());
return
rsp
.
getTaskId
();
}
/**
*
解析接口返回结果
* @param
result
*
发送钉钉待办
* @param
msg
*/
private
void
getResult
(
String
result
){
JSONObject
resultJo
=
JSONObject
.
parseObject
(
result
);
if
(
resultJo
.
containsKey
(
"errcode"
)
&&
resultJo
.
getInteger
(
"errcode"
)!=
0
)
throw
new
BadRequestAlertException
(
String
.
format
(
"发送消息失败,%s"
,
resultJo
.
toString
()),
""
,
""
);
else
log
.
info
(
"发送消息成功"
);
@SneakyThrows
public
void
dingtalkWorkRecordService
(
MsgBody
msg
){
String
msgUsers
=
getMsgUsers
(
msg
);
OapiWorkrecordAddRequest
req
=
new
OapiWorkrecordAddRequest
();
MsgTemplate
template
=
templateService
.
getById
(
msg
.
getTemplateId
());
MsgOpenAccess
openAccess
=
template
.
getOpenaccess
();
req
.
setUserid
(
msgUsers
);
req
.
setCreateTime
(
new
Date
().
getTime
());
req
.
setTitle
(
StringUtils
.
isEmpty
(
msg
.
getSubject
())?
template
.
getTemplateName
():
msg
.
getSubject
());
req
.
setUrl
(
StringUtils
.
isEmpty
(
msg
.
getMsgLink
())?
template
.
getTemplateUrl
():
msg
.
getMsgLink
());
req
.
setPcUrl
(
StringUtils
.
isEmpty
(
msg
.
getMsgLinkPc
())?
template
.
getTemplateUrl
():
msg
.
getMsgLinkPc
());
List
<
OapiWorkrecordAddRequest
.
FormItemVo
>
list2
=
new
ArrayList
<>();
OapiWorkrecordAddRequest
.
FormItemVo
obj3
=
new
OapiWorkrecordAddRequest
.
FormItemVo
();
list2
.
add
(
obj3
);
obj3
.
setTitle
(
StringUtils
.
isEmpty
(
msg
.
getSubject
())?
template
.
getTemplateName
():
msg
.
getSubject
());
obj3
.
setContent
(
StringUtils
.
isEmpty
(
msg
.
getContent
())?
template
.
getContent
():
msg
.
getContent
());
req
.
setFormItemList
(
list2
);
OapiWorkrecordAddResponse
rsp
=
createWorkRecordClient
.
execute
(
req
,
openAccess
.
getAccessToken
());
if
(
rsp
.
isSuccess
()){
msg
.
setUserData
(
rsp
.
getRecordId
());
}
saveCallResult
(
msg
,
rsp
.
getBody
());
}
/**
*
设置新token及过期时间
* @param
openAccess
*
存储消息进消息表
* @param
msg
* @return
*/
public
MsgOpenAccess
refreshToken
(
MsgOpenAccess
openAccess
){
String
tempToken
=
null
;
switch
(
openAccess
.
getOpenType
()){
case
"wechat"
:
tempToken
=
getWeChatToken
(
openAccess
);
break
;
case
"dingtalk"
:
tempToken
=
getDingTalkToken
(
openAccess
);
break
;
public
boolean
sendMsg
(
MsgBody
msg
){
String
templateId
=
msg
.
getTemplateId
();
String
userIds
=
msg
.
getToUsers
();
List
<
MsgBody
>
msgList
=
new
ArrayList
<>();
for
(
int
msgType:
getMsgType
(
msg
.
getMsgType
())){
MsgTemplate
msgTemplate
=
getMsgTempLate
(
templateId
);
msg
.
setMsgName
(
msg
.
getSubject
());
msg
.
setTemplateId
(
msgTemplate
.
getTid
());
msg
.
setToUsers
(
userIds
);
msg
.
setMsgType
(
msgType
);
msgList
.
add
(
msg
);
}
if
(!
StringUtils
.
isEmpty
(
tempToken
)){
JSONObject
objToken
=
JSONObject
.
parseObject
(
tempToken
);
if
(
objToken
!=
null
){
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
new
Date
());
calendar
.
add
(
Calendar
.
SECOND
,
Integer
.
parseInt
(
objToken
.
getString
(
"expires_in"
)));
Date
date
=
calendar
.
getTime
();
openAccess
.
setAccessToken
(
objToken
.
getString
(
"access_token"
));
openAccess
.
setExpiresTime
(
new
Timestamp
(
date
.
getTime
()));
}
}
return
openAccess
;
if
(
msgList
.
size
()>
0
)
msgBodyService
.
createBatch
(
msgList
);
return
true
;
}
/**
*
创建模板
* @param
template
*
存储钉钉消息进消息表
* @param
msg
* @return
*/
public
boolean
createMsgTemplate
(
Template
template
){
JSONArray
templates
=
template
.
getTemplate
();
for
(
int
a
=
0
;
a
<
templates
.
size
();
a
++){
List
<
MsgOpenAccess
>
openAccesses
=
new
ArrayList
<>();
List
<
MsgTemplate
>
msgTemplates
=
new
ArrayList
<>();
MsgTemplate
msgTempl
=
JSONObject
.
toJavaObject
(
templates
.
getJSONObject
(
a
),
MsgTemplate
.
class
);
boolean
isExist
=
checkMsgTemplate
(
msgTempl
);
if
(!
isExist
){
//rt预置消息类型
Collection
<
String
>
templTypes
=
templateType
.
values
();
//创建开放平台
for
(
String
openAccessType:
getOpenAccessType
(
templTypes
)){
String
openAccessId
=
String
.
format
(
"%s-%s"
,
msgTempl
.
getTid
(),
openAccessType
);
MsgOpenAccess
openAccess
=
openAccessService
.
getById
(
openAccessId
);
if
(
openAccess
==
null
)
{
openAccess
=
new
MsgOpenAccess
();
openAccess
.
setId
(
openAccessId
);
openAccess
.
setName
(
openAccessType
);
openAccess
.
setDisabled
(
0
);
openAccess
.
setOpenType
(
openAccessType
);
openAccesses
.
add
(
openAccess
);
}
}
//创建消息模板
for
(
String
templateType
:
templTypes
){
MsgTemplate
msgTemplate
=
new
MsgTemplate
();
String
openAccessType
=
templateType
.
contains
(
"-"
)?
templateType
.
substring
(
0
,
templateType
.
indexOf
(
"-"
)):
templateType
;
msgTemplate
.
setAccessId
(
String
.
format
(
"%s-%s"
,
msgTempl
.
getTid
(),
openAccessType
));
msgTemplate
.
setOpenType
(
openAccessType
);
msgTemplate
.
setTemplateType
(
templateType
);
msgTemplate
.
setTid
(
String
.
format
(
"%s-%s"
,
msgTempl
.
getTid
(),
templateType
));
msgTemplate
.
setTemplateName
(
msgTempl
.
getTemplateName
());
msgTemplate
.
setContent
(
msgTempl
.
getContent
());
msgTemplates
.
add
(
msgTemplate
);
}
if
(
openAccesses
.
size
()>
0
)
openAccessService
.
createBatch
(
openAccesses
);
if
(
msgTemplates
.
size
()>
0
)
templateService
.
createBatch
(
msgTemplates
);
}
}
return
true
;
@SneakyThrows
public
boolean
sendDingTalkLinkMsg
(
MsgBody
msg
){
getMsgTempLate
(
msg
.
getTemplateId
());
msg
.
setMsgName
(
msg
.
getSubject
());
msg
.
setMsgType
(
65
);
return
msgBodyService
.
create
(
msg
);
}
/**
*
检查模板是否存在
* @param msg
Template
*
存储钉钉待办进消息表
* @param msg
* @return
*/
private
boolean
checkMsgTemplate
(
MsgTemplate
msgTemplate
)
{
boolean
isExist
=
false
;
if
(!
ObjectUtils
.
isEmpty
(
msgTemplate
.
getTid
())){
QueryWrapper
<
MsgOpenAccess
>
qw
=
new
QueryWrapper
();
qw
.
likeRight
(
"accessid"
,
msgTemplate
.
getTid
());
if
(
openAccessService
.
count
(
qw
)>
0
){
isExist
=
true
;
log
.
info
(
String
.
format
(
"消息模板[%s]已存在,忽略发布!"
,
msgTemplate
.
getTemplateName
()));
}
}
return
isExist
;
@SneakyThrows
public
String
createDingTalkWorkRecord
(
MsgBody
msg
){
if
(
StringUtils
.
isEmpty
(
msg
.
getToUsers
()))
throw
new
BadRequestAlertException
(
"无法获取到用户信息"
,
""
,
""
);
getMsgTempLate
(
msg
.
getTemplateId
());
msg
.
setMsgName
(
msg
.
getSubject
());
msg
.
setMsgType
(
66
);
msg
.
setMsgId
(
String
.
valueOf
(
msg
.
getDefaultKey
(
true
)));
msgBodyService
.
create
(
msg
);
return
msg
.
getMsgId
();
}
/**
*
获取开放平台
* @param templ
Types
*
创建消息模板
* @param templ
ate
* @return
*/
private
List
<
String
>
getOpenAccessType
(
Collection
<
String
>
templTypes
){
List
openAccess
=
new
ArrayList
();
if
(
templTypes
.
size
()==
0
)
return
openAccess
;
for
(
String
template:
templTypes
){
if
(
template
.
contains
(
"-"
)){
String
openAccessType
=
template
.
substring
(
0
,
template
.
indexOf
(
"-"
));
if
(!
openAccess
.
contains
(
openAccessType
)){
openAccess
.
add
(
openAccessType
);
public
synchronized
boolean
createMsgTemplate
(
Template
template
){
JSONArray
templates
=
template
.
getTemplate
();
for
(
int
a
=
0
;
a
<
templates
.
size
();
a
++){
List
<
MsgTemplate
>
newTempList
=
new
ArrayList
<>();
MsgTemplate
newTempl
=
JSONObject
.
toJavaObject
(
templates
.
getJSONObject
(
a
),
MsgTemplate
.
class
);
Collection
<
String
>
templTypes
=
templateType
.
values
();
//创建消息模板
for
(
String
templateType
:
templTypes
){
String
tid
=
String
.
format
(
"%s-%s"
,
newTempl
.
getTid
(),
templateType
);
MsgTemplate
templ
=
templateService
.
getById
(
tid
);
if
(
templ
!=
null
){
log
.
info
(
String
.
format
(
"消息模板[%s]已存在,忽略发布!"
,
tid
));
continue
;
}
MsgTemplate
msgTemplate
=
new
MsgTemplate
();
// String openAccessType=templateType.contains("-")?templateType.substring(0,templateType.indexOf("-")):templateType;
CachedBeanCopier
.
copy
(
newTempl
,
msgTemplate
);
// msgTemplate.setOpenType(openAccessType);
msgTemplate
.
setTid
(
tid
);
msgTemplate
.
setTemplateType
(
templateType
);
// msgTemplate.setAccessId(String.format("%s-%s",msgTempl.getTid(),openAccessType));
newTempList
.
add
(
msgTemplate
);
}
if
(
newTempList
.
size
()>
0
)
templateService
.
createBatch
(
newTempList
);
}
return
openAccess
;
return
true
;
}
/**
*
发送消息
* @param msg
*
完成钉钉待办
* @param msg
Id
* @return
*/
public
boolean
sendMsg
(
Msg
msg
){
String
templateId
=
msg
.
getTemplateid
();
String
userIds
=
msg
.
getUserids
();
Map
templParams
=
msg
.
getTemplparams
();
for
(
String
msgType:
getMsgType
(
msg
.
getMsgtypes
())){
MsgTemplate
msgTemplate
=
templateService
.
getById
(
templateId
+
"-"
+
msgType
);
if
(
msgTemplate
==
null
){
throw
new
BadRequestAlertException
(
String
.
format
(
"发送消息失败,无法获取到[%s]对应的rt模板"
,
templateId
),
""
,
""
);
}
else
{
switch
(
msgType
){
case
"aliyun-sms"
:
sendAliSms
(
msgTemplate
.
getTid
(),
userIds
,
templParams
==
null
?
null
:
JSONObject
.
parseObject
(
JSON
.
toJSONString
(
templParams
)));
break
;
case
"aliyun-email"
:
sendAliEMail
(
msgTemplate
.
getTid
(),
userIds
);
break
;
case
"dingtalk-msg"
:
sendDingTalkMsg
(
msg
,
msgTemplate
.
getTid
());
break
;
case
"wechat-msg"
:
sendWeChatMsg
(
msgTemplate
.
getTid
(),
userIds
,
getWechatMsgTemplParams
(
templParams
));
break
;
default
:
throw
new
BadRequestAlertException
(
String
.
format
(
"发送消息失败,尚未提供[%s]类型对应的消息服务"
,
msgType
),
""
,
""
);
}
}
@SneakyThrows
public
boolean
finishDingTalkWorkRecord
(
String
msgId
){
if
(
StringUtils
.
isEmpty
(
msgId
)){
throw
new
BadRequestAlertException
(
"无法获取到消息标识"
,
""
,
""
);
}
return
true
;
MsgBody
msg
=
msgBodyService
.
getById
(
msgId
);
if
(
msg
==
null
){
throw
new
BadRequestAlertException
(
"无法获取消息"
,
""
,
""
);
}
String
msgUsers
=
getMsgUsers
(
msg
);
MsgTemplate
template
=
templateService
.
getById
(
msg
.
getTemplateId
());
MsgOpenAccess
openAccess
=
template
.
getOpenaccess
();
OapiWorkrecordUpdateRequest
req
=
new
OapiWorkrecordUpdateRequest
();
req
.
setUserid
(
msgUsers
);
req
.
setRecordId
(
msg
.
getUserData
());
OapiWorkrecordUpdateResponse
rsp
=
finishWorkRecordClient
.
execute
(
req
,
openAccess
.
getAccessToken
());
msg
.
setUserData2
(
rsp
.
getBody
());
msgBodyService
.
update
(
msg
);
return
rsp
.
getResult
();
}
/**
* 获取
微信消息模板参数
* @param
templParams
* 获取
消息类型
* @param
msgType
* @return
*/
private
JSONObject
getWechatMsgTemplParams
(
Map
<
String
,
Object
>
templParams
){
if
(
templParams
==
null
)
return
null
;
JSONObject
params
=
new
JSONObject
();
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
templParams
.
entrySet
())
{
JSONObject
param
=
new
JSONObject
();
param
.
put
(
"value"
,
entry
.
getValue
());
params
.
put
(
entry
.
getKey
(),
param
);
private
String
getIdentityType
(
int
msgType
)
{
String
identityType
=
""
;
switch
(
msgType
){
case
2
:
identityType
=
"aliyun"
;
break
;
case
4
:
identityType
=
"aliyun"
;
break
;
case
32
:
identityType
=
"wechat"
;
break
;
case
64
:
identityType
=
"dingtalk"
;
break
;
case
65
:
identityType
=
"dingtalk"
;
break
;
case
66
:
identityType
=
"dingtalk"
;
break
;
}
return
params
;
return
identityType
;
}
/**
*
解析数值代码表获取消息类型
* @param msg
Type
*
获取消息账户
* @param msg
* @return
*/
private
List
<
String
>
getMsgType
(
int
msgType
){
List
<
String
>
useMsg
=
new
ArrayList
<>();
for
(
Map
.
Entry
<
Integer
,
String
>
msg
:
templateType
.
entrySet
()){
if
((
msgType
&
msg
.
getKey
())
==
msg
.
getKey
()){
useMsg
.
add
(
msg
.
getValue
());
}
private
String
getMsgUsers
(
MsgBody
msg
){
String
userId
=
msg
.
getToUsers
();
String
msgType
=
getIdentityType
(
msg
.
getMsgType
());
QueryWrapper
<
MsgUserAccount
>
qw
=
new
QueryWrapper
();
qw
.
eq
(
"identity_type"
,
msgType
);
if
(
userId
.
contains
(
","
)){
qw
.
in
(
"userid"
,
userId
.
split
(
","
));
List
<
MsgUserAccount
>
userAccounts
=
userAccountService
.
list
(
qw
);
if
(
userAccounts
==
null
||
userAccounts
.
size
()==
0
)
throw
new
BadRequestAlertException
(
"未能获取到授权用户"
,
"NotifyCoreService"
,
"sendDingTalkMsg"
);
StringBuffer
authUserIds
=
new
StringBuffer
();
for
(
MsgUserAccount
userAccount:
userAccounts
){
if
(
StringUtils
.
isEmpty
(
authUserIds
.
toString
())){
authUserIds
.
append
(
userAccount
.
getIdentifier
());
}
else
{
authUserIds
.
append
(
","
+
userAccount
.
getIdentifier
());
}
}
return
authUserIds
.
toString
();
}
else
{
qw
.
eq
(
"userid"
,
userId
);
MsgUserAccount
userAccount
=
userAccountService
.
getOne
(
qw
);
if
(
userAccount
==
null
||
StringUtils
.
isEmpty
(
userAccount
.
getIdentifier
()))
throw
new
BadRequestAlertException
(
"未能获取到授权用户"
,
"NotifyCoreService"
,
"sendDingTalkMsg"
);
return
userAccount
.
getIdentifier
();
}
return
useMsg
;
}
/**
*
发送钉钉链接消息
* @
return
*
解析接口返回结果
* @
param result
*/
@SneakyThrows
public
Long
sendLinkMsg
(
Msg
msg
){
String
authUserId
=
getAuthUserId
(
msg
.
getUserids
(),
MsgType
.
dingtalk
);
MsgTemplate
template
=
templateService
.
getById
(
msg
.
getTemplateid
());
if
(
template
==
null
){
throw
new
BadRequestAlertException
(
String
.
format
(
"发送链接消息失败,无法获取到[%s]对应的rt模板"
,
msg
.
getTemplateid
()),
""
,
""
);
}
MsgOpenAccess
openAccess
=
template
.
getOpenaccess
();
if
(
openAccess
==
null
){
openAccess
=
openAccessService
.
get
(
template
.
getAccessId
());
}
OapiMessageCorpconversationAsyncsendV2Request
req
=
new
OapiMessageCorpconversationAsyncsendV2Request
();
req
.
setAgentId
(
Long
.
parseLong
(
template
.
getTemplateId
()));
req
.
setUseridList
(
authUserId
);
OapiMessageCorpconversationAsyncsendV2Request
.
Msg
dingtalkMsg
=
new
OapiMessageCorpconversationAsyncsendV2Request
.
Msg
();
dingtalkMsg
.
setMsgtype
(
"link"
);
dingtalkMsg
.
setLink
(
new
OapiMessageCorpconversationAsyncsendV2Request
.
Link
());
dingtalkMsg
.
getLink
().
setTitle
(
StringUtils
.
isEmpty
(
msg
.
getTitle
())?
template
.
getTemplateName
():
msg
.
getTitle
());
dingtalkMsg
.
getLink
().
setText
(
StringUtils
.
isEmpty
(
msg
.
getContent
())?
template
.
getContent
():
msg
.
getContent
());
dingtalkMsg
.
getLink
().
setMessageUrl
(
StringUtils
.
isEmpty
(
msg
.
getUrl
())?
template
.
getTemplateUrl
():
msg
.
getUrl
());
dingtalkMsg
.
getLink
().
setPicUrl
(
"test"
);
req
.
setMsg
(
dingtalkMsg
);
OapiMessageCorpconversationAsyncsendV2Response
rsp
=
sendMsgClient
.
execute
(
req
,
openAccess
.
getAccessToken
());
getResult
(
rsp
.
getBody
());
return
rsp
.
getTaskId
();
private
void
getResult
(
String
result
){
JSONObject
resultJo
=
JSONObject
.
parseObject
(
result
);
if
(
resultJo
.
containsKey
(
"errcode"
)
&&
resultJo
.
getInteger
(
"errcode"
)!=
0
)
throw
new
BadRequestAlertException
(
String
.
format
(
"发送消息失败,%s"
,
resultJo
.
toString
()),
""
,
""
);
else
log
.
info
(
"发送消息成功"
);
}
/**
*
建立待办
*
保存接口返回结果
* @param msg
* @
return
* @
param result
*/
@SneakyThrows
public
Boolean
createWorkRecord
(
Msg
msg
){
String
authUserId
=
getAuthUserId
(
msg
.
getUserids
(),
MsgType
.
dingtalk
);
MsgTemplate
template
=
templateService
.
getById
(
msg
.
getTemplateid
()
);
if
(
template
==
null
){
throw
new
BadRequestAlertException
(
String
.
format
(
"创建待办失败,无法获取到[%s]对应的rt模板"
,
msg
.
getTemplateid
()),
""
,
"
"
);
private
void
saveCallResult
(
MsgBody
msg
,
String
result
){
JSONObject
resultJo
=
JSONObject
.
parseObject
(
result
);
if
(
resultJo
.
containsKey
(
"errcode"
)
&&
resultJo
.
getInteger
(
"errcode"
)!=
0
){
msg
.
setIsError
(
1
);
msg
.
setErrorInfo
(
resultJo
.
toString
());
log
.
info
(
"发送消息失败
"
);
}
MsgOpenAccess
openAccess
=
template
.
getOpenaccess
();
if
(
openAccess
==
null
){
openAccess
=
openAccessService
.
get
(
template
.
getAccessId
()
);
else
{
msg
.
setIsError
(
0
);
log
.
info
(
"发送消息成功"
);
}
notifyCoreService
.
createWorkRecordByUserIds
(
authUserId
,
msg
,
template
,
openAccess
);
return
true
;
msg
.
setIsSend
(
1
);
msgBodyService
.
update
(
msg
)
;
}
/**
* 异步创建待办
* @param userIds
* @param msg
* @param template
* @param openAccess
* 获取消息模板
* @param templateId
* @return
*/
@Async
@SneakyThrows
public
void
createWorkRecordByUserIds
(
String
userIds
,
Msg
msg
,
MsgTemplate
template
,
MsgOpenAccess
openAccess
){
for
(
String
userId:
userIds
.
split
(
","
)){
OapiWorkrecordAddRequest
req
=
new
OapiWorkrecordAddRequest
();
req
.
setUserid
(
userId
);
req
.
setCreateTime
(
new
Date
().
getTime
());
req
.
setTitle
(
StringUtils
.
isEmpty
(
msg
.
getTitle
())?
template
.
getTemplateName
():
msg
.
getTitle
());
req
.
setUrl
(
StringUtils
.
isEmpty
(
msg
.
getUrl
())?
template
.
getTemplateUrl
():
msg
.
getUrl
());
List
<
OapiWorkrecordAddRequest
.
FormItemVo
>
list2
=
new
ArrayList
<>();
OapiWorkrecordAddRequest
.
FormItemVo
obj3
=
new
OapiWorkrecordAddRequest
.
FormItemVo
();
list2
.
add
(
obj3
);
obj3
.
setTitle
(
StringUtils
.
isEmpty
(
msg
.
getTitle
())?
template
.
getTemplateName
():
msg
.
getTitle
());
obj3
.
setContent
(
StringUtils
.
isEmpty
(
msg
.
getContent
())?
template
.
getContent
():
msg
.
getContent
());
req
.
setFormItemList
(
list2
);
OapiWorkrecordAddResponse
rsp
=
createWorkRecordClient
.
execute
(
req
,
openAccess
.
getAccessToken
());
getResult
(
rsp
.
getBody
());
private
MsgTemplate
getMsgTempLate
(
String
templateId
){
MsgTemplate
msgTemplate
=
templateService
.
getById
(
templateId
);
if
(
msgTemplate
==
null
){
throw
new
BadRequestAlertException
(
String
.
format
(
"发送消息失败,无法获取到[%s]对应的rt模板"
,
templateId
),
""
,
""
);
}
String
openAccessId
=
msgTemplate
.
getAccessId
();
if
(
StringUtils
.
isEmpty
(
openAccessId
)){
throw
new
BadRequestAlertException
(
String
.
format
(
"发送消息失败,无法获取到消息模板[%s]对应的开放平台[%s]"
,
templateId
,
openAccessId
),
""
,
""
);
}
return
msgTemplate
;
}
/**
*
完成待办
* @param msg
*
解析数值代码表获取消息类型
* @param msg
Type
* @return
*/
@SneakyThrows
public
boolean
finishWorkRecord
(
Msg
msg
){
String
authUserId
=
getAuthUserId
(
msg
.
getUserids
(),
MsgType
.
dingtalk
);
MsgTemplate
template
=
templateService
.
getById
(
msg
.
getTemplateid
());
if
(
template
==
null
){
throw
new
BadRequestAlertException
(
String
.
format
(
"完成待办失败,无法获取到[%s]对应的rt模板"
,
msg
.
getTemplateid
()),
""
,
""
);
private
List
<
Integer
>
getMsgType
(
int
msgType
){
List
<
Integer
>
useMsg
=
new
ArrayList
<>();
for
(
Map
.
Entry
<
Integer
,
String
>
msg
:
templateType
.
entrySet
()){
if
((
msgType
&
msg
.
getKey
())
==
msg
.
getKey
()){
useMsg
.
add
(
msg
.
getKey
());
}
}
MsgOpenAccess
openAccess
=
template
.
getOpenaccess
();
OapiWorkrecordUpdateRequest
req
=
new
OapiWorkrecordUpdateRequest
();
req
.
setUserid
(
authUserId
);
req
.
setRecordId
(
msg
.
getRecordid
());
OapiWorkrecordUpdateResponse
rsp
=
finishWorkRecordClient
.
execute
(
req
,
openAccess
.
getAccessToken
());
getResult
(
rsp
.
getBody
());
return
rsp
.
getResult
();
return
useMsg
;
}
}
ibznotify-provider/ibznotify-provider-api/src/main/java/cn/ibizlab/api/config/apiSecurityConfig.java
浏览文件 @
01d85850
...
...
@@ -120,12 +120,7 @@ public class apiSecurityConfig extends WebSecurityConfigurerAdapter {
.
antMatchers
(
"/"
+
uploadpath
).
permitAll
()
.
antMatchers
(
"/"
+
previewpath
+
"/**"
).
permitAll
()
//消息发送请求
.
antMatchers
(
"/SendMsg"
).
permitAll
()
.
antMatchers
(
"/createMsgTemplate"
).
permitAll
()
.
antMatchers
(
"/trade/pagepay"
).
permitAll
()
.
antMatchers
(
"/dingtalk/sendlinkmsg"
).
permitAll
()
.
antMatchers
(
"/dingtalk/createworkrecord"
).
permitAll
()
.
antMatchers
(
"/dingtalk/finishworkrecord"
).
permitAll
()
.
antMatchers
(
"/notify/**"
).
permitAll
()
// 所有请求都需要认证
.
anyRequest
().
authenticated
()
// 防止iframe 造成跨域
...
...
ibznotify-provider/ibznotify-provider-api/src/main/java/cn/ibizlab/api/rest/extensions/NotifyCoreResource.java
浏览文件 @
01d85850
package
cn
.
ibizlab
.
api
.
rest
.
extensions
;
import
cn.ibizlab.core.extensions.domain.Msg
;
import
cn.ibizlab.api.dto.MsgBodyDTO
;
import
cn.ibizlab.api.mapping.MsgBodyMapping
;
import
cn.ibizlab.core.extensions.domain.Template
;
import
cn.ibizlab.core.extensions.service.NotifyCoreService
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -15,50 +16,53 @@ public class NotifyCoreResource {
@Autowired
NotifyCoreService
notifyCoreService
;
@Autowired
MsgBodyMapping
mapping
;
/**
* 发送工作流消息
* @param
msg
* @param
dto
* @return
*/
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/
SendM
sg"
)
public
ResponseEntity
<
Boolean
>
SendMsg
(
@Validated
@RequestBody
Msg
msg
){
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
notifyCoreService
.
sendMsg
(
m
sg
));
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/
notify/sendm
sg"
)
public
ResponseEntity
<
Boolean
>
sendMsg
(
@Validated
@RequestBody
MsgBodyDTO
dto
){
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
notifyCoreService
.
sendMsg
(
m
apping
.
toDomain
(
dto
)
));
}
/**
* 建立消息模板
* @param template
* @return
*/
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/
createMsgTemplate
"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/
notify/createmsgtempl
"
)
public
ResponseEntity
<
Boolean
>
createMsgTemplate
(
@Validated
@RequestBody
Template
template
){
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
notifyCoreService
.
createMsgTemplate
(
template
));
}
/**
* 发送钉钉链接消息
* @param
msg
* @param
dto
* @return
*/
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/dingtalk/sendlinkmsg"
)
public
ResponseEntity
<
Long
>
sendDingTalkLinkMsg
(
@RequestBody
Msg
msg
){
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
notifyCoreService
.
send
LinkMsg
(
msg
));
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/
notify/
dingtalk/sendlinkmsg"
)
public
ResponseEntity
<
Boolean
>
sendDingTalkLinkMsg
(
@RequestBody
MsgBodyDTO
dto
){
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
notifyCoreService
.
send
DingTalkLinkMsg
(
mapping
.
toDomain
(
dto
)
));
}
/**
* 创建钉钉待办
* @param
msg
* @param
dto
* @return
*/
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/dingtalk/createworkrecord"
)
public
ResponseEntity
<
Boolean
>
createDingTalkWorkRecord
(
@RequestBody
Msg
msg
){
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
notifyCoreService
.
create
WorkRecord
(
msg
));
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/
notify/
dingtalk/createworkrecord"
)
public
ResponseEntity
<
String
>
createDingTalkWorkRecord
(
@RequestBody
MsgBodyDTO
dto
){
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
notifyCoreService
.
create
DingTalkWorkRecord
(
mapping
.
toDomain
(
dto
)
));
}
/**
* 完成钉钉待办
* @param
msg
* @param
* @return
*/
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/
dingtalk/finishworkrecord
"
)
public
ResponseEntity
<
Boolean
>
finishDingTalkWorkRecord
(
@
RequestBody
Msg
msg
){
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
notifyCoreService
.
finish
WorkRecord
(
msg
));
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/
notify/dingtalk/finishworkrecord/{msgid}
"
)
public
ResponseEntity
<
Boolean
>
finishDingTalkWorkRecord
(
@
PathVariable
(
"msgid"
)
String
msgId
){
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
notifyCoreService
.
finish
DingTalkWorkRecord
(
msgId
));
}
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录