Browse Source

modify:

1. 测试环境钉钉机器人消息增加开关;
tags/24102401
WendyYang 1 month ago
parent
commit
395e657843
2 changed files with 19 additions and 5 deletions
  1. +14
    -4
      hz-pm-api/src/main/java/com/hz/pm/api/common/util/DingTalkMsgClient.java
  2. +5
    -1
      hz-pm-api/src/main/resources/application-dev.yml

+ 14
- 4
hz-pm-api/src/main/java/com/hz/pm/api/common/util/DingTalkMsgClient.java View File

@@ -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);


+ 5
- 1
hz-pm-api/src/main/resources/application-dev.yml View File

@@ -234,4 +234,8 @@ early-warning-without-submit:
open: false
major-project-eval:
open: true
cron: 0 0/2 8-20 * * ?
cron: 0 0/2 8-20 * * ?

ding-talk:
client:
open: true

Loading…
Cancel
Save