import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AlarmPushLogVO, AlarmPushLogForm, AlarmPushLogId, AlarmPushLogIds, AlarmPushLogQuery } from '@/api/ems/base/alarmPushLog/types';

/**
 * 查询报警推送日志列表
 * @param query
 * @returns {*}
 */

export const listAlarmPushLog = (query?: AlarmPushLogQuery): AxiosPromise<AlarmPushLogVO[]> => {
  return request({
    url: '/ems/base/alarmPushLog/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询报警推送日志详细
 * @param id
 */
export const getAlarmPushLog = (id: AlarmPushLogId): AxiosPromise<AlarmPushLogVO> => {
  return request({
    url: '/ems/base/alarmPushLog/' + id,
    method: 'get'
  });
};

/**
 * 批量查询报警推送日志详细
 * @param ids
 */
export const getAlarmPushLogByIds = (ids: AlarmPushLogIds): AxiosPromise<AlarmPushLogVO[]> => {
  return request({
    url: '/ems/base/alarmPushLog/listByIds',
    method: 'post',
    data: ids
  });
};

/**
 * 统计报警推送日志数量
 * @param query
 */
export const countAlarmPushLog = (query?: AlarmPushLogQuery): AxiosPromise<number> => {
  return request({
    url: '/ems/base/alarmPushLog/count',
    method: 'get',
    params: query
  });
};

/**
 * 判断是否存在符合条件的报警推送日志
 * @param query
 */
export const existsAlarmPushLog = (query?: AlarmPushLogQuery): AxiosPromise<boolean> => {
  return request({
    url: '/ems/base/alarmPushLog/exists',
    method: 'get',
    params: query
  });
};

/**
 * 新增报警推送日志
 * @param data
 */
export const addAlarmPushLog = (data: AlarmPushLogForm) => {
  return request({
    url: '/ems/base/alarmPushLog',
    method: 'post',
    data: data
  });
};

/**
 * 修改报警推送日志
 * @param data
 */
export const updateAlarmPushLog = (data: AlarmPushLogForm) => {
  return request({
    url: '/ems/base/alarmPushLog',
    method: 'put',
    data: data
  });
};

/**
 * 删除报警推送日志
 * @param id
 */
export const delAlarmPushLog = (id: AlarmPushLogId | AlarmPushLogIds) => {
  return request({
    url: '/ems/base/alarmPushLog/' + id,
    method: 'delete'
  });
};
