feat: mall api 添加mall统一前缀

This commit is contained in:
xingyu4j
2025-06-06 22:45:43 +08:00
parent dbb9a33fda
commit 1f598d7712
40 changed files with 281 additions and 255 deletions

View File

@@ -2,7 +2,7 @@ import type { PageParam, PageResult } from '@vben/request';
import { requestClient } from '#/api/request';
export namespace BrandApi {
export namespace MallBrandApi {
/** 商品品牌 */
export interface Brand {
/** 品牌编号 */
@@ -21,12 +21,12 @@ export namespace BrandApi {
}
/** 创建商品品牌 */
export function createBrand(data: BrandApi.Brand) {
export function createBrand(data: MallBrandApi.Brand) {
return requestClient.post('/product/brand/create', data);
}
/** 更新商品品牌 */
export function updateBrand(data: BrandApi.Brand) {
export function updateBrand(data: MallBrandApi.Brand) {
return requestClient.put('/product/brand/update', data);
}
@@ -37,17 +37,22 @@ export function deleteBrand(id: number) {
/** 获得商品品牌 */
export function getBrand(id: number) {
return requestClient.get<BrandApi.Brand>(`/product/brand/get?id=${id}`);
return requestClient.get<MallBrandApi.Brand>(`/product/brand/get?id=${id}`);
}
/** 获得商品品牌列表 */
export function getBrandPage(params: PageParam) {
return requestClient.get<PageResult<BrandApi.Brand>>('/product/brand/page', {
params,
});
return requestClient.get<PageResult<MallBrandApi.Brand>>(
'/product/brand/page',
{
params,
},
);
}
/** 获得商品品牌精简信息列表 */
export function getSimpleBrandList() {
return requestClient.get<BrandApi.Brand[]>('/product/brand/list-all-simple');
return requestClient.get<MallBrandApi.Brand[]>(
'/product/brand/list-all-simple',
);
}

View File

@@ -1,8 +1,6 @@
import type { PageParam, PageResult } from '@vben/request';
import { requestClient } from '#/api/request';
export namespace CategoryApi {
export namespace MallCategoryApi {
/** 产品分类 */
export interface Category {
/** 分类编号 */
@@ -21,12 +19,12 @@ export namespace CategoryApi {
}
/** 创建商品分类 */
export function createCategory(data: CategoryApi.Category) {
export function createCategory(data: MallCategoryApi.Category) {
return requestClient.post('/product/category/create', data);
}
/** 更新商品分类 */
export function updateCategory(data: CategoryApi.Category) {
export function updateCategory(data: MallCategoryApi.Category) {
return requestClient.put('/product/category/update', data);
}
@@ -37,15 +35,17 @@ export function deleteCategory(id: number) {
/** 获得商品分类 */
export function getCategory(id: number) {
return requestClient.get<CategoryApi.Category>(
return requestClient.get<MallCategoryApi.Category>(
`/product/category/get?id=${id}`,
);
}
/** 获得商品分类列表 */
export function getCategoryList(params: PageParam) {
return requestClient.get<PageResult<CategoryApi.Category>>(
export function getCategoryList(params: any) {
return requestClient.get<MallCategoryApi.Category[]>(
'/product/category/list',
{ params },
{
params,
},
);
}

View File

@@ -2,7 +2,7 @@ import type { PageParam, PageResult } from '@vben/request';
import { requestClient } from '#/api/request';
export namespace CommentApi {
export namespace MallCommentApi {
/** 商品评论 */
export interface Comment {
id: number;
@@ -42,7 +42,7 @@ export namespace CommentApi {
/** 查询商品评论列表 */
export function getCommentPage(params: PageParam) {
return requestClient.get<PageResult<CommentApi.Comment>>(
return requestClient.get<PageResult<MallCommentApi.Comment>>(
'/product/comment/page',
{ params },
);
@@ -50,20 +50,24 @@ export function getCommentPage(params: PageParam) {
/** 查询商品评论详情 */
export function getComment(id: number) {
return requestClient.get<CommentApi.Comment>(`/product/comment/get?id=${id}`);
return requestClient.get<MallCommentApi.Comment>(
`/product/comment/get?id=${id}`,
);
}
/** 添加自评 */
export function createComment(data: CommentApi.Comment) {
export function createComment(data: MallCommentApi.Comment) {
return requestClient.post('/product/comment/create', data);
}
/** 显示 / 隐藏评论 */
export function updateCommentVisible(data: CommentApi.CommentVisibleUpdate) {
export function updateCommentVisible(
data: MallCommentApi.CommentVisibleUpdate,
) {
return requestClient.put('/product/comment/update-visible', data);
}
/** 商家回复 */
export function replyComment(data: CommentApi.CommentReply) {
export function replyComment(data: MallCommentApi.CommentReply) {
return requestClient.put('/product/comment/reply', data);
}

View File

@@ -2,7 +2,7 @@ import type { PageParam, PageResult } from '@vben/request';
import { requestClient } from '#/api/request';
export namespace FavoriteApi {
export namespace MallFavoriteApi {
/** 商品收藏 */
export interface Favorite {
/** 收藏编号 */
@@ -16,7 +16,7 @@ export namespace FavoriteApi {
/** 获得商品收藏列表 */
export function getFavoritePage(params: PageParam) {
return requestClient.get<PageResult<FavoriteApi.Favorite>>(
return requestClient.get<PageResult<MallFavoriteApi.Favorite>>(
'/product/favorite/page',
{ params },
);

View File

@@ -2,7 +2,7 @@ import type { PageParam, PageResult } from '@vben/request';
import { requestClient } from '#/api/request';
export namespace HistoryApi {
export namespace MallHistoryApi {
/** 商品浏览记录 */
export interface BrowseHistory {
/** 记录编号 */
@@ -22,7 +22,7 @@ export namespace HistoryApi {
* @param params 请求参数
*/
export function getBrowseHistoryPage(params: PageParam) {
return requestClient.get<PageResult<HistoryApi.BrowseHistory>>(
return requestClient.get<PageResult<MallHistoryApi.BrowseHistory>>(
'/product/browse-history/page',
{ params },
);

View File

@@ -2,7 +2,7 @@ import type { PageParam, PageResult } from '@vben/request';
import { requestClient } from '#/api/request';
export namespace PropertyApi {
export namespace MallPropertyApi {
/** 商品属性 */
export interface Property {
/** 属性编号 */
@@ -32,12 +32,12 @@ export namespace PropertyApi {
}
/** 创建属性项 */
export function createProperty(data: PropertyApi.Property) {
export function createProperty(data: MallPropertyApi.Property) {
return requestClient.post('/product/property/create', data);
}
/** 更新属性项 */
export function updateProperty(data: PropertyApi.Property) {
export function updateProperty(data: MallPropertyApi.Property) {
return requestClient.put('/product/property/update', data);
}
@@ -48,14 +48,14 @@ export function deleteProperty(id: number) {
/** 获得属性项 */
export function getProperty(id: number) {
return requestClient.get<PropertyApi.Property>(
return requestClient.get<MallPropertyApi.Property>(
`/product/property/get?id=${id}`,
);
}
/** 获得属性项分页 */
export function getPropertyPage(params: PageParam) {
return requestClient.get<PageResult<PropertyApi.Property>>(
return requestClient.get<PageResult<MallPropertyApi.Property>>(
'/product/property/page',
{ params },
);
@@ -63,14 +63,16 @@ export function getPropertyPage(params: PageParam) {
/** 获得属性项精简列表 */
export function getPropertySimpleList() {
return requestClient.get<PropertyApi.Property[]>(
return requestClient.get<MallPropertyApi.Property[]>(
'/product/property/simple-list',
);
}
/** 获得属性值分页 */
export function getPropertyValuePage(params: PropertyApi.PropertyValueQuery) {
return requestClient.get<PageResult<PropertyApi.PropertyValue>>(
export function getPropertyValuePage(
params: MallPropertyApi.PropertyValueQuery,
) {
return requestClient.get<PageResult<MallPropertyApi.PropertyValue>>(
'/product/property/value/page',
{ params },
);
@@ -78,18 +80,18 @@ export function getPropertyValuePage(params: PropertyApi.PropertyValueQuery) {
/** 获得属性值 */
export function getPropertyValue(id: number) {
return requestClient.get<PropertyApi.PropertyValue>(
return requestClient.get<MallPropertyApi.PropertyValue>(
`/product/property/value/get?id=${id}`,
);
}
/** 创建属性值 */
export function createPropertyValue(data: PropertyApi.PropertyValue) {
export function createPropertyValue(data: MallPropertyApi.PropertyValue) {
return requestClient.post('/product/property/value/create', data);
}
/** 更新属性值 */
export function updatePropertyValue(data: PropertyApi.PropertyValue) {
export function updatePropertyValue(data: MallPropertyApi.PropertyValue) {
return requestClient.put('/product/property/value/update', data);
}
@@ -100,7 +102,7 @@ export function deletePropertyValue(id: number) {
/** 获得属性值精简列表 */
export function getPropertyValueSimpleList(propertyId: number) {
return requestClient.get<PropertyApi.PropertyValue[]>(
return requestClient.get<MallPropertyApi.PropertyValue[]>(
'/product/property/value/simple-list',
{
params: { propertyId },

View File

@@ -2,7 +2,7 @@ import type { PageParam, PageResult } from '@vben/request';
import { requestClient } from '#/api/request';
export namespace SpuApi {
export namespace MallSpuApi {
/** 商品属性 */
export interface Property {
/** 属性编号 */
@@ -126,7 +126,7 @@ export namespace SpuApi {
/** 获得商品 SPU 列表 */
export function getSpuPage(params: PageParam) {
return requestClient.get<PageResult<SpuApi.Spu>>('/product/spu/page', {
return requestClient.get<PageResult<MallSpuApi.Spu>>('/product/spu/page', {
params,
});
}
@@ -137,28 +137,28 @@ export function getTabsCount() {
}
/** 创建商品 SPU */
export function createSpu(data: SpuApi.Spu) {
export function createSpu(data: MallSpuApi.Spu) {
return requestClient.post('/product/spu/create', data);
}
/** 更新商品 SPU */
export function updateSpu(data: SpuApi.Spu) {
export function updateSpu(data: MallSpuApi.Spu) {
return requestClient.put('/product/spu/update', data);
}
/** 更新商品 SPU 状态 */
export function updateStatus(data: SpuApi.StatusUpdate) {
export function updateStatus(data: MallSpuApi.StatusUpdate) {
return requestClient.put('/product/spu/update-status', data);
}
/** 获得商品 SPU */
export function getSpu(id: number) {
return requestClient.get<SpuApi.Spu>(`/product/spu/get-detail?id=${id}`);
return requestClient.get<MallSpuApi.Spu>(`/product/spu/get-detail?id=${id}`);
}
/** 获得商品 SPU 详情列表 */
export function getSpuDetailList(ids: number[]) {
return requestClient.get<SpuApi.Spu[]>(`/product/spu/list?spuIds=${ids}`);
return requestClient.get<MallSpuApi.Spu[]>(`/product/spu/list?spuIds=${ids}`);
}
/** 删除商品 SPU */
@@ -173,5 +173,5 @@ export function exportSpu(params: PageParam) {
/** 获得商品 SPU 精简列表 */
export function getSpuSimpleList() {
return requestClient.get<SpuApi.Spu[]>('/product/spu/list-all-simple');
return requestClient.get<MallSpuApi.Spu[]>('/product/spu/list-all-simple');
}