import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RfidDeviceForm, RfidDeviceQuery, RfidDeviceVO } from './types';

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

export const listRfidDevice = (query?: RfidDeviceQuery): AxiosPromise<RfidDeviceVO[]> => {
  return request({
    url: '/rfid/rfidDevice/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询设备信息详细
 * @param id
 */
export const getRfidDevice = (id: string | number): AxiosPromise<RfidDeviceVO> => {
  return request({
    url: '/rfid/rfidDevice/' + id,
    method: 'get'
  });
};

/**
 * 新增设备信息
 * @param data
 */
export const addRfidDevice = (data: RfidDeviceForm) => {
  return request({
    url: '/rfid/rfidDevice',
    method: 'post',
    data: data
  });
};

/**
 * 修改设备信息
 * @param data
 */
export const updateRfidDevice = (data: RfidDeviceForm) => {
  return request({
    url: '/rfid/rfidDevice',
    method: 'put',
    data: data
  });
};

/**
 * 删除设备信息
 * @param id
 */
export const delRfidDevice = (id: string | number | Array<string | number>) => {
  return request({
    url: '/rfid/rfidDevice/' + id,
    method: 'delete'
  });
};

/**
 * 获取全部设备信息列表（用于下拉、首页等场景）
 * @param query
 */
export const getRfidDeviceList = (query?: RfidDeviceQuery) => {
  return request({
    url: '/rfid/rfidDevice/getRfidDeviceList',
    method: 'get',
    params: query
  });
};
