shop-front-end/src/api/cabinet/smart-cabinet.ts

185 lines
4.7 KiB
TypeScript
Raw Normal View History

2025-03-21 16:59:44 +08:00
import { http } from '@/utils/http';
import { CabinetCellDTO } from './cabinet-cell';
export interface SmartCabinetQuery extends BasePageQuery {
/** 柜机名称 */
2025-03-21 16:59:44 +08:00
cabinetName?: string;
/** 柜机类型0主柜 1副柜 */
2025-03-21 16:59:44 +08:00
cabinetType?: number;
/** 柜机模版编号 */
2025-03-21 16:59:44 +08:00
templateNo?: string;
/** 归属类型0-借还柜 1-固资通) */
belongType?: number;
2025-03-21 16:59:44 +08:00
}
/**
*
* @description
*/
2025-03-21 16:59:44 +08:00
export interface SmartCabinetDTO {
/** 柜机唯一ID */
2025-03-21 16:59:44 +08:00
cabinetId?: number;
/** 柜机名称 */
2025-03-21 16:59:44 +08:00
cabinetName: string;
/** 柜机类型0主柜 1副柜 */
2025-03-21 16:59:44 +08:00
cabinetType: number;
/** 归属主柜ID */
mainCabinet?: number;
/** 归属主柜名称 */
mainCabinetName?: string;
/** MQTT服务ID */
mqttServerId?: number;
/** 商店ID */
shopId?: number;
/** 商店名称 */
shopName?: string;
/** 柜机模版编号 */
2025-03-21 16:59:44 +08:00
templateNo: string;
/** 锁控板序号 */
2025-03-21 16:59:44 +08:00
lockControlNo: number;
/** 柜机位置 */
2025-03-21 16:59:44 +08:00
location: number;
/** 操作人 */
2025-03-21 16:59:44 +08:00
operator?: string;
/** 归属类型0-借还柜 1-固资通) */
belongType?: number;
usedCells?: number;
availableCells?: number;
/** 运行模式0-支付模式 1-审批模式 2-借还模式 3-会员模式) */
mode?: number;
/** 借呗支付1-正常使用 0-禁止使用) */
balanceEnable?: number;
2025-03-21 16:59:44 +08:00
}
/**
*
*/
2025-03-21 16:59:44 +08:00
export interface AddSmartCabinetCommand {
/** 柜机名称 */
2025-03-21 16:59:44 +08:00
cabinetName: string;
/** 柜机类型0主柜 1副柜 */
2025-03-21 16:59:44 +08:00
cabinetType: number;
/** 归属主柜ID */
mainCabinet?: number;
/** MQTT服务ID */
mqttServerId?: number;
/** 商店ID */
shopId?: number;
/** 柜机模版编号 */
2025-03-21 16:59:44 +08:00
templateNo: string;
/** 锁控板序号 */
2025-03-21 16:59:44 +08:00
lockControlNo: number;
/** 柜机位置 */
2025-03-21 16:59:44 +08:00
location: number;
/** 归属类型0-借还柜 1-固资通) */
belongType: number;
/** 运行模式0-支付模式 1-审批模式 2-借还模式 3-会员模式) */
mode?: number;
/** 借呗支付1-正常使用 0-禁止使用) */
balanceEnable?: number;
2025-03-21 16:59:44 +08:00
}
/**
*
*/
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;
2025-03-21 16:59:44 +08:00
}
export interface AllCabinetDataDTO {
smartCabinetList: SmartCabinetDTO[];
cells: CabinetCellDTO[];
}
export const getSmartCabinetList = (params?: SmartCabinetQuery) => {
return http.request<ResponseData<PageDTO<SmartCabinetDTO>>>('get', '/cabinet/smartCabinet', {
params
});
};
export const addSmartCabinet = (data: AddSmartCabinetCommand) => {
return http.request<ResponseData<void>>('post', '/cabinet/smartCabinet', {
data
});
};
export const updateSmartCabinet = (id: number, data: UpdateSmartCabinetCommand) => {
return http.request<ResponseData<void>>('put', `/cabinet/smartCabinet/${id}`, {
data
});
};
export const deleteSmartCabinet = (ids: string) => {
return http.request<ResponseData<void>>('delete', `/cabinet/smartCabinet/${ids}`);
};
export const getAllCabinetsWithCells = () => {
return http.request<ResponseData<AllCabinetDataDTO>>('get', '/cabinet/smartCabinet/all');
};
export const allCabinets = () => {
return http.request<ResponseData<Array<SmartCabinetDTO>>>('get', '/cabinet/smartCabinet/allCabinets');
};
export const getSmartCabinetDetailApi = (cabinetId: number) => {
return http.request<ResponseData<SmartCabinetDTO>>("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 '未知状态';
}
};