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
此差异已折叠。
点击以展开。
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;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
javax.validation.constraints.NotNull
;
@RestController
public
class
NotifyCoreResource
{
...
...
@@ -61,7 +62,7 @@ public class NotifyCoreResource {
* @return
*/
@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
));
}
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录