feat: 新增api接口文件

This commit is contained in:
吃货
2025-07-05 00:41:50 +08:00
parent 8b477131a2
commit e0080bb3e0
118 changed files with 8710 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
import type { PageParam, PageResult } from '@vben/request';
import { requestClient } from '#/api/request';
export namespace MallBrandApi {
/** 商品品牌 */
export interface Brand {
/** 品牌编号 */
id?: number;
/** 品牌名称 */
name: string;
/** 品牌图片 */
picUrl: string;
/** 品牌排序 */
sort?: number;
/** 品牌描述 */
description?: string;
/** 开启状态 */
status: number;
}
}
/** 创建商品品牌 */
export function createBrand(data: MallBrandApi.Brand) {
return requestClient.post('/product/brand/create', data);
}
/** 更新商品品牌 */
export function updateBrand(data: MallBrandApi.Brand) {
return requestClient.put('/product/brand/update', data);
}
/** 删除商品品牌 */
export function deleteBrand(id: number) {
return requestClient.delete(`/product/brand/delete?id=${id}`);
}
/** 获得商品品牌 */
export function getBrand(id: number) {
return requestClient.get<MallBrandApi.Brand>(`/product/brand/get?id=${id}`);
}
/** 获得商品品牌列表 */
export function getBrandPage(params: PageParam) {
return requestClient.get<PageResult<MallBrandApi.Brand>>(
'/product/brand/page',
{
params,
},
);
}
/** 获得商品品牌精简信息列表 */
export function getSimpleBrandList() {
return requestClient.get<MallBrandApi.Brand[]>(
'/product/brand/list-all-simple',
);
}

View File

@@ -0,0 +1,51 @@
import { requestClient } from '#/api/request';
export namespace MallCategoryApi {
/** 产品分类 */
export interface Category {
/** 分类编号 */
id?: number;
/** 父分类编号 */
parentId?: number;
/** 分类名称 */
name: string;
/** 移动端分类图 */
picUrl: string;
/** 分类排序 */
sort: number;
/** 开启状态 */
status: number;
}
}
/** 创建商品分类 */
export function createCategory(data: MallCategoryApi.Category) {
return requestClient.post('/product/category/create', data);
}
/** 更新商品分类 */
export function updateCategory(data: MallCategoryApi.Category) {
return requestClient.put('/product/category/update', data);
}
/** 删除商品分类 */
export function deleteCategory(id: number) {
return requestClient.delete(`/product/category/delete?id=${id}`);
}
/** 获得商品分类 */
export function getCategory(id: number) {
return requestClient.get<MallCategoryApi.Category>(
`/product/category/get?id=${id}`,
);
}
/** 获得商品分类列表 */
export function getCategoryList(params: any) {
return requestClient.get<MallCategoryApi.Category[]>(
'/product/category/list',
{
params,
},
);
}

View File

@@ -0,0 +1,81 @@
import type { PageParam, PageResult } from '@vben/request';
import { requestClient } from '#/api/request';
export namespace MallCommentApi {
export interface Property {
propertyId: number;
propertyName: string;
valueId: number;
valueName: string;
}
/** 商品评论 */
export interface Comment {
id: number;
userId: number;
userNickname: string;
userAvatar: string;
anonymous: boolean;
orderId: number;
orderItemId: number;
spuId: number;
spuName: string;
skuId: number;
visible: boolean;
scores: number;
descriptionScores: number;
benefitScores: number;
content: string;
picUrls: string[];
replyStatus: boolean;
replyUserId: number;
replyContent: string;
replyTime: Date;
createTime: Date;
skuProperties: Property[];
}
/** 评论可见性更新 */
export interface CommentVisibleUpdate {
id: number;
visible: boolean;
}
/** 评论回复 */
export interface CommentReply {
id: number;
replyContent: string;
}
}
/** 查询商品评论列表 */
export function getCommentPage(params: PageParam) {
return requestClient.get<PageResult<MallCommentApi.Comment>>(
'/product/comment/page',
{ params },
);
}
/** 查询商品评论详情 */
export function getComment(id: number) {
return requestClient.get<MallCommentApi.Comment>(
`/product/comment/get?id=${id}`,
);
}
/** 添加自评 */
export function createComment(data: MallCommentApi.Comment) {
return requestClient.post('/product/comment/create', data);
}
/** 显示 / 隐藏评论 */
export function updateCommentVisible(
data: MallCommentApi.CommentVisibleUpdate,
) {
return requestClient.put('/product/comment/update-visible', data);
}
/** 商家回复 */
export function replyComment(data: MallCommentApi.CommentReply) {
return requestClient.put('/product/comment/reply', data);
}

