import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AlarmVO, AlarmForm, AlarmQuery } from '@/api/equipment/alarm/types';

/**
 * 查询设备告警列表
 * @param query
 * @returns {*}
 */

export const listAlarm = (query?: AlarmQuery): AxiosPromise<AlarmVO[]> => {
  return request({
    url: 'api/equipment/alarm/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询设备告警详细
 * @param id
 */
export const getAlarm = (id: string | number): AxiosPromise<AlarmVO> => {
  return request({
    url: '/equipment/alarm/' + id,
    method: 'get'
  });
};

/**
 * 新增设备告警
 * @param data
 */
export const addAlarm = (data: AlarmForm) => {
  return request({
    url: '/equipment/alarm',
    method: 'post',
    data: data
  });
};

/**
 * 修改设备告警
 * @param data
 */
export const updateAlarm = (data: AlarmForm) => {
  return request({
    url: '/equipment/alarm',
    method: 'put',
    data: data
  });
};

/**
 * 删除设备告警
 * @param id
 */
export const delAlarm = (id: string | number | Array<string | number>) => {
  return request({
    url: '/equipment/alarm/' + id,
    method: 'delete'
  });
};
