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

173 lines
4.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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<ResponseData<PageDTO<SmartCabinetDTO>>>('get', '/cabinet/smartCabinet', {
params
});
};
export const getSmartCabinetListQuery = (params?: SmartCabinetQuery) => {
return http.request<ResponseData<SmartCabinetDTO[]>>('get', '/cabinet/smartCabinet/list', {
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 balanceEnable 借呗支付状态数字
*/
export const getBalanceEnableText = (balanceEnable?: number) => {
switch (balanceEnable) {
case 0:
return '禁止使用';
case 1:
return '正常使用';
default:
return '未知状态';
}
};