import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AlarmNotifyGroupVO, AlarmNotifyGroupForm, AlarmNotifyGroupId, AlarmNotifyGroupIds, AlarmNotifyGroupQuery } from '@/api/ems/base/alarmNotifyGroup/types';

/**
 * 查询报警通知组主表列表
 * @param query
 * @returns {*}
 */

export const listAlarmNotifyGroup = (query?: AlarmNotifyGroupQuery): AxiosPromise<AlarmNotifyGroupVO[]> => {
  return request({
    url: '/ems/base/alarmNotifyGroup/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询报警通知组全量列表
 * 这里单独收口成选项接口，避免每个表单页都自己拼大分页参数。
 */
export const listAlarmNotifyGroupAll = (): AxiosPromise<AlarmNotifyGroupVO[]> => {
  return request({
    url: '/ems/base/alarmNotifyGroup/listAll',
    method: 'get'
  });
};

/**
 * 查询报警通知组主表详细
 * @param id
 */
export const getAlarmNotifyGroup = (id: AlarmNotifyGroupId): AxiosPromise<AlarmNotifyGroupVO> => {
  return request({
    url: '/ems/base/alarmNotifyGroup/' + id,
    method: 'get'
  });
};

/**
 * 批量查询报警通知组主表详细
 * @param ids
 */
export const getAlarmNotifyGroupByIds = (ids: AlarmNotifyGroupIds): AxiosPromise<AlarmNotifyGroupVO[]> => {
  return request({
    url: '/ems/base/alarmNotifyGroup/listByIds',
    method: 'post',
    data: ids
  });
};

/**
 * 统计报警通知组主表数量
 * @param query
 */
export const countAlarmNotifyGroup = (query?: AlarmNotifyGroupQuery): AxiosPromise<number> => {
  return request({
    url: '/ems/base/alarmNotifyGroup/count',
    method: 'get',
    params: query
  });
};

/**
 * 判断是否存在符合条件的报警通知组主表
 * @param query
 */
export const existsAlarmNotifyGroup = (query?: AlarmNotifyGroupQuery): AxiosPromise<boolean> => {
  return request({
    url: '/ems/base/alarmNotifyGroup/exists',
    method: 'get',
    params: query
  });
};

/**
 * 新增报警通知组主表
 * @param data
 */
export const addAlarmNotifyGroup = (data: AlarmNotifyGroupForm) => {
  return request({
    url: '/ems/base/alarmNotifyGroup',
    method: 'post',
    data: data
  });
};

/**
 * 修改报警通知组主表
 * @param data
 */
export const updateAlarmNotifyGroup = (data: AlarmNotifyGroupForm) => {
  return request({
    url: '/ems/base/alarmNotifyGroup',
    method: 'put',
    data: data
  });
};

/**
 * 删除报警通知组主表
 * @param id
 */
export const delAlarmNotifyGroup = (id: AlarmNotifyGroupId | AlarmNotifyGroupIds) => {
  return request({
    url: '/ems/base/alarmNotifyGroup/' + id,
    method: 'delete'
  });
};
