shop-front-end/src/api/shop/goods.ts

117 lines
2.7 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";
export interface GoodsQuery extends BasePageQuery {
goodsName?: string;
categoryId?: number;
status?: number;
goodsId?: number;
autoApproval?: number;
}
/** 商品DTO */
export interface GoodsDTO {
/** 商品ID */
goodsId?: number;
/** 商品名称 */
goodsName: string;
/** 商品分类ID */
categoryId: number;
/** 商品价格 */
price: number;
/** 库存数量 */
stock: number;
/** 商品状态0下架 1上架 */
status: number;
/** 自动审批开关0关闭 1开启 */
autoApproval: number;
/** 商品封面图 */
coverImg: string;
/** 商品详情(富文本) */
goodsDetail: string;
/** 创建人ID */
creatorId?: number;
/** 创建时间 */
createTime?: Date;
/** 更新人ID */
updaterId?: number;
/** 更新时间 */
updateTime?: Date;
/** 备注信息 */
remark?: string;
/** 删除标志0存在 1删除 */
deleted?: number;
/** 所属货柜名称 */
cabinetName?: string;
/** 货柜单元格编号 */
cellNo?: number;
/** 单元格编号(字符串形式) */
cellNoStr?: string;
/** 总库存量(含所有仓库) */
totalStock?: number;
}
/** 商品请求参数 */
export interface GoodsRequest {
goodsName: string;
categoryId: number;
price: number;
stock: number;
status: number;
autoApproval: number;
coverImg?: string;
goodsDetail: string;
remark?: string;
}
/** 获取商品列表 */
export const getGoodsListApi = (params?: GoodsQuery) => {
return http.request<ResponseData<PageDTO<GoodsDTO>>>("get", "/shop/goods/list", {
params
});
};
/** 获取单个商品信息 */
export const getGoodsInfo = (goodsId: number) => {
return http.request<ResponseData<GoodsDTO>>("get", "/shop/goods/getGoodsInfo", {
params: {
goodsId
}
});
};
/** 新增商品 */
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
});
};
/** 删除商品 */
export const deleteGoodsApi = (goodsId: number | string) => {
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
});
};