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

// 硬件 VO 类型
export interface HardwareVO {
  id?: number;
  hardwareCode?: string;
  hardwareName: string;
  hardwareTypeId?: number;
  workshopId?: number;
  enableFlag?: string;
  remark?: string;
  createBy?: string;
  createTime?: Date | string;
  updateBy?: string;
  updateTime?: Date | string;
}

// 分页参数类型
export interface HardwarePageParam {
  pageNo?: number;
  pageSize?: number;
  hardwareCode?: string;
  hardwareName?: string;
  hardwareTypeId?: number;
  workshopId?: number;
  enableFlag?: string;
  [key: string]: any;
}

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

// 硬件管理 API
export const hardwareApi = {
  // 获取机柜列表
  getCabinets: (params?: any) => {
    return axiosInstance.get('/hardware/cabinets', { params });
  },

  // 获取钥匙列表
  getKeys: (params?: any) => {
    return axiosInstance.get('/hardware/keys', { params });
  },

  // 查询硬件列表
  listHardware: (params: HardwarePageParam): Promise<PageResponse<HardwareVO>> => {
    return axiosInstance.get('/iscs/hardware/getHardwarePage', { params });
  },

  // 获取硬件详细信息
  getHardwareInfo: (id: number): Promise<HardwareVO> => {
    return axiosInstance.get('/iscs/hardware/selectHardwareById', {
      params: { id }
    });
  },
};

