import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AlarmNotifyGroupUserVO, AlarmNotifyGroupUserForm, AlarmNotifyGroupUserId, AlarmNotifyGroupUserIds, AlarmNotifyGroupUserQuery } from '@/api/ems/base/alarmNotifyGroupUser/types';

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

export const listAlarmNotifyGroupUser = (query?: AlarmNotifyGroupUserQuery): AxiosPromise<AlarmNotifyGroupUserVO[]> => {
  return request({
    url: '/ems/base/alarmNotifyGroupUser/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询报警通知组成员详细
 * @param id
 */
export const getAlarmNotifyGroupUser = (id: AlarmNotifyGroupUserId): AxiosPromise<AlarmNotifyGroupUserVO> => {
  return request({
    url: '/ems/base/alarmNotifyGroupUser/' + id,
    method: 'get'
  });
};

/**
 * 批量查询报警通知组成员详细
 * @param ids
 */
export const getAlarmNotifyGroupUserByIds = (ids: AlarmNotifyGroupUserIds): AxiosPromise<AlarmNotifyGroupUserVO[]> => {
  return request({
    url: '/ems/base/alarmNotifyGroupUser/listByIds',
    method: 'post',
    data: ids
  });
};

/**
 * 统计报警通知组成员数量
 * @param query
 */
export const countAlarmNotifyGroupUser = (query?: AlarmNotifyGroupUserQuery): AxiosPromise<number> => {
  return request({
    url: '/ems/base/alarmNotifyGroupUser/count',
    method: 'get',
    params: query
  });
};

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

/**
 * 新增报警通知组成员
 * @param data
 */
export const addAlarmNotifyGroupUser = (data: AlarmNotifyGroupUserForm) => {
  return request({
    url: '/ems/base/alarmNotifyGroupUser',
    method: 'post',
    data: data
  });
};

/**
 * 修改报警通知组成员
 * @param data
 */
export const updateAlarmNotifyGroupUser = (data: AlarmNotifyGroupUserForm) => {
  return request({
    url: '/ems/base/alarmNotifyGroupUser',
    method: 'put',
    data: data
  });
};

/**
 * 删除报警通知组成员
 * @param id
 */
export const delAlarmNotifyGroupUser = (id: AlarmNotifyGroupUserId | AlarmNotifyGroupUserIds) => {
  return request({
    url: '/ems/base/alarmNotifyGroupUser/' + id,
    method: 'delete'
  });
};
