import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MonitorMetricThresholdVO, MonitorMetricThresholdForm, MonitorMetricThresholdId, MonitorMetricThresholdIds, MonitorMetricThresholdQuery } from '@/api/ems/base/monitorMetricThreshold/types';

/**
 * 查询统一点位阈值列表
 * @param query
 * @returns {*}
 */

export const listMonitorMetricThreshold = (query?: MonitorMetricThresholdQuery): AxiosPromise<MonitorMetricThresholdVO[]> => {
  return request({
    url: '/ems/base/monitorMetricThreshold/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询统一点位阈值详细
 * @param id
 */
export const getMonitorMetricThreshold = (id: MonitorMetricThresholdId): AxiosPromise<MonitorMetricThresholdVO> => {
  return request({
    url: '/ems/base/monitorMetricThreshold/' + id,
    method: 'get'
  });
};

/**
 * 批量查询统一点位阈值详细
 * @param ids
 */
export const getMonitorMetricThresholdByIds = (ids: MonitorMetricThresholdIds): AxiosPromise<MonitorMetricThresholdVO[]> => {
  return request({
    url: '/ems/base/monitorMetricThreshold/listByIds',
    method: 'post',
    data: ids
  });
};

/**
 * 统计统一点位阈值数量
 * @param query
 */
export const countMonitorMetricThreshold = (query?: MonitorMetricThresholdQuery): AxiosPromise<number> => {
  return request({
    url: '/ems/base/monitorMetricThreshold/count',
    method: 'get',
    params: query
  });
};

/**
 * 判断是否存在符合条件的统一点位阈值
 * @param query
 */
export const existsMonitorMetricThreshold = (query?: MonitorMetricThresholdQuery): AxiosPromise<boolean> => {
  return request({
    url: '/ems/base/monitorMetricThreshold/exists',
    method: 'get',
    params: query
  });
};

/**
 * 新增统一点位阈值
 * @param data
 */
export const addMonitorMetricThreshold = (data: MonitorMetricThresholdForm) => {
  return request({
    url: '/ems/base/monitorMetricThreshold',
    method: 'post',
    data: data
  });
};

/**
 * 修改统一点位阈值
 * @param data
 */
export const updateMonitorMetricThreshold = (data: MonitorMetricThresholdForm) => {
  return request({
    url: '/ems/base/monitorMetricThreshold',
    method: 'put',
    data: data
  });
};

/**
 * 删除统一点位阈值
 * @param id
 */
export const delMonitorMetricThreshold = (id: MonitorMetricThresholdId | MonitorMetricThresholdIds) => {
  return request({
    url: '/ems/base/monitorMetricThreshold/' + id,
    method: 'delete'
  });
};
