forked from gxwebsoft/mp-10550
提交代码
This commit is contained in:
101
src/api/shop/shopGoodsCategory/index.ts
Normal file
101
src/api/shop/shopGoodsCategory/index.ts
Normal file
@@ -0,0 +1,101 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api/index';
|
||||
import type { ShopGoodsCategory, ShopGoodsCategoryParam } from './model';
|
||||
|
||||
/**
|
||||
* 分页查询商品分类
|
||||
*/
|
||||
export async function pageShopGoodsCategory(params: ShopGoodsCategoryParam) {
|
||||
const res = await request.get<ApiResult<PageResult<ShopGoodsCategory>>>(
|
||||
'/shop/shop-goods-category/page',
|
||||
params
|
||||
);
|
||||
if (res.code === 0) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询商品分类列表
|
||||
*/
|
||||
export async function listShopGoodsCategory(params?: ShopGoodsCategoryParam) {
|
||||
const res = await request.get<ApiResult<ShopGoodsCategory[]>>(
|
||||
'/shop/shop-goods-category',
|
||||
params
|
||||
);
|
||||
if (res.code === 0 && res.data) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加商品分类
|
||||
*/
|
||||
export async function addShopGoodsCategory(data: ShopGoodsCategory) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
'/shop/shop-goods-category',
|
||||
data
|
||||
);
|
||||
if (res.code === 0) {
|
||||
return res.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改商品分类
|
||||
*/
|
||||
export async function updateShopGoodsCategory(data: ShopGoodsCategory) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
'/shop/shop-goods-category',
|
||||
data
|
||||
);
|
||||
if (res.code === 0) {
|
||||
return res.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品分类
|
||||
*/
|
||||
export async function removeShopGoodsCategory(id?: number) {
|
||||
const res = await request.del<ApiResult<unknown>>(
|
||||
'/shop/shop-goods-category/' + id
|
||||
);
|
||||
if (res.code === 0) {
|
||||
return res.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除商品分类
|
||||
*/
|
||||
export async function removeBatchShopGoodsCategory(data: (number | undefined)[]) {
|
||||
const res = await request.del<ApiResult<unknown>>(
|
||||
'/shop/shop-goods-category/batch',
|
||||
{
|
||||
data
|
||||
}
|
||||
);
|
||||
if (res.code === 0) {
|
||||
return res.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询商品分类
|
||||
*/
|
||||
export async function getShopGoodsCategory(id: number) {
|
||||
const res = await request.get<ApiResult<ShopGoodsCategory>>(
|
||||
'/shop/shop-goods-category/' + id
|
||||
);
|
||||
if (res.code === 0 && res.data) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
64
src/api/shop/shopGoodsCategory/model/index.ts
Normal file
64
src/api/shop/shopGoodsCategory/model/index.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import type { PageParam } from '@/api/index';
|
||||
|
||||
/**
|
||||
* 商品分类
|
||||
*/
|
||||
export interface ShopGoodsCategory {
|
||||
// 商品分类ID
|
||||
categoryId?: number;
|
||||
// 分类标识
|
||||
categoryCode?: string;
|
||||
// 分类名称
|
||||
title?: string;
|
||||
// 类型 0商城分类 1外卖分类
|
||||
type?: number;
|
||||
// 分类图片
|
||||
image?: string;
|
||||
// 上级分类ID
|
||||
parentId?: number;
|
||||
// 路由/链接地址
|
||||
path?: string;
|
||||
// 组件路径
|
||||
component?: string;
|
||||
// 绑定的页面
|
||||
pageId?: number;
|
||||
// 用户ID
|
||||
userId?: number;
|
||||
// 商品数量
|
||||
count?: number;
|
||||
// 排序(数字越小越靠前)
|
||||
sortNumber?: number;
|
||||
// 备注
|
||||
comments?: string;
|
||||
// 是否隐藏, 0否, 1是(仅注册路由不显示在左侧菜单)
|
||||
hide?: number;
|
||||
// 是否推荐
|
||||
recommend?: number;
|
||||
// 是否显示在首页
|
||||
showIndex?: number;
|
||||
// 商铺ID
|
||||
merchantId?: number;
|
||||
// 状态, 0正常, 1禁用
|
||||
status?: number;
|
||||
// 是否删除, 0否, 1是
|
||||
deleted?: number;
|
||||
// 租户id
|
||||
tenantId?: number;
|
||||
// 注册时间
|
||||
createTime?: string;
|
||||
// 修改时间
|
||||
updateTime?: string;
|
||||
// 子菜单
|
||||
children?: ShopGoodsCategory[];
|
||||
key?: number;
|
||||
value?: number;
|
||||
label?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品分类搜索条件
|
||||
*/
|
||||
export interface ShopGoodsCategoryParam extends PageParam {
|
||||
categoryId?: number;
|
||||
keywords?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user