|
@@ -1,19 +1,26 @@
|
|
|
package com.qs.mp.common.utils;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.dingtalk.api.DefaultDingTalkClient;
|
|
|
+import com.dingtalk.api.DingTalkClient;
|
|
|
+import com.dingtalk.api.request.OapiRobotSendRequest;
|
|
|
+import com.dingtalk.api.response.OapiRobotSendResponse;
|
|
|
import com.qs.mp.common.enums.ServerEnvEnum;
|
|
|
import com.qs.mp.common.utils.http.OkHttpUtil;
|
|
|
+import com.taobao.api.ApiException;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
+
|
|
|
@Component
|
|
|
public class WebhookService {
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(WebhookService.class);
|
|
|
- //private String dingToken = "https://oapi.dingtalk.com/robot/send?access_token=a2f955b2c685e4449ac98fd4a41b9ba1238a6badb58aba4da9c6fc50714fc43d";
|
|
|
- //final static String alertUrl = "https://oapi.dingtalk.com/robot/send?access_token=79bd929c6cdec2150dbd2d5fdb5b4a499c9ad8137da511eab85bc7d381af9d7a";
|
|
|
+// private String dingToken = "https://oapi.dingtalk.com/robot/send?access_token=a2f955b2c685e4449ac98fd4a41b9ba1238a6badb58aba4da9c6fc50714fc43d";
|
|
|
+ final static String alertUrl = "https://oapi.dingtalk.com/robot/send?access_token=942c2e951c794fa9683acaad5b9be13e61224fd797093dd580cc65ca776977e7";
|
|
|
//final static String url = "https://oapi.dingtalk.com/robot/send?access_token=a2f955b2c685e4449ac98fd4a41b9ba1238a6badb58aba4da9c6fc50714fc43d";
|
|
|
final static String wxLogMonitorUrl = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=4275487c-8706-4676-ae21-e74db900fcb6";
|
|
|
|
|
@@ -24,10 +31,9 @@ public class WebhookService {
|
|
|
public void setEnv(String serverEnv) {
|
|
|
env = serverEnv;
|
|
|
}
|
|
|
- /*
|
|
|
- public static void sendDing(String msg) {
|
|
|
+ /*public static void sendDing(String msg) {
|
|
|
sendDing(url, msg, null);
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
public static void sendAlertDing(String msg) {
|
|
|
sendDing(alertUrl, msg, null);
|
|
@@ -53,7 +59,7 @@ public class WebhookService {
|
|
|
logger.error("钉钉消息发送失败");
|
|
|
}
|
|
|
|
|
|
- }*/
|
|
|
+ }
|
|
|
|
|
|
|
|
|
public static String sendWXRobot(String url , String msg) {
|
|
@@ -77,8 +83,10 @@ public class WebhookService {
|
|
|
* @return
|
|
|
*/
|
|
|
public static String sendLogAlertMsg(String msg) {
|
|
|
-
|
|
|
- return sendWXRobot(wxLogMonitorUrl,msg);
|
|
|
+ // 钉钉机器人发送
|
|
|
+ sendAlertDing(msg);
|
|
|
+ return "success";
|
|
|
+// return sendWXRobot(wxLogMonitorUrl,msg);
|
|
|
}
|
|
|
|
|
|
/**
|