View File

@@ -0,0 +1,23 @@
import type { PageParam, PageResult } from '@vben/request';
import { requestClient } from '#/api/request';
export namespace MallFavoriteApi {
/** 商品收藏 */
export interface Favorite {
/** 收藏编号 */
id?: number;
/** 用户编号 */
userId?: string;
/** 商品 SPU 编号 */
spuId?: null | number;
}
}
/** 获得商品收藏列表 */
export function getFavoritePage(params: PageParam) {
return requestClient.get<PageResult<MallFavoriteApi.Favorite>>(
'/product/favorite/page',
{ params },
);
}

View File

@@ -0,0 +1,29 @@
import type { PageParam, PageResult } from '@vben/request';
import { requestClient } from '#/api/request';
export namespace MallHistoryApi {
/** 商品浏览记录 */
export interface BrowseHistory {
/** 记录编号 */
id?: number;
/** 用户编号 */
userId?: number;
/** 商品 SPU 编号 */
spuId?: number;
/** 浏览时间 */
createTime?: Date;
}
}
/**
* 获得商品浏览记录分页
*
* @param params 请求参数
*/
export function getBrowseHistoryPage(params: PageParam) {
return requestClient.get<PageResult<MallHistoryApi.BrowseHistory>>(
'/product/browse-history/page',
{ params },
);
}

View File

@@ -0,0 +1,111 @@
import type { PageParam, PageResult } from '@vben/request';
import { requestClient } from '#/api/request';
export namespace MallPropertyApi {
/** 商品属性 */
export interface Property {
/** 属性编号 */
id?: number;
/** 名称 */
name: string;
/** 备注 */
remark?: string;
}
/** 属性值 */
export interface PropertyValue {
/** 属性值编号 */
id?: number;
/** 属性项的编号 */
propertyId?: number;
/** 名称 */
name: string;
/** 备注 */
remark?: string;
}
/** 属性值查询参数 */
export interface PropertyValueQuery extends PageParam {
propertyId?: number;
}
}
/** 创建属性项 */
export function createProperty(data: MallPropertyApi.Property) {
return requestClient.post('/product/property/create', data);
}
/** 更新属性项 */
export function updateProperty(data: MallPropertyApi.Property) {
return requestClient.put('/product/property/update', data);
}
/** 删除属性项 */
export function deleteProperty(id: number) {
return requestClient.delete(`/product/property/delete?id=${id}`);
}
/** 获得属性项 */
export function getProperty(id: number) {
return requestClient.get<MallPropertyApi.Property>(
`/product/property/get?id=${id}`,
);
}
/** 获得属性项分页 */
export function getPropertyPage(params: PageParam) {
return requestClient.get<PageResult<MallPropertyApi.Property>>(
'/product/property/page',
{ params },
);
}
/** 获得属性项精简列表 */
export function getPropertySimpleList() {
return requestClient.get<MallPropertyApi.Property[]>(
'/product/property/simple-list',
);
}
/** 获得属性值分页 */
export function getPropertyValuePage(
params: MallPropertyApi.PropertyValueQuery,
) {
return requestClient.get<PageResult<MallPropertyApi.PropertyValue>>(
'/product/property/value/page',
{ params },
);
}
/** 获得属性值 */
export function getPropertyValue(id: number) {
return requestClient.get<MallPropertyApi.PropertyValue>(
`/product/property/value/get?id=${id}`,
);
}
/** 创建属性值 */
export function createPropertyValue(data: MallPropertyApi.PropertyValue) {
return requestClient.post('/product/property/value/create', data);
}
/** 更新属性值 */
export function updatePropertyValue(data: MallPropertyApi.PropertyValue) {
return requestClient.put('/product/property/value/update', data);
}
/** 删除属性值 */
export function deletePropertyValue(id: number) {
return requestClient.delete(`/product/property/value/delete?id=${id}`);
}
/** 获得属性值精简列表 */
export function getPropertyValueSimpleList(propertyId: number) {
return requestClient.get<MallPropertyApi.PropertyValue[]>(
'/product/property/value/simple-list',
{
params: { propertyId },
},
);
}

View File

