import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BaseAlarmInfoVO, BaseAlarmInfoForm, BaseAlarmInfoQuery } from '@/api/dms/baseAlarmInfo/types';

/**
 * 查询报警信息列表
 * @param query
 * @returns {*}
 */

export const listBaseAlarmInfo = (query?: BaseAlarmInfoQuery): AxiosPromise<BaseAlarmInfoVO[]> => {
  return request({
    url: '/dms/baseAlarmInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询报警信息详细
 * @param alarmInfoId
 */
export const getBaseAlarmInfo = (alarmInfoId: string | number): AxiosPromise<BaseAlarmInfoVO> => {
  return request({
    url: '/dms/baseAlarmInfo/' + alarmInfoId,
    method: 'get'
  });
};

/**
 * 新增报警信息
 * @param data
 */
export const addBaseAlarmInfo = (data: BaseAlarmInfoForm) => {
  return request({
    url: '/dms/baseAlarmInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改报警信息
 * @param data
 */
export const updateBaseAlarmInfo = (data: BaseAlarmInfoForm) => {
  return request({
    url: '/dms/baseAlarmInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除报警信息
 * @param alarmInfoId
 */
export const delBaseAlarmInfo = (alarmInfoId: string | number | Array<string | number>) => {
  return request({
    url: '/dms/baseAlarmInfo/' + alarmInfoId,
    method: 'delete'
  });
};


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

/**
 * Get alarm info count
 * @param query
 * @returns {*}
 */
export const getAlarmInfoCount = (query?: BaseAlarmInfoQuery): AxiosPromise<number> => {
  return request({
    url: '/dms/baseAlarmInfo/count',
    method: 'get',
    params: query
  });
};
