import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DeviceInfoVO, DeviceInfoForm, DeviceInfoId, DeviceInfoIds, DeviceInfoQuery } from '@/api/wcs/deviceInfo/types';
import type { WcsDropdownQuery } from '@/api/wcs/types';

/**
 * 查询设备信息列表
 * @param query
 * @returns {*}
 */

export const listDeviceInfo = (query?: DeviceInfoQuery): AxiosPromise<DeviceInfoVO[]> => {
  return request({
    url: '/wcs/deviceInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 获取设备信息下拉列表
 * @param query
 */
export const getDeviceInfoList = (query?: WcsDropdownQuery<DeviceInfoQuery>): AxiosPromise<DeviceInfoVO[]> => {
  return request({
    url: '/wcs/deviceInfo/getDeviceInfoList',
    method: 'get',
    params: query
  });
};

/**
 * 查询设备信息详细
 * @param objId
 */
export const getDeviceInfo = (objId: DeviceInfoId): AxiosPromise<DeviceInfoVO> => {
  return request({
    url: '/wcs/deviceInfo/' + objId,
    method: 'get'
  });
};

/**
 * 批量查询设备信息详细
 * @param ids
 */
export const getDeviceInfoByIds = (ids: DeviceInfoIds): AxiosPromise<DeviceInfoVO[]> => {
  return request({
    url: '/wcs/deviceInfo/listByIds',
    method: 'post',
    data: ids
  });
};

/**
 * 统计设备信息数量
 * @param query
 */
export const countDeviceInfo = (query?: DeviceInfoQuery): AxiosPromise<number> => {
  return request({
    url: '/wcs/deviceInfo/count',
    method: 'get',
    params: query
  });
};

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

/**
 * 新增设备信息
 * @param data
 */
export const addDeviceInfo = (data: DeviceInfoForm) => {
  return request({
    url: '/wcs/deviceInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改设备信息
 * @param data
 */
export const updateDeviceInfo = (data: DeviceInfoForm) => {
  return request({
    url: '/wcs/deviceInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除设备信息
 * @param objId
 */
export const delDeviceInfo = (objId: DeviceInfoId | DeviceInfoIds) => {
  return request({
    url: '/wcs/deviceInfo/' + objId,
    method: 'delete'
  });
};
