alert_handle.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import axios from 'axios';
  2. import { AlertHandleLog } from "../../share/monitorTypes.ts";
  3. // 告警处理相关响应类型
  4. interface AlertHandleDataResponse {
  5. data: AlertHandleLog[];
  6. total: number;
  7. page: number;
  8. pageSize: number;
  9. }
  10. interface AlertHandleResponse {
  11. data: AlertHandleLog;
  12. message?: string;
  13. }
  14. // 告警处理API接口定义
  15. export const AlertHandleAPI = {
  16. // 获取告警处理数据
  17. getAlertHandleData: async (params?: {
  18. page?: number,
  19. limit?: number,
  20. alert_id?: number,
  21. handle_type?: string,
  22. start_time?: string,
  23. end_time?: string
  24. }): Promise<AlertHandleDataResponse> => {
  25. try {
  26. const response = await axios.get(`/alert-handles`, { params });
  27. return response.data;
  28. } catch (error) {
  29. throw error;
  30. }
  31. },
  32. // 获取单个告警处理数据
  33. getAlertHandle: async (id: number): Promise<AlertHandleResponse> => {
  34. try {
  35. const response = await axios.get(`/alert-handles/${id}`);
  36. return response.data;
  37. } catch (error) {
  38. throw error;
  39. }
  40. },
  41. // 创建告警处理数据
  42. createAlertHandle: async (data: Partial<AlertHandleLog>) => {
  43. try {
  44. const response = await axios.post(`/alert-handles`, data);
  45. return response.data;
  46. } catch (error) {
  47. throw error;
  48. }
  49. },
  50. // 更新告警处理数据
  51. updateAlertHandle: async (id: number, data: Partial<AlertHandleLog>) => {
  52. try {
  53. const response = await axios.put(`/alert-handles/${id}`, data);
  54. return response.data;
  55. } catch (error) {
  56. throw error;
  57. }
  58. },
  59. // 删除告警处理数据
  60. deleteAlertHandle: async (id: number) => {
  61. try {
  62. const response = await axios.delete(`/alert-handles/${id}`);
  63. return response.data;
  64. } catch (error) {
  65. throw error;
  66. }
  67. }
  68. };