|
2 | 2 |
|
3 | 3 | ### 1. 概述
|
4 | 4 |
|
5 |
| -tio-boot 内置了消息通知组件,用户发送消息到 企业微信群 |
| 5 | +tio-boot 内置了消息通知组件,用户发送消息到 微信企业群 飞书企业群 等等 |
6 | 6 | 本文档提供了一个通知组件的使用指南,介绍通过不同的方式发送通知,比如发送文本消息或者发送预警信息。它支持自定义通知方式,用户可以通过实现特定的接口来集成不同的通知服务。
|
7 | 7 |
|
8 | 8 | 添加依赖
|
@@ -45,11 +45,45 @@ NotificationUtils.sendTextMsg("您的消息内容");
|
45 | 45 | 要发送预警信息,可以使用`NotificationUtils.sendWarm`方法:
|
46 | 46 |
|
47 | 47 | ```java
|
48 |
| -String warningName = "警告名称"; |
49 |
| -String level = "警告级别"; |
50 |
| -String deviceName = "设备名称"; |
51 |
| -String content = "警告内容"; |
52 |
| -NotificationUtils.sendWarm(warningName, level, deviceName, content); |
| 48 | +package com.imaginix.kimi.service.monitoring; |
| 49 | + |
| 50 | +import java.io.IOException; |
| 51 | +import java.util.Date; |
| 52 | + |
| 53 | +import org.junit.Test; |
| 54 | + |
| 55 | +import com.litongjava.tio.utils.environment.EnvironmentUtils; |
| 56 | +import com.litongjava.tio.utils.notification.NotifactionWarmModel; |
| 57 | +import com.litongjava.tio.utils.notification.NotificationUtils; |
| 58 | + |
| 59 | +import lombok.Cleanup; |
| 60 | +import okhttp3.Response; |
| 61 | + |
| 62 | +public class MonitoringNotificationTest { |
| 63 | + |
| 64 | + @Test |
| 65 | + public void test() { |
| 66 | + EnvironmentUtils.load("app.properties"); |
| 67 | + String appGroupName = "imaginix"; |
| 68 | + String appName = "kimi-service-monitoring"; |
| 69 | + String warningName = "警告名称"; |
| 70 | + String level = "警告级别"; |
| 71 | + String deviceName = "设备名称"; |
| 72 | + String content = "警告内容"; |
| 73 | + Date time = new Date(); |
| 74 | + |
| 75 | + NotifactionWarmModel notifactionWarmModel = new NotifactionWarmModel(appGroupName, appName, warningName, level, |
| 76 | + deviceName, content, time); |
| 77 | + |
| 78 | + try { |
| 79 | + @Cleanup |
| 80 | + Response response = NotificationUtils.sendWarm(notifactionWarmModel); |
| 81 | + System.out.println(response.body().string()); |
| 82 | + } catch (IOException e) { |
| 83 | + e.printStackTrace(); |
| 84 | + } |
| 85 | + } |
| 86 | +} |
53 | 87 | ```
|
54 | 88 |
|
55 | 89 | ### 4. 自定义通知工厂
|
|
0 commit comments