初始化

This commit is contained in:
2024-07-10 13:50:01 +08:00
commit e30966c6c5
1073 changed files with 143076 additions and 0 deletions
+106
View File
@@ -0,0 +1,106 @@
import request from '@/utils/request';
import type { ApiResult, PageResult } from '@/api';
import type { Goods, GoodsParam } from './model';
import { MODULES_API_URL } from '@/config/setting';
/**
* 分页查询商品记录表
*/
export async function pageGoods(params: GoodsParam) {
const res = await request.get<ApiResult<PageResult<Goods>>>(
MODULES_API_URL + '/shop/goods/page',
{
params
}
);
if (res.data.code === 0) {
return res.data.data;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 查询商品记录表列表
*/
export async function listGoods(params?: GoodsParam) {
const res = await request.get<ApiResult<Goods[]>>(
MODULES_API_URL + '/shop/goods',
{
params
}
);
if (res.data.code === 0 && res.data.data) {
return res.data.data;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 添加商品记录表
*/
export async function addGoods(data: Goods) {
const res = await request.post<ApiResult<unknown>>(
MODULES_API_URL + '/shop/goods',
data
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 修改商品记录表
*/
export async function updateGoods(data: Goods) {
const res = await request.put<ApiResult<unknown>>(
MODULES_API_URL + '/shop/goods',
data
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 删除商品记录表
*/
export async function removeGoods(id?: number) {
const res = await request.delete<ApiResult<unknown>>(
MODULES_API_URL + '/shop/goods/' + id
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 批量删除商品记录表
*/
export async function removeBatchGoods(data: (number | undefined)[]) {
const res = await request.delete<ApiResult<unknown>>(
MODULES_API_URL + '/shop/goods/batch',
{
data
}
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 根据id查询商品记录表
*/
export async function getGoods(id: number) {
const res = await request.get<ApiResult<Goods>>(
MODULES_API_URL + '/shop/goods/' + id
);
if (res.data.code === 0 && res.data.data) {
return res.data.data;
}
return Promise.reject(new Error(res.data.message));
}
+83
View File
@@ -0,0 +1,83 @@
import type { PageParam } from '@/api';
import type {GoodsSpec} from "@/api/shop/goodsSpec/model";
import type {GoodsSku} from "@/api/shop/goodsSku/model";
/**
* 商品记录表
*/
export interface Goods {
// 自增ID
goodsId?: number;
// 类型 1实物商品 2虚拟商品
type?: number;
// 商品编码
code?: string;
// 商品名称
goodsName?: string;
// 商品封面图
image?: string;
// 商品详情
content?: string;
// 商品附件
files?: string;
// 分类ID
categoryId?: number;
categoryParent?: string;
categoryChildren?: string;
// 分类名称
categoryName?: string;
// 规格
specs?: number;
// 货架
position?: string;
// 进货价格
price?: number;
// 销售价格
salePrice?: string;
// 销量
sales?: number;
// 库存
stock?: number;
// 商品重量
goodsWeight?: number;
// 库存计算方式
deductStockType?: number;
// 推荐
recommend?: number;
// 状态, 0正常, 1待修,2异常已修,3异常未修
status?: number;
// 备注
comments?: string;
// 排序号
sortNumber?: number;
// 所有人
userId?: number;
merchantId?: number;
// 是否删除, 0否, 1是
deleted?: number;
// 租户id
tenantId?: number;
// 创建时间
createTime?: string;
// 修改时间
updateTime?: string;
// 商品规格
goodsSpecs?: GoodsSpec[];
// 商品sku列表
goodsSkus?: GoodsSku[];
}
export interface BathSet {
price?: number;
salePrice?: number;
stock?: number;
skuNo?: string;
}
/**
* 商品记录表搜索条件
*/
export interface GoodsParam extends PageParam {
goodsId?: number;
keywords?: string;
}