mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 07:09:20 +08:00
refactor: 重构电商模块目录结构
This commit is contained in:
@@ -0,0 +1,135 @@
|
||||
import type { ProductDTO, ProductVO } from './types';
|
||||
|
||||
import type { PageQueryDTO, PageResultVO } from '#/types/common';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
/**
|
||||
* 商品管理API
|
||||
*/
|
||||
|
||||
/**
|
||||
* 分页获取商品列表
|
||||
*/
|
||||
export async function getProductPageApi(
|
||||
params: PageQueryDTO<ProductDTO.Filters>,
|
||||
) {
|
||||
return requestClient.post<PageResultVO<ProductVO.Info>>(
|
||||
'/ec/product/page',
|
||||
params,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建商品
|
||||
*/
|
||||
export async function createProductApi(data: ProductDTO.Create) {
|
||||
return requestClient.post<ProductVO.Info>('/ec/product/create', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品
|
||||
*/
|
||||
export async function updateProductApi(id: number, data: ProductDTO.Update) {
|
||||
return requestClient.put<ProductVO.Info>(`/ec/product/update/${id}`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品
|
||||
*/
|
||||
export async function deleteProductApi(id: number) {
|
||||
return requestClient.delete(`/ec/product/delete/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品规格管理API
|
||||
*/
|
||||
|
||||
/**
|
||||
* 分页获取商品规格列表
|
||||
*/
|
||||
export async function getProductSpecPageApi(
|
||||
params: PageQueryDTO<ProductDTO.SpecFilters>,
|
||||
) {
|
||||
return requestClient.post<PageResultVO<ProductVO.SpecInfo>>(
|
||||
'/ec/product-spec/page',
|
||||
params,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建商品规格
|
||||
*/
|
||||
export async function createProductSpecApi(data: ProductDTO.CreateSpec) {
|
||||
return requestClient.post<ProductVO.SpecInfo>(
|
||||
'/ec/product-spec/create',
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品规格
|
||||
*/
|
||||
export async function updateProductSpecApi(
|
||||
id: number,
|
||||
data: ProductDTO.UpdateSpec,
|
||||
) {
|
||||
return requestClient.put<ProductVO.SpecInfo>(
|
||||
`/ec/product-spec/update/${id}`,
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品规格
|
||||
*/
|
||||
export async function deleteProductSpecApi(id: number) {
|
||||
return requestClient.delete(`/ec/product-spec/delete/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 精准查询API - 用于数据导入
|
||||
*/
|
||||
|
||||
/**
|
||||
* 根据名称精准查询商品
|
||||
*/
|
||||
export async function getProductByNameApi(name: string) {
|
||||
return requestClient.get<ProductVO.Info>(
|
||||
`/ec/product/find-by-name/${encodeURIComponent(name)}`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量根据名称查询商品
|
||||
*/
|
||||
export async function getProductsByNamesApi(names: string[]) {
|
||||
return requestClient.post<ProductVO.Info[]>(
|
||||
'/ec/product/find-by-names',
|
||||
names,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商品名称和规格编码精准查询商品规格
|
||||
*/
|
||||
export async function getProductSpecByProductAndSpecApi(
|
||||
productName: string,
|
||||
specCode: string,
|
||||
) {
|
||||
return requestClient.get<ProductVO.SpecInfo>(
|
||||
`/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.Info[]>(
|
||||
'/ec/product-spec/find-by-product-and-specs',
|
||||
queries,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export * from './apis';
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './types.dto';
|
||||
export * from './types.vo';
|
||||
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* 商品相关DTO类型定义
|
||||
*/
|
||||
|
||||
export namespace ProductDTO {
|
||||
/** 创建商品参数 */
|
||||
export interface Create {
|
||||
/** 商品名称 */
|
||||
name: string;
|
||||
/** 商品编码 */
|
||||
productCode?: string;
|
||||
/** 主图图片ID */
|
||||
mainImageId?: number;
|
||||
/** 商品规格列表(可选) */
|
||||
specs?: Spec[];
|
||||
}
|
||||
|
||||
/** 更新商品参数 */
|
||||
export interface Update {
|
||||
/** 商品名称 */
|
||||
name: string;
|
||||
/** 商品编码 */
|
||||
productCode?: string;
|
||||
/** 商品编码 */
|
||||
specCode?: string;
|
||||
/** 商品SKU */
|
||||
skuCode?: string;
|
||||
/** 主图图片ID */
|
||||
mainImageId?: number;
|
||||
/** 成本价 */
|
||||
costPrice: number;
|
||||
}
|
||||
|
||||
/** 商品规格DTO */
|
||||
export interface Spec {
|
||||
/** 规格名称 */
|
||||
name: string;
|
||||
/** 规格编码 */
|
||||
specCode?: string;
|
||||
/** 成本价 */
|
||||
costPrice: number;
|
||||
}
|
||||
|
||||
/** 创建商品规格参数 */
|
||||
export interface CreateSpec {
|
||||
/** 商品ID */
|
||||
productId: number;
|
||||
/** 规格名称 */
|
||||
name: string;
|
||||
/** 规格编码 */
|
||||
specCode?: string;
|
||||
/** 成本价 */
|
||||
costPrice: number;
|
||||
}
|
||||
|
||||
/** 更新商品规格参数 */
|
||||
export interface UpdateSpec {
|
||||
/** 规格名称 */
|
||||
name: string;
|
||||
/** 规格编码 */
|
||||
specCode?: string;
|
||||
/** 成本价 */
|
||||
costPrice: number;
|
||||
}
|
||||
|
||||
/** 商品过滤条件 */
|
||||
export interface Filters {
|
||||
/** 商品名称(模糊查询) */
|
||||
name?: string;
|
||||
/** 商品编码(模糊查询) */
|
||||
productCode?: string;
|
||||
/** 商品编码(模糊查询) */
|
||||
specCode?: string;
|
||||
/** 商品SKU(模糊查询) */
|
||||
skuCode?: string;
|
||||
/** 成本价范围-最小值 */
|
||||
minCostPrice?: number;
|
||||
/** 成本价范围-最大值 */
|
||||
maxCostPrice?: number;
|
||||
}
|
||||
|
||||
/** 商品规格过滤条件 */
|
||||
export interface SpecFilters {
|
||||
/** 商品ID */
|
||||
productId?: number;
|
||||
/** 商品名称(模糊查询) */
|
||||
productName?: string;
|
||||
/** 规格名称(模糊查询) */
|
||||
name?: string;
|
||||
/** 规格编码(模糊查询) */
|
||||
specCode?: string;
|
||||
/** 成本价范围-最小值 */
|
||||
minCostPrice?: number;
|
||||
/** 成本价范围-最大值 */
|
||||
maxCostPrice?: number;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* 商品相关VO类型定义
|
||||
*/
|
||||
|
||||
export namespace ProductVO {
|
||||
/** 商品信息 */
|
||||
export interface Info {
|
||||
/** 商品ID */
|
||||
id: number;
|
||||
/** 公司ID */
|
||||
companyId: number;
|
||||
/** 商品名称 */
|
||||
name: string;
|
||||
/** 商品编码 */
|
||||
productCode?: string;
|
||||
/** 主图URL(冗余字段) */
|
||||
mainImage?: string;
|
||||
/** 主图图片ID */
|
||||
mainImageId?: number;
|
||||
/** 创建时间 */
|
||||
createTime: string;
|
||||
/** 更新时间 */
|
||||
updateTime: string;
|
||||
/** 创建人ID */
|
||||
createBy?: number;
|
||||
/** 更新人ID */
|
||||
updateBy?: number;
|
||||
/** 商品规格列表 */
|
||||
specs?: SpecInfo[];
|
||||
}
|
||||
|
||||
/** 商品规格信息 */
|
||||
export interface SpecInfo {
|
||||
/** 规格ID */
|
||||
id: number;
|
||||
/** 公司ID */
|
||||
companyId: number;
|
||||
/** 商品ID */
|
||||
productId: number;
|
||||
/** 商品名称 */
|
||||
productName: string;
|
||||
/** 规格名称 */
|
||||
name: string;
|
||||
/** 规格编码 */
|
||||
specCode?: string;
|
||||
/** 成本价 */
|
||||
costPrice: number;
|
||||
/** 创建时间 */
|
||||
createTime: string;
|
||||
/** 更新时间 */
|
||||
updateTime: string;
|
||||
/** 创建人ID */
|
||||
createBy?: number;
|
||||
/** 更新人ID */
|
||||
updateBy?: number;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user