|
|
@@ -1,5 +1,6 @@ |
|
|
|
package com.hz.pm.api.common.util; |
|
|
|
|
|
|
|
import cn.hutool.extra.spring.SpringUtil; |
|
|
|
import cn.hutool.http.HttpRequest; |
|
|
|
import cn.hutool.http.HttpResponse; |
|
|
|
import cn.hutool.http.HttpUtil; |
|
|
@@ -22,19 +23,28 @@ public class DingTalkMsgClient { |
|
|
|
private DingTalkMsgClient() { |
|
|
|
} |
|
|
|
|
|
|
|
private static final boolean DING_TALK_CLIENT_OPEN; |
|
|
|
|
|
|
|
static { |
|
|
|
DING_TALK_CLIENT_OPEN = SpringUtil.getProperty("ding-talk.client.open", Boolean.class, false); |
|
|
|
} |
|
|
|
|
|
|
|
private static final String WEB_HOOK = "https://oapi.dingtalk.com/robot/send?access_token=176a8522d9662b231f873f68725e973762d600245ce5fd5ece8ced1be7a6111c"; |
|
|
|
|
|
|
|
public static void send(String receiver, String content, Object extraParam) { |
|
|
|
if (!DING_TALK_CLIENT_OPEN) { |
|
|
|
return; |
|
|
|
} |
|
|
|
HttpRequest request = HttpUtil.createPost(WEB_HOOK); |
|
|
|
DingTalkMarkdownMsgDTO msg = new DingTalkMarkdownMsgDTO(); |
|
|
|
MarkdownDTO markdown = new MarkdownDTO(); |
|
|
|
markdown.setTitle("模拟待办发送"); |
|
|
|
StringBuilder msgObj = new StringBuilder() |
|
|
|
.append("#### 接收人\n") |
|
|
|
.append("### 接收人\n") |
|
|
|
.append(receiver) |
|
|
|
.append("\n#### 待办或提醒内容") |
|
|
|
.append("\n").append(content) |
|
|
|
.append("\n#### 拓展参数") |
|
|
|
.append("\n### 待办或提醒内容\n") |
|
|
|
.append(content) |
|
|
|
.append("\n### 拓展参数\n") |
|
|
|
.append(JSONUtil.toJsonStr(extraParam)); |
|
|
|
markdown.setText(JSONUtil.toJsonStr(msgObj)); |
|
|
|
msg.setMarkdown(markdown); |
|
|
|