import { http } from '@/utils/http'; import { CabinetCellDTO } from './cabinet-cell'; export interface SmartCabinetQuery extends BasePageQuery { /** 柜机名称 */ cabinetName?: string; /** 柜机类型(0主柜 1副柜) */ cabinetType?: number; /** 柜机模版编号 */ templateNo?: string; /** 归属类型(0-借还柜 1-固资通) */ belongType?: number; } /** * 智能柜信息 * @description 智能柜信息表 */ export interface SmartCabinetDTO { /** 柜机唯一ID */ cabinetId?: number; /** 柜机名称 */ cabinetName: string; /** 柜机类型(0主柜 1副柜) */ cabinetType: number; /** 归属主柜ID */ mainCabinet?: number; /** 归属主柜名称 */ mainCabinetName?: string; /** MQTT服务ID */ mqttServerId?: number; /** 商店ID */ shopId?: number; /** 商店名称 */ shopName?: string; /** 柜机模版编号 */ templateNo: string; /** 锁控板序号 */ lockControlNo: number; /** 柜机位置 */ location: number; /** 操作人 */ operator?: string; /** 归属类型(0-借还柜 1-固资通) */ belongType?: number; usedCells?: number; availableCells?: number; /** 运行模式(0-支付模式 1-审批模式 2-借还模式 3-会员模式) */ mode?: number; /** 借呗支付(1-正常使用 0-禁止使用) */ balanceEnable?: number; } /** * 添加智能柜命令 */ export interface AddSmartCabinetCommand { /** 柜机名称 */ cabinetName: string; /** 柜机类型(0主柜 1副柜) */ cabinetType: number; /** 归属主柜ID */ mainCabinet?: number; /** MQTT服务ID */ mqttServerId?: number; /** 商店ID */ shopId?: number; /** 柜机模版编号 */ templateNo: string; /** 锁控板序号 */ lockControlNo: number; /** 柜机位置 */ location: number; /** 归属类型(0-借还柜 1-固资通) */ belongType: number; /** 运行模式(0-支付模式 1-审批模式 2-借还模式 3-会员模式) */ mode?: number; /** 借呗支付(1-正常使用 0-禁止使用) */ balanceEnable?: number; } /** * 更新智能柜命令 */ export interface UpdateSmartCabinetCommand { /** 柜机唯一ID */ cabinetId: number; /** 柜机名称 */ cabinetName?: string; /** 柜机类型(0主柜 1副柜) */ cabinetType?: number; /** 归属主柜ID */ mainCabinet?: number; /** MQTT服务ID */ mqttServerId?: number; /** 商店ID */ shopId?: number; /** 柜机模版编号 */ templateNo?: string; /** 锁控板序号 */ lockControlNo?: number; /** 柜机位置 */ location?: number; /** 归属类型(0-借还柜 1-固资通) */ belongType?: number; /** 运行模式(0-支付模式 1-审批模式 2-借还模式 3-会员模式) */ mode?: number; /** 借呗支付(1-正常使用 0-禁止使用) */ balanceEnable?: number; } export interface AllCabinetDataDTO { smartCabinetList: SmartCabinetDTO[]; cells: CabinetCellDTO[]; } export const getSmartCabinetList = (params?: SmartCabinetQuery) => { return http.request>>('get', '/cabinet/smartCabinet', { params }); }; export const addSmartCabinet = (data: AddSmartCabinetCommand) => { return http.request>('post', '/cabinet/smartCabinet', { data }); }; export const updateSmartCabinet = (id: number, data: UpdateSmartCabinetCommand) => { return http.request>('put', `/cabinet/smartCabinet/${id}`, { data }); }; export const deleteSmartCabinet = (ids: string) => { return http.request>('delete', `/cabinet/smartCabinet/${ids}`); }; export const getAllCabinetsWithCells = () => { return http.request>('get', '/cabinet/smartCabinet/all'); }; export const allCabinets = () => { return http.request>>('get', '/cabinet/smartCabinet/allCabinets'); }; export const getSmartCabinetDetailApi = (cabinetId: number) => { return http.request>("get", `/cabinet/smartCabinet/detail/${cabinetId}`); }; /** * 获取运行模式文字描述 * @param mode 运行模式数字 */ export const getModeText = (mode?: number) => { switch (mode) { case 0: return '支付模式'; case 1: return '审批模式'; case 2: return '借还模式'; case 3: return '会员模式'; default: return '未知模式'; } }; /** * 获取借呗支付状态文字描述 * @param balanceEnable 借呗支付状态数字 */ export const getBalanceEnableText = (balanceEnable?: number) => { switch (balanceEnable) { case 0: return '禁止使用'; case 1: return '正常使用'; default: return '未知状态'; } };