import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AlarmRuleVO, AlarmRuleForm, AlarmRuleQuery } from '@/api/dms/alarmRule/types';

/**
 * 查询报警规则列表
 * @param query
 * @returns {*}
 */

export const listAlarmRule = (query?: AlarmRuleQuery): AxiosPromise<AlarmRuleVO[]> => {
  return request({
    url: '/dms/alarmRule/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询报警规则详细
 * @param alarmRuleId
 */
export const getAlarmRule = (alarmRuleId: string | number): AxiosPromise<AlarmRuleVO> => {
  return request({
    url: '/dms/alarmRule/' + alarmRuleId,
    method: 'get'
  });
};

/**
 * 新增报警规则
 * @param data
 */
export const addAlarmRule = (data: AlarmRuleForm) => {
  return request({
    url: '/dms/alarmRule',
    method: 'post',
    data: data
  });
};

/**
 * 修改报警规则
 * @param data
 */
export const updateAlarmRule = (data: AlarmRuleForm) => {
  return request({
    url: '/dms/alarmRule',
    method: 'put',
    data: data
  });
};

/**
 * 删除报警规则
 * @param alarmRuleId
 */
export const delAlarmRule = (alarmRuleId: string | number | Array<string | number>) => {
  return request({
    url: '/dms/alarmRule/' + alarmRuleId,
    method: 'delete'
  });
};


/**
 * 下拉框查询报警规则列表
 * @param query
 * @returns {*}
 */
export function getBaseAlarmRuleList(query) {
  return request({
    url: '/dms/alarmRule/getBaseAlarmRuleList',
    method: 'get',
    params: query
  });
};
