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

// 分页参数类型
export interface PageParam {
  pageNo?: number;
  pageSize?: number;
  cabinetName?: string;
  isOnline?: string;
  status?: string;
  [key: string]: any;
}

// 机柜 VO 类型
export interface LockCabinetVO {
  cabinetId?: number;
  cabinetCode?: string;
  cabinetName: string;
  workstationId?: number;
  workstationName?: string;
  hardwareId?: number;
  serialNumber?: string;
  isOnline?: string;
  status?: string;
  cabinetIcon?: string;
  cabinetPicture?: string;
  remark?: string;
  createTime?: Date | string;
  createBy?: string;
  updateTime?: Date | string;
  updateBy?: string;
}

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

// 机柜管理 API
export const lockCabinetApi = {
  // 查询机柜列表
  getIsLockCabinetPage: (params: PageParam): Promise<PageResponse<LockCabinetVO>> => {
    return axiosInstance.get('/iscs/lock-cabinet/getLockCabinetPage', { params });
  },

  // 获取机柜详细信息
  selectIsLockCabinetById: (id: number): Promise<LockCabinetVO> => {
    return axiosInstance.get('/iscs/lock-cabinet/selectLockCabinetById', {
      params: { id }
    });
  },

  // 新增机柜
  insertIsLockCabinet: (data: LockCabinetVO): Promise<void> => {
    return axiosInstance.post('/iscs/lock-cabinet/insertLockCabinet', data);
  },

  // 修改机柜信息
  updateIsLockCabinet: (data: LockCabinetVO): Promise<void> => {
    return axiosInstance.put('/iscs/lock-cabinet/updateLockCabinet', data);
  },

  // 删除机柜信息
  deleteIsLockCabinetByCabinetIds: (ids: string): Promise<void> => {
    return axiosInstance.delete(`/iscs/lock-cabinet/deleteLockCabinetList?ids=${ids}`);
  },
};

