import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DeviceHostVO, DeviceHostForm, DeviceHostId, DeviceHostIds, DeviceHostQuery } from '@/api/wcs/deviceHost/types';
import type { WcsDropdownQuery } from '@/api/wcs/types';

/**
 * 查询设备主机列表
 * @param query
 * @returns {*}
 */

export const listDeviceHost = (query?: DeviceHostQuery): AxiosPromise<DeviceHostVO[]> => {
  return request({
    url: '/wcs/deviceHost/list',
    method: 'get',
    params: query
  });
};

/**
 * 获取设备主机下拉列表
 * @param query
 */
export const getDeviceHostList = (query?: WcsDropdownQuery<DeviceHostQuery>): AxiosPromise<DeviceHostVO[]> => {
  return request({
    url: '/wcs/deviceHost/getDeviceHostList',
    method: 'get',
    params: query
  });
};

/**
 * 查询设备主机详细
 * @param objId
 */
export const getDeviceHost = (objId: DeviceHostId): AxiosPromise<DeviceHostVO> => {
  return request({
    url: '/wcs/deviceHost/' + objId,
    method: 'get'
  });
};

/**
 * 批量查询设备主机详细
 * @param ids
 */
export const getDeviceHostByIds = (ids: DeviceHostIds): AxiosPromise<DeviceHostVO[]> => {
  return request({
    url: '/wcs/deviceHost/listByIds',
    method: 'post',
    data: ids
  });
};

/**
 * 统计设备主机数量
 * @param query
 */
export const countDeviceHost = (query?: DeviceHostQuery): AxiosPromise<number> => {
  return request({
    url: '/wcs/deviceHost/count',
    method: 'get',
    params: query
  });
};

/**
 * 判断是否存在符合条件的设备主机
 * @param query
 */
export const existsDeviceHost = (query?: DeviceHostQuery): AxiosPromise<boolean> => {
  return request({
    url: '/wcs/deviceHost/exists',
    method: 'get',
    params: query
  });
};

/**
 * 新增设备主机
 * @param data
 */
export const addDeviceHost = (data: DeviceHostForm) => {
  return request({
    url: '/wcs/deviceHost',
    method: 'post',
    data: data
  });
};

/**
 * 修改设备主机
 * @param data
 */
export const updateDeviceHost = (data: DeviceHostForm) => {
  return request({
    url: '/wcs/deviceHost',
    method: 'put',
    data: data
  });
};

/**
 * 删除设备主机
 * @param objId
 */
export const delDeviceHost = (objId: DeviceHostId | DeviceHostIds) => {
  return request({
    url: '/wcs/deviceHost/' + objId,
    method: 'delete'
  });
};
