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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 商品DTO */
|
|
|
|
export interface GoodsDTO {
|
|
|
|
goodsId?: number;
|
|
|
|
goodsName?: string;
|
|
|
|
categoryId?: number;
|
|
|
|
price?: number;
|
|
|
|
stock?: number;
|
|
|
|
status?: number;
|
|
|
|
coverImg?: string;
|
|
|
|
goodsDetail?: string;
|
|
|
|
creatorId?: number;
|
|
|
|
createTime?: Date;
|
|
|
|
updaterId?: number;
|
|
|
|
updateTime?: Date;
|
|
|
|
remark?: string;
|
|
|
|
deleted?: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 商品请求参数 */
|
|
|
|
export interface GoodsRequest {
|
|
|
|
goodsName: string;
|
|
|
|
categoryId: number;
|
|
|
|
price: number;
|
|
|
|
stock: number;
|
|
|
|
status: 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 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
|
|
|
|
});
|
|
|
|
};
|