mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 09:49:19 +08:00
167 lines
4.5 KiB
TypeScript
167 lines
4.5 KiB
TypeScript
import { requestClient } from '#/api/request';
|
|
|
|
import type { PageQueryDTO, PageResultVO } from '#/types/common';
|
|
import type { ShopDTO, ShopVO, ProductDTO, ProductVO } from './types';
|
|
|
|
/**
|
|
* 店铺管理API
|
|
*/
|
|
|
|
/**
|
|
* 分页获取店铺列表
|
|
*/
|
|
export async function getShopPageApi(params: PageQueryDTO<ShopDTO.ShopFiltersDTO>) {
|
|
return requestClient.post<PageResultVO<ShopVO.ShopInfoVO>>('/ec/shop/page', params);
|
|
}
|
|
|
|
/**
|
|
* 创建店铺
|
|
*/
|
|
export async function createShopApi(data: ShopDTO.CreateShopDTO) {
|
|
return requestClient.post<ShopVO.ShopInfoVO>('/ec/shop/create', data);
|
|
}
|
|
|
|
/**
|
|
* 更新店铺
|
|
*/
|
|
export async function updateShopApi(id: number, data: ShopDTO.UpdateShopDTO) {
|
|
return requestClient.put<ShopVO.ShopInfoVO>(`/ec/shop/update/${id}`, data);
|
|
}
|
|
|
|
/**
|
|
* 删除店铺
|
|
*/
|
|
export async function deleteShopApi(id: number) {
|
|
return requestClient.delete<void>(`/ec/shop/delete/${id}`);
|
|
}
|
|
|
|
/**
|
|
* 上传店铺Logo
|
|
*/
|
|
export async function uploadShopLogoApi(file: File) {
|
|
const formData = new FormData();
|
|
formData.append('file', file);
|
|
return requestClient.post<ShopVO.ShopInfoVO>('/ec/shop/upload-logo', formData, {
|
|
headers: {
|
|
'Content-Type': 'multipart/form-data',
|
|
},
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 商品管理API
|
|
*/
|
|
|
|
/**
|
|
* 分页获取商品列表
|
|
*/
|
|
export async function getProductPageApi(params: PageQueryDTO<ProductDTO.ProductFiltersDTO>) {
|
|
return requestClient.post<PageResultVO<ProductVO.ProductInfoVO>>('/ec/product/page', params);
|
|
}
|
|
|
|
/**
|
|
* 创建商品
|
|
*/
|
|
export async function createProductApi(data: ProductDTO.CreateProductDTO) {
|
|
return requestClient.post<ProductVO.ProductInfoVO>('/ec/product/create', data);
|
|
}
|
|
|
|
/**
|
|
* 更新商品
|
|
*/
|
|
export async function updateProductApi(id: number, data: ProductDTO.UpdateProductDTO) {
|
|
return requestClient.put<ProductVO.ProductInfoVO>(`/ec/product/update/${id}`, data);
|
|
}
|
|
|
|
/**
|
|
* 删除商品
|
|
*/
|
|
export async function deleteProductApi(id: number) {
|
|
return requestClient.delete<void>(`/ec/product/delete/${id}`);
|
|
}
|
|
|
|
/**
|
|
* 一键创建商品和规格
|
|
*/
|
|
export async function createProductWithSpecsApi(data: ProductDTO.CreateProductWithSpecsDTO) {
|
|
return requestClient.post<ProductVO.ProductInfoVO>('/ec/product/create-with-specs', data);
|
|
}
|
|
|
|
/**
|
|
* 商品规格管理API
|
|
*/
|
|
|
|
/**
|
|
* 分页获取商品规格列表
|
|
*/
|
|
export async function getProductSpecPageApi(params: PageQueryDTO<ProductDTO.ProductSpecFilterDTO>) {
|
|
return requestClient.post<PageResultVO<ProductVO.ProductSpecInfoVO>>('/ec/product-spec/page', params);
|
|
}
|
|
|
|
/**
|
|
* 创建商品规格
|
|
*/
|
|
export async function createProductSpecApi(data: ProductDTO.CreateProductSpecDTO) {
|
|
return requestClient.post<ProductVO.ProductSpecInfoVO>('/ec/product-spec/create', data);
|
|
}
|
|
|
|
/**
|
|
* 更新商品规格
|
|
*/
|
|
export async function updateProductSpecApi(id: number, data: ProductDTO.UpdateProductSpecDTO) {
|
|
return requestClient.put<ProductVO.ProductSpecInfoVO>(`/ec/product-spec/update/${id}`, data);
|
|
}
|
|
|
|
/**
|
|
* 删除商品规格
|
|
*/
|
|
export async function deleteProductSpecApi(id: number) {
|
|
return requestClient.delete<void>(`/ec/product-spec/delete/${id}`);
|
|
}
|
|
|
|
/**
|
|
* 精准查询API - 用于数据导入
|
|
*/
|
|
|
|
/**
|
|
* 根据名称精准查询店铺
|
|
*/
|
|
export async function getShopByNameApi(name: string) {
|
|
return requestClient.get<ShopVO.ShopInfoVO>(`/ec/shop/find-by-name/${encodeURIComponent(name)}`);
|
|
}
|
|
|
|
/**
|
|
* 批量根据名称查询店铺
|
|
*/
|
|
export async function getShopsByNamesApi(names: string[]) {
|
|
return requestClient.post<ShopVO.ShopInfoVO[]>('/ec/shop/find-by-names', names);
|
|
}
|
|
|
|
/**
|
|
* 根据名称精准查询商品
|
|
*/
|
|
export async function getProductByNameApi(name: string) {
|
|
return requestClient.get<ProductVO.ProductInfoVO>(`/ec/product/find-by-name/${encodeURIComponent(name)}`);
|
|
}
|
|
|
|
/**
|
|
* 批量根据名称查询商品
|
|
*/
|
|
export async function getProductsByNamesApi(names: string[]) {
|
|
return requestClient.post<ProductVO.ProductInfoVO[]>('/ec/product/find-by-names', names);
|
|
}
|
|
|
|
/**
|
|
* 根据商品名称和规格编码精准查询商品规格
|
|
*/
|
|
export async function getProductSpecByProductAndSpecApi(productName: string, specCode: string) {
|
|
return requestClient.get<ProductVO.ProductSpecInfoVO>(`/ec/product-spec/find-by-product-and-spec/${encodeURIComponent(productName)}/${encodeURIComponent(specCode)}`);
|
|
}
|
|
|
|
/**
|
|
* 批量根据商品名称和规格编码查询商品规格
|
|
*/
|
|
export async function getProductSpecsByProductAndSpecsApi(queries: { productName: string; specCode: string }[]) {
|
|
return requestClient.post<ProductVO.ProductInfoVO[]>('/ec/product-spec/find-by-product-and-specs', queries);
|
|
}
|