import axiosInstance from '../../utils/axios';

// 仓位 VO 类型
export interface LockCabinetSlotVO {
  slotId?: number;
  cabinetId?: number;
  slotCode?: string;
  slotName?: string;
  slotType?: string;
  row?: number;
  col?: number;
  isOccupied?: string;
  hardwareId?: number;
  status?: string;
  remark?: string;
  createTime?: Date | string;
  createBy?: string;
  updateTime?: Date | string;
  updateBy?: string;
}

// 分页参数类型
export interface SlotPageParam {
  pageNo?: number;
  pageSize?: number;
  slotCode?: string;
  slotType?: string;
  status?: string;
  cabinetId?: number;
  [key: string]: any;
}

// 分页响应类型
export interface PageResponse<T> {
  list: T[];
  total: number;
}

// 仓位管理 API
export const slotApi = {
  // 查询仓位列表
  getIsLockCabinetSlotsPage: (params: SlotPageParam): Promise<PageResponse<LockCabinetSlotVO>> => {
    return axiosInstance.get('/iscs/lock-cabinet-slots/getLockCabinetSlotsPage', { params });
  },

  // 获取仓位详细信息
  selectIsLockCabinetSlotsById: (id: number): Promise<LockCabinetSlotVO> => {
    return axiosInstance.get('/iscs/lock-cabinet-slots/selectLockCabinetSlotsById', {
      params: { id }
    });
  },

  // 新增仓位
  insertIsLockCabinetSlots: (data: LockCabinetSlotVO): Promise<void> => {
    return axiosInstance.post('/iscs/lock-cabinet-slots/insertLockCabinetSlots', data);
  },

  // 修改仓位信息
  updateIsLockCabinetSlots: (data: LockCabinetSlotVO): Promise<void> => {
    return axiosInstance.put('/iscs/lock-cabinet-slots/updateLockCabinetSlots', data);
  },

  // 删除仓位信息
  deleteIsLockCabinetSlotsBySlotIds: (ids: string): Promise<void> => {
    return axiosInstance.delete(`/iscs/lock-cabinet-slots/deleteLockCabinetSlotsList?ids=${ids}`);
  },
};

