2025-03-04 09:11:33 +08:00
|
|
|
|
import { http } from "@/utils/http";
|
|
|
|
|
|
|
|
|
|
export interface GoodsQuery extends BasePageQuery {
|
|
|
|
|
goodsName?: string;
|
|
|
|
|
categoryId?: number;
|
|
|
|
|
status?: number;
|
|
|
|
|
goodsId?: number;
|
2025-04-21 11:40:59 +08:00
|
|
|
|
autoApproval?: number;
|
2025-03-04 09:11:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 商品DTO */
|
|
|
|
|
export interface GoodsDTO {
|
2025-04-21 11:40:59 +08:00
|
|
|
|
/** 商品ID */
|
2025-03-04 09:11:33 +08:00
|
|
|
|
goodsId?: number;
|
2025-04-21 11:40:59 +08:00
|
|
|
|
/** 商品名称 */
|
2025-03-08 08:18:35 +08:00
|
|
|
|
goodsName: string;
|
2025-04-21 11:40:59 +08:00
|
|
|
|
/** 商品分类ID */
|
2025-03-08 08:18:35 +08:00
|
|
|
|
categoryId: number;
|
2025-04-21 11:40:59 +08:00
|
|
|
|
/** 商品价格 */
|
2025-03-08 08:18:35 +08:00
|
|
|
|
price: number;
|
2025-04-21 11:40:59 +08:00
|
|
|
|
/** 库存数量 */
|
2025-03-08 08:18:35 +08:00
|
|
|
|
stock: number;
|
2025-04-21 11:40:59 +08:00
|
|
|
|
/** 商品状态(0下架 1上架) */
|
2025-03-08 08:18:35 +08:00
|
|
|
|
status: number;
|
2025-04-21 11:40:59 +08:00
|
|
|
|
/** 自动审批开关(0关闭 1开启) */
|
|
|
|
|
autoApproval: number;
|
|
|
|
|
/** 商品封面图 */
|
2025-03-08 08:18:35 +08:00
|
|
|
|
coverImg: string;
|
2025-04-21 11:40:59 +08:00
|
|
|
|
/** 商品详情(富文本) */
|
2025-03-08 08:18:35 +08:00
|
|
|
|
goodsDetail: string;
|
2025-04-21 11:40:59 +08:00
|
|
|
|
/** 创建人ID */
|
2025-03-04 09:11:33 +08:00
|
|
|
|
creatorId?: number;
|
2025-04-21 11:40:59 +08:00
|
|
|
|
/** 创建时间 */
|
2025-03-04 09:11:33 +08:00
|
|
|
|
createTime?: Date;
|
2025-04-21 11:40:59 +08:00
|
|
|
|
/** 更新人ID */
|
2025-03-04 09:11:33 +08:00
|
|
|
|
updaterId?: number;
|
2025-04-21 11:40:59 +08:00
|
|
|
|
/** 更新时间 */
|
2025-03-04 09:11:33 +08:00
|
|
|
|
updateTime?: Date;
|
2025-04-21 11:40:59 +08:00
|
|
|
|
/** 备注信息 */
|
2025-03-04 09:11:33 +08:00
|
|
|
|
remark?: string;
|
2025-04-21 11:40:59 +08:00
|
|
|
|
/** 删除标志(0存在 1删除) */
|
2025-03-04 09:11:33 +08:00
|
|
|
|
deleted?: number;
|
2025-04-21 11:40:59 +08:00
|
|
|
|
/** 所属货柜名称 */
|
2025-03-21 16:59:44 +08:00
|
|
|
|
cabinetName?: string;
|
2025-04-21 11:40:59 +08:00
|
|
|
|
/** 货柜单元格编号 */
|
2025-03-21 16:59:44 +08:00
|
|
|
|
cellNo?: number;
|
2025-04-21 11:40:59 +08:00
|
|
|
|
/** 单元格编号(字符串形式) */
|
2025-04-19 09:27:58 +08:00
|
|
|
|
cellNoStr?: string;
|
2025-04-21 11:40:59 +08:00
|
|
|
|
/** 总库存量(含所有仓库) */
|
2025-04-18 17:13:38 +08:00
|
|
|
|
totalStock?: number;
|
2025-03-04 09:11:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 商品请求参数 */
|
|
|
|
|
export interface GoodsRequest {
|
|
|
|
|
goodsName: string;
|
|
|
|
|
categoryId: number;
|
|
|
|
|
price: number;
|
|
|
|
|
stock: number;
|
|
|
|
|
status: number;
|
2025-04-21 11:40:59 +08:00
|
|
|
|
autoApproval: number;
|
2025-03-04 09:11:33 +08:00
|
|
|
|
coverImg?: string;
|
|
|
|
|
goodsDetail: string;
|
|
|
|
|
remark?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取商品列表 */
|
|
|
|
|
export const getGoodsListApi = (params?: GoodsQuery) => {
|
|
|
|
|
return http.request<ResponseData<PageDTO<GoodsDTO>>>("get", "/shop/goods/list", {
|
|
|
|
|
params
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2025-04-25 11:42:50 +08:00
|
|
|
|
/** 获取单个商品信息 */
|
|
|
|
|
export const getGoodsInfo = (goodsId: number) => {
|
|
|
|
|
return http.request<ResponseData<GoodsDTO>>("get", "/shop/goods/getGoodsInfo", {
|
|
|
|
|
params: {
|
|
|
|
|
goodsId
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2025-03-04 09:11:33 +08:00
|
|
|
|
/** 新增商品 */
|
|
|
|
|
export const addGoodsApi = (data: GoodsRequest) => {
|
|
|
|
|
return http.request<ResponseData<void>>("post", "/shop/goods", {
|
|
|
|
|
data
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** 编辑商品 */
|
|
|
|
|
export const updateGoodsApi = (goodsId: number, data: GoodsRequest) => {
|
|
|
|
|
return http.request<ResponseData<void>>("put", `/shop/goods/${goodsId}`, {
|
|
|
|
|
data
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** 删除商品 */
|
2025-03-04 17:17:46 +08:00
|
|
|
|
export const deleteGoodsApi = (goodsId: number | string) => {
|
2025-03-04 09:11:33 +08:00
|
|
|
|
return http.request<ResponseData<void>>("delete", `/shop/goods/${goodsId}`);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** 修改商品状态 */
|
|
|
|
|
export const updateGoodsStatusApi = (goodsId: number, status: number) => {
|
|
|
|
|
return http.request<ResponseData<void>>(
|
|
|
|
|
"put",
|
|
|
|
|
`/shop/goods/${goodsId}/status`,
|
|
|
|
|
{
|
|
|
|
|
data: { status }
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** 批量导出商品 */
|
|
|
|
|
export const exportGoodsExcelApi = (params: GoodsQuery, fileName: string) => {
|
|
|
|
|
return http.download("/shop/goods/excel", fileName, {
|
|
|
|
|
params
|
|
|
|
|
});
|
|
|
|
|
};
|