import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BaseDeviceCategoryVO, BaseDeviceCategoryForm, BaseDeviceCategoryQuery } from '@/api/mes/baseDeviceCategory/types';

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

export const listBaseDeviceCategory = (query?: BaseDeviceCategoryQuery): AxiosPromise<BaseDeviceCategoryVO[]> => {
  return request({
    url: '/mes/baseDeviceCategory/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询设备大类信息详细
 * @param deviceCategoryId
 */
export const getBaseDeviceCategory = (deviceCategoryId: string | number): AxiosPromise<BaseDeviceCategoryVO> => {
  return request({
    url: '/mes/baseDeviceCategory/' + deviceCategoryId,
    method: 'get'
  });
};

/**
 * 新增设备大类信息
 * @param data
 */
export const addBaseDeviceCategory = (data: BaseDeviceCategoryForm) => {
  return request({
    url: '/mes/baseDeviceCategory',
    method: 'post',
    data: data
  });
};

/**
 * 修改设备大类信息
 * @param data
 */
export const updateBaseDeviceCategory = (data: BaseDeviceCategoryForm) => {
  return request({
    url: '/mes/baseDeviceCategory',
    method: 'put',
    data: data
  });
};

/**
 * 删除设备大类信息
 * @param deviceCategoryId
 */
export const delBaseDeviceCategory = (deviceCategoryId: string | number | Array<string | number>) => {
  return request({
    url: '/mes/baseDeviceCategory/' + deviceCategoryId,
    method: 'delete'
  });
};


/**
 * 下拉框查询设备大类信息列表
 * @param query
 * @returns {*}
 */
export function getBaseDeviceCategoryList (query) {
    return request({
        url: '/mes/baseDeviceCategory/getBaseDeviceCategoryList',
        method: 'get',
        params: query
    });
};
