import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RfidReadRecordForm, RfidReadRecordQuery, RfidReadRecordVO } from './types';

/**
 * 查询读取记录列表
 * @param query
 * @returns {*}
 */

export const listRfidReadRecord = (query?: RfidReadRecordQuery): AxiosPromise<RfidReadRecordVO[]> => {
  return request({
    url: '/rfid/rfidReadRecord/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询读取记录详细
 * @param id 主键
 * @param queryDate 查询日期（用于定位分表，格式：yyyy-MM-dd）
 */
export const getRfidReadRecord = (id: string | number, queryDate?: string): AxiosPromise<RfidReadRecordVO> => {
  return request({
    url: '/rfid/rfidReadRecord/' + id,
    method: 'get',
    params: { queryDate }
  });
};

/**
 * 新增读取记录
 * @param data
 */
export const addRfidReadRecord = (data: RfidReadRecordForm) => {
  return request({
    url: '/rfid/rfidReadRecord',
    method: 'post',
    data: data
  });
};

/**
 * 修改读取记录
 * @param data
 */
export const updateRfidReadRecord = (data: RfidReadRecordForm) => {
  return request({
    url: '/rfid/rfidReadRecord',
    method: 'put',
    data: data
  });
};

/**
 * 删除读取记录
 * @param id 主键
 * @param queryDate 查询日期（用于定位分表，格式：yyyy-MM-dd）
 */
export const delRfidReadRecord = (id: string | number | Array<string | number>, queryDate?: string) => {
  return request({
    url: '/rfid/rfidReadRecord/' + id,
    method: 'delete',
    params: { queryDate }
  });
};

/**
 * 获取全部读取记录列表（用于首页告警统计等场景）
 * @param query
 */
export const getRfidReadRecordList = (query?: RfidReadRecordQuery) => {
  return request({
    url: '/rfid/rfidReadRecord/getRfidReadRecordList',
    method: 'get',
    params: query
  });
};
