import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { IntegrationPointMapVO, IntegrationPointMapForm, IntegrationPointMapId, IntegrationPointMapIds, IntegrationPointMapQuery } from '@/api/ems/base/integrationPointMap/types';

/**
 * 查询对接点位映射列表
 * @param query
 * @returns {*}
 */

export const listIntegrationPointMap = (query?: IntegrationPointMapQuery): AxiosPromise<IntegrationPointMapVO[]> => {
  return request({
    url: '/ems/base/integrationPointMap/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询对接点位映射详细
 * @param id
 */
export const getIntegrationPointMap = (id: IntegrationPointMapId): AxiosPromise<IntegrationPointMapVO> => {
  return request({
    url: '/ems/base/integrationPointMap/' + id,
    method: 'get'
  });
};

/**
 * 批量查询对接点位映射详细
 * @param ids
 */
export const getIntegrationPointMapByIds = (ids: IntegrationPointMapIds): AxiosPromise<IntegrationPointMapVO[]> => {
  return request({
    url: '/ems/base/integrationPointMap/listByIds',
    method: 'post',
    data: ids
  });
};

/**
 * 统计对接点位映射数量
 * @param query
 */
export const countIntegrationPointMap = (query?: IntegrationPointMapQuery): AxiosPromise<number> => {
  return request({
    url: '/ems/base/integrationPointMap/count',
    method: 'get',
    params: query
  });
};

/**
 * 判断是否存在符合条件的对接点位映射
 * @param query
 */
export const existsIntegrationPointMap = (query?: IntegrationPointMapQuery): AxiosPromise<boolean> => {
  return request({
    url: '/ems/base/integrationPointMap/exists',
    method: 'get',
    params: query
  });
};

/**
 * 新增对接点位映射
 * @param data
 */
export const addIntegrationPointMap = (data: IntegrationPointMapForm) => {
  return request({
    url: '/ems/base/integrationPointMap',
    method: 'post',
    data: data
  });
};

/**
 * 修改对接点位映射
 * @param data
 */
export const updateIntegrationPointMap = (data: IntegrationPointMapForm) => {
  return request({
    url: '/ems/base/integrationPointMap',
    method: 'put',
    data: data
  });
};

/**
 * 删除对接点位映射
 * @param id
 */
export const delIntegrationPointMap = (id: IntegrationPointMapId | IntegrationPointMapIds) => {
  return request({
    url: '/ems/base/integrationPointMap/' + id,
    method: 'delete'
  });
};
