72 lines
2.1 KiB
TypeScript
72 lines
2.1 KiB
TypeScript
import http from "@/utils/http";
|
|
import { Product, Resp, RespPage } from "./types/types";
|
|
|
|
/**
|
|
* 商品列表
|
|
* @returns 商品列表
|
|
*/
|
|
export const productPage = (params: Product.PageReq) => {
|
|
return http.post<RespPage<Product.ProductInfo>>("/shop-shop-service/api/shop/product-my/queryPage", params);
|
|
};
|
|
/**
|
|
* 发布商品
|
|
* @returns 商品列表
|
|
*/
|
|
export const createProduct = (params: Product.ProductEdit) => {
|
|
return http.post<Resp<boolean>>("/shop-shop-service/api/shop/product-my/createProduct", params);
|
|
};
|
|
/**
|
|
* 获取商品详情,编辑用
|
|
* @returns 商品详情
|
|
*/
|
|
export const getProductEdit = (productId: string) => {
|
|
return http.get<Resp<Product.ProductEdit>>(`/shop-shop-service/api/shop/product-my/getProductInfo/${productId}`);
|
|
};
|
|
/**
|
|
* 修改商品
|
|
* @param params 修改参数
|
|
*/
|
|
export const updateProduct = (productId: string, params: Product.ProductEdit) => {
|
|
return http.post<Resp<boolean>>("/shop-shop-service/api/shop/product-my/udpProduct", {
|
|
...params,
|
|
id: productId
|
|
});
|
|
};
|
|
|
|
/**
|
|
* 删除商品
|
|
* @param productId 删除ID
|
|
*/
|
|
export const deleteProduct = (productId: string) => {
|
|
return http.get<Resp<boolean>>(`/shop-shop-service/api/shop/product-my/deleteByProductId/${productId}`);
|
|
};
|
|
|
|
// ======================= 展示页面 START ======================
|
|
/**
|
|
* 获取商品详情,
|
|
*/
|
|
export const getProductInfo = (productId: string) => {
|
|
return http.get<
|
|
Resp<{
|
|
product: Product.ProductInfo;
|
|
skuList: Product.SkuDtoInfo[];
|
|
}>
|
|
>(`/shop-shop-service/api/shop/product/getById/${productId}`);
|
|
};
|
|
|
|
/**
|
|
* 获取分类列表
|
|
* @param classifyId 分类ID
|
|
*/
|
|
export const queryByClassifyId = (classifyId: string) => {
|
|
return http.get<Resp<Product.ProductInfo[]>>(`/shop-shop-service/api/shop/product/productHome/${classifyId}`);
|
|
};
|
|
/**
|
|
* 产品搜索
|
|
* @param params 搜索参数
|
|
*/
|
|
export const searchProduct = (params: Product.SearchProductReq) => {
|
|
return http.post<RespPage<Product.ProductInfo>>("/shop-shop-service/api/shop/product/queryProduct", params);
|
|
};
|
|
// ======================= 展示页面 END ======================
|