import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DeviceParamVO, DeviceParamForm, DeviceParamId, DeviceParamIds, DeviceParamQuery } from '@/api/wcs/deviceParam/types';

/**
 * 查询设备参数列表
 * @param query
 * @returns {*}
 */

export const listDeviceParam = (query?: DeviceParamQuery): AxiosPromise<DeviceParamVO[]> => {
  return request({
    url: '/wcs/deviceParam/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询设备参数详细
 * @param objId
 */
export const getDeviceParam = (objId: DeviceParamId): AxiosPromise<DeviceParamVO> => {
  return request({
    url: '/wcs/deviceParam/' + objId,
    method: 'get'
  });
};

/**
 * 批量查询设备参数详细
 * @param ids
 */
export const getDeviceParamByIds = (ids: DeviceParamIds): AxiosPromise<DeviceParamVO[]> => {
  return request({
    url: '/wcs/deviceParam/listByIds',
    method: 'post',
    data: ids
  });
};

/**
 * 统计设备参数数量
 * @param query
 */
export const countDeviceParam = (query?: DeviceParamQuery): AxiosPromise<number> => {
  return request({
    url: '/wcs/deviceParam/count',
    method: 'get',
    params: query
  });
};

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

/**
 * 新增设备参数
 * @param data
 */
export const addDeviceParam = (data: DeviceParamForm) => {
  return request({
    url: '/wcs/deviceParam',
    method: 'post',
    data: data
  });
};

/**
 * 修改设备参数
 * @param data
 */
export const updateDeviceParam = (data: DeviceParamForm) => {
  return request({
    url: '/wcs/deviceParam',
    method: 'put',
    data: data
  });
};

/**
 * 删除设备参数
 * @param objId
 */
export const delDeviceParam = (objId: DeviceParamId | DeviceParamIds) => {
  return request({
    url: '/wcs/deviceParam/' + objId,
    method: 'delete'
  });
};
