Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibznotify
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibznotify
提交
35d4ca09
提交
35d4ca09
编写于
9月 29, 2020
作者:
zhouweidong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
补充agentid及异常处理
上级
07cfa742
变更
4
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
266 行增加
和
120 行删除
+266
-120
DingTalkHelper.java
...ava/cn/ibizlab/core/extensions/helper/DingTalkHelper.java
+136
-0
NotifyCoreService.java
...cn/ibizlab/core/extensions/service/NotifyCoreService.java
+115
-119
20200929130759_changelog.xml
...esources/liquibase/changelog/20200929130759_changelog.xml
+13
-0
NotifyCoreResource.java
...va/cn/ibizlab/api/rest/extensions/NotifyCoreResource.java
+2
-1
未找到文件。
ibznotify-core/src/main/java/cn/ibizlab/core/extensions/helper/DingTalkHelper.java
0 → 100644
浏览文件 @
35d4ca09
package
cn
.
ibizlab
.
core
.
extensions
.
helper
;
import
com.dingtalk.api.DefaultDingTalkClient
;
import
com.dingtalk.api.DingTalkClient
;
import
com.dingtalk.api.request.OapiMessageCorpconversationAsyncsendV2Request
;
import
com.dingtalk.api.request.OapiWorkrecordAddRequest
;
import
com.dingtalk.api.request.OapiWorkrecordUpdateRequest
;
import
com.dingtalk.api.response.OapiMessageCorpconversationAsyncsendV2Response
;
import
com.dingtalk.api.response.OapiWorkrecordAddResponse
;
import
com.dingtalk.api.response.OapiWorkrecordUpdateResponse
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
/**
* 钉钉api辅助类
*/
public
class
DingTalkHelper
{
/**
* 钉钉获取token api
*/
private
static
final
String
dingTalkTokenApi
=
"https://oapi.dingtalk.com/gettoken"
;
/**
* 钉钉发送消息api
*/
private
static
final
String
dingTalkSendMsgApi
=
"https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2"
;
/**
* 钉钉创建待办api
*/
private
static
final
String
dingTalkCreateWorkRecordApi
=
"https://oapi.dingtalk.com/topapi/workrecord/add"
;
/**
* 钉钉完成待办api
*/
private
static
final
String
dingTalkFinishWorkRecordApi
=
"https://oapi.dingtalk.com/topapi/workrecord/update"
;
private
static
DingTalkClient
sendMsgClient
;
private
static
DingTalkClient
createWorkRecordClient
;
private
static
DingTalkClient
finishWorkRecordClient
;
private
static
DingTalkClient
getTokenClient
;
static
{
getTokenClient
=
new
DefaultDingTalkClient
(
dingTalkTokenApi
);
sendMsgClient
=
new
DefaultDingTalkClient
(
dingTalkSendMsgApi
);
createWorkRecordClient
=
new
DefaultDingTalkClient
(
dingTalkCreateWorkRecordApi
);
finishWorkRecordClient
=
new
DefaultDingTalkClient
(
dingTalkFinishWorkRecordApi
);
}
/**
* 发送工作消息通知
* @param agentId
* @param users
* @param content
* @param accessToken
*/
public
static
String
sendWorkNotifyMsg
(
Long
agentId
,
String
users
,
String
content
,
String
accessToken
)
throws
Exception
{
OapiMessageCorpconversationAsyncsendV2Request
req
=
new
OapiMessageCorpconversationAsyncsendV2Request
();
req
.
setAgentId
(
agentId
);
req
.
setUseridList
(
users
);
OapiMessageCorpconversationAsyncsendV2Request
.
Msg
dingtalkMsg
=
new
OapiMessageCorpconversationAsyncsendV2Request
.
Msg
();
dingtalkMsg
.
setMsgtype
(
"text"
);
OapiMessageCorpconversationAsyncsendV2Request
.
Text
obj2
=
new
OapiMessageCorpconversationAsyncsendV2Request
.
Text
();
obj2
.
setContent
(
content
);
dingtalkMsg
.
setText
(
obj2
);
req
.
setMsg
(
dingtalkMsg
);
OapiMessageCorpconversationAsyncsendV2Response
rsp
=
sendMsgClient
.
execute
(
req
,
accessToken
);
return
rsp
.
getBody
();
}
/**
* 发送链接消息
* @param agentId
* @param users
* @param title
* @param content
* @param msgUrl
* @param accessToken
* @return
*/
public
static
String
sendLinkMsg
(
Long
agentId
,
String
users
,
String
title
,
String
content
,
String
msgUrl
,
String
picUrl
,
String
accessToken
)
throws
Exception
{
OapiMessageCorpconversationAsyncsendV2Request
req
=
new
OapiMessageCorpconversationAsyncsendV2Request
();
req
.
setAgentId
(
agentId
);
req
.
setUseridList
(
users
);
OapiMessageCorpconversationAsyncsendV2Request
.
Msg
dingTalkMsg
=
new
OapiMessageCorpconversationAsyncsendV2Request
.
Msg
();
dingTalkMsg
.
setMsgtype
(
"link"
);
dingTalkMsg
.
setLink
(
new
OapiMessageCorpconversationAsyncsendV2Request
.
Link
());
dingTalkMsg
.
getLink
().
setTitle
(
title
);
dingTalkMsg
.
getLink
().
setText
(
content
);
dingTalkMsg
.
getLink
().
setMessageUrl
(
msgUrl
);
dingTalkMsg
.
getLink
().
setPicUrl
(
msgUrl
);
req
.
setMsg
(
dingTalkMsg
);
OapiMessageCorpconversationAsyncsendV2Response
rsp
=
sendMsgClient
.
execute
(
req
,
accessToken
);
return
rsp
.
getBody
();
}
/**
* 创建待办
* @param user
* @param title
* @param content
* @param msgUrl
* @param pcUrl
* @param accessToken
* @return
*/
public
static
OapiWorkrecordAddResponse
createWorkRecord
(
String
user
,
String
title
,
String
content
,
String
msgUrl
,
String
pcUrl
,
String
accessToken
)
throws
Exception
{
OapiWorkrecordAddRequest
req
=
new
OapiWorkrecordAddRequest
();
req
.
setUserid
(
user
);
req
.
setCreateTime
(
new
Date
().
getTime
());
req
.
setTitle
(
title
);
req
.
setUrl
(
msgUrl
);
req
.
setPcUrl
(
pcUrl
);
List
<
OapiWorkrecordAddRequest
.
FormItemVo
>
list2
=
new
ArrayList
<>();
OapiWorkrecordAddRequest
.
FormItemVo
obj3
=
new
OapiWorkrecordAddRequest
.
FormItemVo
();
list2
.
add
(
obj3
);
obj3
.
setTitle
(
title
);
obj3
.
setContent
(
content
);
req
.
setFormItemList
(
list2
);
OapiWorkrecordAddResponse
rsp
=
createWorkRecordClient
.
execute
(
req
,
accessToken
);
return
rsp
;
}
/**
* 完成待办
* @param user
* @param recordId
* @param accessToken
* @return
*/
public
static
String
finishWorkRecord
(
String
user
,
String
recordId
,
String
accessToken
)
throws
Exception
{
OapiWorkrecordUpdateRequest
req
=
new
OapiWorkrecordUpdateRequest
();
req
.
setUserid
(
user
);
req
.
setRecordId
(
recordId
);
OapiWorkrecordUpdateResponse
rsp
=
finishWorkRecordClient
.
execute
(
req
,
accessToken
);
return
rsp
.
getBody
();
}
}
ibznotify-core/src/main/java/cn/ibizlab/core/extensions/service/NotifyCoreService.java
浏览文件 @
35d4ca09
package
cn
.
ibizlab
.
core
.
extensions
.
service
;
package
cn
.
ibizlab
.
core
.
extensions
.
service
;
import
cn.ibizlab.core.extensions.domain.Template
;
import
cn.ibizlab.core.extensions.domain.Template
;
import
cn.ibizlab.core.extensions.helper.DingTalkHelper
;
import
cn.ibizlab.core.notify.domain.MsgBody
;
import
cn.ibizlab.core.notify.domain.MsgBody
;
import
cn.ibizlab.core.notify.domain.MsgOpenAccess
;
import
cn.ibizlab.core.notify.domain.MsgOpenAccess
;
import
cn.ibizlab.core.notify.domain.MsgTemplate
;
import
cn.ibizlab.core.notify.domain.MsgTemplate
;
...
@@ -237,10 +238,10 @@ public class NotifyCoreService {
...
@@ -237,10 +238,10 @@ public class NotifyCoreService {
dingTalkMsgService
(
msg
);
dingTalkMsgService
(
msg
);
}
}
for
(
MsgBody
msg
:
dingtalk_link
){
for
(
MsgBody
msg
:
dingtalk_link
){
ding
t
alkLinkMsgService
(
msg
);
ding
T
alkLinkMsgService
(
msg
);
}
}
for
(
MsgBody
msg
:
dingtalk_workRecord
){
for
(
MsgBody
msg
:
dingtalk_workRecord
){
ding
t
alkWorkRecordService
(
msg
);
ding
T
alkWorkRecordService
(
msg
);
}
}
}
}
...
@@ -248,22 +249,81 @@ public class NotifyCoreService {
...
@@ -248,22 +249,81 @@ public class NotifyCoreService {
* 发送钉钉消息
* 发送钉钉消息
* @param msg
* @param msg
*/
*/
@SneakyThrows
private
void
dingTalkMsgService
(
MsgBody
msg
){
private
boolean
dingTalkMsgService
(
MsgBody
msg
){
try
{
String
msgUsers
=
getMsgUsers
(
msg
);
String
msgUsers
=
getMsgUsers
(
msg
);
MsgTemplate
template
=
templateService
.
getById
(
msg
.
getTemplateId
());
MsgTemplate
template
=
templateService
.
getById
(
msg
.
getTemplateId
());
MsgOpenAccess
openAccess
=
template
.
getOpenaccess
();
MsgOpenAccess
openAccess
=
template
.
getOpenaccess
();
OapiMessageCorpconversationAsyncsendV2Request
req
=
new
OapiMessageCorpconversationAsyncsendV2Request
();
String
result
=
DingTalkHelper
.
sendWorkNotifyMsg
(
openAccess
.
getAgentId
(),
msgUsers
,
msg
.
getContent
(),
openAccess
.
getAccessToken
());
req
.
setAgentId
(
Long
.
parseLong
(
template
.
getTemplateId
()));
saveCallResult
(
msg
,
result
);
req
.
setUseridList
(
msgUsers
);
}
catch
(
Exception
e
)
{
OapiMessageCorpconversationAsyncsendV2Request
.
Msg
dingtalkMsg
=
new
OapiMessageCorpconversationAsyncsendV2Request
.
Msg
();
log
.
error
(
"发送[{}]消息失败,失败原因为:[{}]"
,
msg
.
getMsgId
(),
e
);
dingtalkMsg
.
setMsgtype
(
"text"
);
saveErrorResult
(
msg
,
e
.
getMessage
());
OapiMessageCorpconversationAsyncsendV2Request
.
Text
obj2
=
new
OapiMessageCorpconversationAsyncsendV2Request
.
Text
();
}
obj2
.
setContent
(
StringUtils
.
isEmpty
(
msg
.
getContent
())?
template
.
getContent
():
msg
.
getContent
());
}
dingtalkMsg
.
setText
(
obj2
);
req
.
setMsg
(
dingtalkMsg
);
/**
OapiMessageCorpconversationAsyncsendV2Response
rsp
=
sendMsgClient
.
execute
(
req
,
openAccess
.
getAccessToken
());
* 发送钉钉链接消息
saveCallResult
(
msg
,
rsp
.
getBody
());
* @return
*/
public
void
dingTalkLinkMsgService
(
MsgBody
msg
){
try
{
String
msgUsers
=
getMsgUsers
(
msg
);
MsgTemplate
template
=
getTempLate
(
msg
.
getTemplateId
());
MsgOpenAccess
openAccess
=
getOpenAccess
(
template
.
getAccessId
());
String
result
=
DingTalkHelper
.
sendLinkMsg
(
openAccess
.
getAgentId
(),
msgUsers
,
msg
.
getSubject
(),
msg
.
getContent
(),
msg
.
getMsgLink
(),
msg
.
getMsgLink
(),
openAccess
.
getAccessToken
());
saveCallResult
(
msg
,
result
);
}
catch
(
Exception
e
)
{
log
.
error
(
"发送[{}]消息失败,失败原因为:[{}]"
,
msg
.
getMsgId
(),
e
);
saveErrorResult
(
msg
,
e
.
getMessage
());
}
}
/**
* 发送钉钉待办
* @param msg
*/
public
void
dingTalkWorkRecordService
(
MsgBody
msg
){
try
{
String
msgUser
=
getMsgUsers
(
msg
);
MsgTemplate
template
=
getTempLate
(
msg
.
getTemplateId
());
MsgOpenAccess
openAccess
=
getOpenAccess
(
template
.
getAccessId
());
OapiWorkrecordAddResponse
rsp
=
DingTalkHelper
.
createWorkRecord
(
msgUser
,
msg
.
getSubject
(),
msg
.
getContent
(),
msg
.
getMsgLink
(),
msg
.
getMsgLinkPc
(),
openAccess
.
getAccessToken
());
if
(
rsp
.
isSuccess
()){
msg
.
setUserData
(
rsp
.
getRecordId
());
}
saveCallResult
(
msg
,
rsp
.
getBody
());
}
catch
(
Exception
e
)
{
log
.
error
(
"创建[{}]工作待办失败,失败原因为:[{}]"
,
msg
.
getMsgId
(),
e
);
saveErrorResult
(
msg
,
e
.
getMessage
());
}
}
/**
* 完成钉钉待办
* @param msgId
* @return
*/
public
boolean
finishDingTalkWorkRecord
(
String
msgId
){
String
result
;
MsgBody
msg
=
null
;
try
{
msg
=
msgBodyService
.
getById
(
msgId
);
if
(
msg
==
null
){
throw
new
BadRequestAlertException
(
String
.
format
(
"无法获取到[%s]待办信息"
,
msgId
),
""
,
""
);
}
String
msgUser
=
getMsgUsers
(
msg
);
MsgTemplate
template
=
getTempLate
(
msg
.
getTemplateId
());
MsgOpenAccess
openAccess
=
getOpenAccess
(
template
.
getAccessId
());
result
=
DingTalkHelper
.
finishWorkRecord
(
msgUser
,
msg
.
getUserData
(),
openAccess
.
getAccessToken
());
}
catch
(
Exception
e
)
{
result
=
String
.
format
(
"完成[{}]工作待办失败,失败原因为:[{}]"
,
msgId
,
e
);
log
.
error
(
result
);
}
if
(
msg
!=
null
){
msg
.
setUserData2
(
result
);
msgBodyService
.
update
(
msg
);
}
return
true
;
return
true
;
}
}
...
@@ -352,65 +412,6 @@ public class NotifyCoreService {
...
@@ -352,65 +412,6 @@ public class NotifyCoreService {
return
true
;
return
true
;
}
}
/**
* 发送钉钉链接消息
* @return
*/
@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 msg
*/
@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
());
}
/**
/**
* 存储消息进消息表
* 存储消息进消息表
* @param msg
* @param msg
...
@@ -421,7 +422,7 @@ public class NotifyCoreService {
...
@@ -421,7 +422,7 @@ public class NotifyCoreService {
String
userIds
=
msg
.
getToUsers
();
String
userIds
=
msg
.
getToUsers
();
List
<
MsgBody
>
msgList
=
new
ArrayList
<>();
List
<
MsgBody
>
msgList
=
new
ArrayList
<>();
for
(
int
msgType:
getMsgType
(
msg
.
getMsgType
())){
for
(
int
msgType:
getMsgType
(
msg
.
getMsgType
())){
MsgTemplate
msgTemplate
=
get
Msg
TempLate
(
templateId
);
MsgTemplate
msgTemplate
=
getTempLate
(
templateId
);
msg
.
setMsgName
(
msg
.
getSubject
());
msg
.
setMsgName
(
msg
.
getSubject
());
msg
.
setTemplateId
(
msgTemplate
.
getTid
());
msg
.
setTemplateId
(
msgTemplate
.
getTid
());
msg
.
setToUsers
(
userIds
);
msg
.
setToUsers
(
userIds
);
...
@@ -440,7 +441,7 @@ public class NotifyCoreService {
...
@@ -440,7 +441,7 @@ public class NotifyCoreService {
*/
*/
@SneakyThrows
@SneakyThrows
public
boolean
sendDingTalkLinkMsg
(
MsgBody
msg
){
public
boolean
sendDingTalkLinkMsg
(
MsgBody
msg
){
get
Msg
TempLate
(
msg
.
getTemplateId
());
getTempLate
(
msg
.
getTemplateId
());
msg
.
setMsgName
(
msg
.
getSubject
());
msg
.
setMsgName
(
msg
.
getSubject
());
msg
.
setMsgType
(
65
);
msg
.
setMsgType
(
65
);
return
msgBodyService
.
create
(
msg
);
return
msgBodyService
.
create
(
msg
);
...
@@ -455,7 +456,7 @@ public class NotifyCoreService {
...
@@ -455,7 +456,7 @@ public class NotifyCoreService {
public
String
createDingTalkWorkRecord
(
MsgBody
msg
){
public
String
createDingTalkWorkRecord
(
MsgBody
msg
){
if
(
StringUtils
.
isEmpty
(
msg
.
getToUsers
()))
if
(
StringUtils
.
isEmpty
(
msg
.
getToUsers
()))
throw
new
BadRequestAlertException
(
"无法获取到用户信息"
,
""
,
""
);
throw
new
BadRequestAlertException
(
"无法获取到用户信息"
,
""
,
""
);
get
Msg
TempLate
(
msg
.
getTemplateId
());
getTempLate
(
msg
.
getTemplateId
());
msg
.
setMsgName
(
msg
.
getSubject
());
msg
.
setMsgName
(
msg
.
getSubject
());
msg
.
setMsgType
(
66
);
msg
.
setMsgType
(
66
);
msg
.
setMsgId
(
String
.
valueOf
(
msg
.
getDefaultKey
(
true
)));
msg
.
setMsgId
(
String
.
valueOf
(
msg
.
getDefaultKey
(
true
)));
...
@@ -498,32 +499,6 @@ public class NotifyCoreService {
...
@@ -498,32 +499,6 @@ public class NotifyCoreService {
return
true
;
return
true
;
}
}
/**
* 完成钉钉待办
* @param msgId
* @return
*/
@SneakyThrows
public
boolean
finishDingTalkWorkRecord
(
String
msgId
){
if
(
StringUtils
.
isEmpty
(
msgId
)){
throw
new
BadRequestAlertException
(
"无法获取到消息标识"
,
""
,
""
);
}
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 msgType
* @param msgType
...
@@ -621,20 +596,15 @@ public class NotifyCoreService {
...
@@ -621,20 +596,15 @@ public class NotifyCoreService {
}
}
/**
/**
*
获取消息模板
*
存储错误信息
* @param
templateId
* @param
msg
* @
return
* @
param errInfo
*/
*/
private
MsgTemplate
getMsgTempLate
(
String
templateId
){
private
void
saveErrorResult
(
MsgBody
msg
,
String
errInfo
){
MsgTemplate
msgTemplate
=
templateService
.
getById
(
templateId
);
msg
.
setIsError
(
1
);
if
(
msgTemplate
==
null
){
msg
.
setErrorInfo
(
errInfo
);
throw
new
BadRequestAlertException
(
String
.
format
(
"发送消息失败,无法获取到[%s]对应的rt模板"
,
templateId
),
""
,
""
);
msg
.
setIsSend
(
1
);
}
msgBodyService
.
update
(
msg
);
String
openAccessId
=
msgTemplate
.
getAccessId
();
if
(
StringUtils
.
isEmpty
(
openAccessId
)){
throw
new
BadRequestAlertException
(
String
.
format
(
"发送消息失败,无法获取到消息模板[%s]对应的开放平台[%s]"
,
templateId
,
openAccessId
),
""
,
""
);
}
return
msgTemplate
;
}
}
/**
/**
...
@@ -652,4 +622,30 @@ public class NotifyCoreService {
...
@@ -652,4 +622,30 @@ public class NotifyCoreService {
return
useMsg
;
return
useMsg
;
}
}
/**
* 获取消息模板
* @param templateId
* @return
*/
private
MsgTemplate
getTempLate
(
String
templateId
){
MsgTemplate
template
=
templateService
.
getById
(
templateId
);
if
(
template
==
null
){
throw
new
BadRequestAlertException
(
String
.
format
(
"发送链接消息失败,无法获取到[%s]对应的rt模板"
,
templateId
),
""
,
""
);
}
return
template
;
}
/**
* 获取开放平台
* @param openAccessId
* @return
*/
private
MsgOpenAccess
getOpenAccess
(
String
openAccessId
){
MsgOpenAccess
openAccess
=
openAccessService
.
getById
(
openAccessId
);
if
(
openAccess
==
null
){
throw
new
BadRequestAlertException
(
String
.
format
(
"发送链接消息失败,无法获取到[%s]对应的开放平台"
,
openAccessId
),
""
,
""
);
}
return
openAccess
;
}
}
}
ibznotify-core/src/main/resources/liquibase/changelog/20200929130759_changelog.xml
0 → 100644
浏览文件 @
35d4ca09
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog
xmlns=
"http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext=
"http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:pro=
"http://www.liquibase.org/xml/ns/pro"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-3.8.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd"
>
<changeSet
author=
"mac (generated)"
id=
"1730281588526-1"
>
<preConditions
onFail=
"MARK_RAN"
>
<not>
<columnExists
tableName=
"IBZOPENACCESS"
columnName=
"AGENT_ID"
/>
</not>
</preConditions>
<addColumn
tableName=
"IBZOPENACCESS"
>
<column
name=
"AGENT_ID"
type=
"BIGINT"
/>
</addColumn>
</changeSet>
</databaseChangeLog>
ibznotify-provider/ibznotify-provider-api/src/main/java/cn/ibizlab/api/rest/extensions/NotifyCoreResource.java
浏览文件 @
35d4ca09
...
@@ -9,6 +9,7 @@ import org.springframework.http.HttpStatus;
...
@@ -9,6 +9,7 @@ import org.springframework.http.HttpStatus;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.validation.constraints.NotNull
;
@RestController
@RestController
public
class
NotifyCoreResource
{
public
class
NotifyCoreResource
{
...
@@ -61,7 +62,7 @@ public class NotifyCoreResource {
...
@@ -61,7 +62,7 @@ public class NotifyCoreResource {
* @return
* @return
*/
*/
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/notify/dingtalk/finishworkrecord/{msgid}"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/notify/dingtalk/finishworkrecord/{msgid}"
)
public
ResponseEntity
<
Boolean
>
finishDingTalkWorkRecord
(
@PathVariable
(
"msgid"
)
String
msgId
){
public
ResponseEntity
<
Boolean
>
finishDingTalkWorkRecord
(
@
Validated
@NotNull
@
PathVariable
(
"msgid"
)
String
msgId
){
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
notifyCoreService
.
finishDingTalkWorkRecord
(
msgId
));
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
notifyCoreService
.
finishDingTalkWorkRecord
(
msgId
));
}
}
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录