@@ -0,0 +1,177 @@
import type { PageParam, PageResult } from '@vben/request';
import { requestClient } from '#/api/request';
export namespace MallSpuApi {
/** 商品属性 */
export interface Property {
/** 属性编号 */
propertyId?: number;
/** 属性名称 */
propertyName?: string;
/** 属性值编号 */
valueId?: number;
/** 属性值名称 */
valueName?: string;
}
/** 商品 SKU */
export interface Sku {
/** 商品 SKU 编号 */
id?: number;
/** 商品 SKU 名称 */
name?: string;
/** SPU 编号 */
spuId?: number;
/** 属性数组 */
properties?: Property[];
/** 商品价格 */
price?: number | string;
/** 市场价 */
marketPrice?: number | string;
/** 成本价 */
costPrice?: number | string;
/** 商品条码 */
barCode?: string;
/** 图片地址 */
picUrl?: string;
/** 库存 */
stock?: number;
/** 商品重量单位kg 千克 */
weight?: number;
/** 商品体积单位m^3 平米 */
volume?: number;
/** 一级分销的佣金 */
firstBrokeragePrice?: number | string;
/** 二级分销的佣金 */
secondBrokeragePrice?: number | string;
/** 商品销量 */
salesCount?: number;
}
/** 优惠券模板 */
export interface GiveCouponTemplate {
/** 优惠券编号 */
id?: number;
/** 优惠券名称 */
name?: string;
}
/** 商品 SPU */
export interface Spu {
/** 商品编号 */
id?: number;
/** 商品名称 */
name?: string;
/** 商品分类 */
categoryId?: number;
/** 关键字 */
keyword?: string;
/** 单位 */
unit?: number | undefined;
/** 商品封面图 */
picUrl?: string;
/** 商品轮播图 */
sliderPicUrls?: string[];
/** 商品简介 */
introduction?: string;
/** 配送方式 */
deliveryTypes?: number[];
/** 运费模版 */
deliveryTemplateId?: number | undefined;
/** 商品品牌编号 */
brandId?: number;
/** 商品规格 */
specType?: boolean;
/** 分销类型 */
subCommissionType?: boolean;
/** sku数组 */
skus?: Sku[];
/** 商品详情 */
description?: string;
/** 商品排序 */
sort?: number;
/** 赠送积分 */
giveIntegral?: number;
/** 虚拟销量 */
virtualSalesCount?: number;
/** 商品价格 */
price?: number;
/** 商品拼团价格 */
combinationPrice?: number;
/** 商品秒杀价格 */
seckillPrice?: number;
/** 商品销量 */
salesCount?: number;
/** 市场价 */
marketPrice?: number;
/** 成本价 */
costPrice?: number;
/** 商品库存 */
stock?: number;
/** 商品创建时间 */
createTime?: Date;
/** 商品状态 */
status?: number;
}
/** 商品状态更新 */
export interface StatusUpdate {
/** 商品编号 */
id: number;
/** 商品状态 */
status: number;
}
}
/** 获得商品 SPU 列表 */
export function getSpuPage(params: PageParam) {
return requestClient.get<PageResult<MallSpuApi.Spu>>('/product/spu/page', {
params,
});
}
/** 获得商品 SPU 列表 tabsCount */
export function getTabsCount() {
return requestClient.get<Record<string, number>>('/product/spu/get-count');
}
/** 创建商品 SPU */
export function createSpu(data: MallSpuApi.Spu) {
return requestClient.post('/product/spu/create', data);
}
/** 更新商品 SPU */
export function updateSpu(data: MallSpuApi.Spu) {
return requestClient.put('/product/spu/update', data);
}
/** 更新商品 SPU 状态 */
export function updateStatus(data: MallSpuApi.StatusUpdate) {
return requestClient.put('/product/spu/update-status', data);
}
/** 获得商品 SPU */
export function getSpu(id: number) {
return requestClient.get<MallSpuApi.Spu>(`/product/spu/get-detail?id=${id}`);
}
/** 获得商品 SPU 详情列表 */
export function getSpuDetailList(ids: number[]) {
return requestClient.get<MallSpuApi.Spu[]>(`/product/spu/list?spuIds=${ids}`);
}
/** 删除商品 SPU */
export function deleteSpu(id: number) {
return requestClient.delete(`/product/spu/delete?id=${id}`);
}
/** 导出商品 SPU Excel */
export function exportSpu(params: PageParam) {
return requestClient.download('/product/spu/export-excel', { params });
}
/** 获得商品 SPU 精简列表 */
export function getSpuSimpleList() {
return requestClient.get<MallSpuApi.Spu[]>('/product/spu/list-all-simple');
}