| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- import axios from 'axios';
- import { AlertNotifyConfig } from "../../share/monitorTypes.ts";
- // 告警通知配置相关响应类型
- interface AlertNotifyConfigDataResponse {
- data: AlertNotifyConfig[];
- total: number;
- page: number;
- pageSize: number;
- }
-
- interface AlertNotifyConfigResponse {
- data: AlertNotifyConfig;
- message?: string;
- }
- // 告警通知配置API接口定义
- export const AlertNotifyConfigAPI = {
- // 获取告警通知配置
- getAlertNotifyConfig: async (params?: {
- page?: number,
- limit?: number,
- device_id?: number,
- alert_level?: string
- }): Promise<AlertNotifyConfigDataResponse> => {
- try {
- const response = await axios.get(`/alert-notify-configs`, { params });
- return response.data;
- } catch (error) {
- throw error;
- }
- },
-
- // 创建告警通知配置
- createAlertNotifyConfig: async (data: Partial<AlertNotifyConfig>): Promise<AlertNotifyConfigResponse> => {
- try {
- const response = await axios.post(`/alert-notify-configs`, data);
- return response.data;
- } catch (error) {
- throw error;
- }
- },
-
- // 更新告警通知配置
- updateAlertNotifyConfig: async (id: number, data: Partial<AlertNotifyConfig>): Promise<AlertNotifyConfigResponse> => {
- try {
- const response = await axios.put(`/alert-notify-configs/${id}`, data);
- return response.data;
- } catch (error) {
- throw error;
- }
- },
-
- // 删除告警通知配置
- deleteAlertNotifyConfig: async (id: number): Promise<AlertNotifyConfigResponse> => {
- try {
- const response = await axios.delete(`/alert-notify-configs/${id}`);
- return response.data;
- } catch (error) {
- throw error;
- }
- }
- };
|