初始化
This commit is contained in:
116
api/shop/goods/index.ts
Normal file
116
api/shop/goods/index.ts
Normal file
@@ -0,0 +1,116 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { Goods, GoodsParam } from './model';
|
||||
import { MODULES_API_URL } from '@/config';
|
||||
|
||||
export async function getCount(params: GoodsParam) {
|
||||
const res = await request.get(MODULES_API_URL + '/shop/goods/data', {
|
||||
params
|
||||
});
|
||||
if (res.data.code === 0) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询商品记录表
|
||||
*/
|
||||
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));
|
||||
}
|
||||
114
api/shop/goods/model/index.ts
Normal file
114
api/shop/goods/model/index.ts
Normal file
@@ -0,0 +1,114 @@
|
||||
import type { PageParam } from '@/api';
|
||||
import type { GoodsSpec } from "@/api/shop/goodsSpec/model";
|
||||
import type { GoodsSku } from "@/api/shop/goodsSku/model";
|
||||
import type {Merchant} from "~/api/shop/merchant/model";
|
||||
|
||||
export interface GoodsCount {
|
||||
totalNum: number;
|
||||
totalNum2: number;
|
||||
totalNum3: number;
|
||||
totalNum4: number;
|
||||
}
|
||||
/**
|
||||
* 商品记录表
|
||||
*/
|
||||
export interface Goods {
|
||||
// 自增ID
|
||||
goodsId?: number;
|
||||
// 类型 1实物商品 2虚拟商品
|
||||
type?: number;
|
||||
// 商品编码
|
||||
code?: string;
|
||||
// 商品标题
|
||||
goodsName?: string;
|
||||
// 商品封面图
|
||||
image?: string;
|
||||
// 商品详情
|
||||
content?: string;
|
||||
// 商品分类ID
|
||||
categoryId?: number;
|
||||
// 一级分类
|
||||
categoryParent?: string;
|
||||
// 二级分类
|
||||
categoryChildren?: string;
|
||||
// 商品规格 0单规格 1多规格
|
||||
specs?: number;
|
||||
// 货架
|
||||
position?: string;
|
||||
// 进货价格
|
||||
price?: number;
|
||||
// 销售价格
|
||||
salePrice?: number;
|
||||
// 库存计算方式(10下单减库存 20付款减库存)
|
||||
deductStockType?: number;
|
||||
// 封面图
|
||||
files?: string;
|
||||
// 封面图数组
|
||||
filesImgs?: any;
|
||||
// 销量
|
||||
sales?: number;
|
||||
// 库存
|
||||
stock?: number;
|
||||
// 商品重量
|
||||
goodsWeight?: number;
|
||||
// 消费赚取积分
|
||||
gainIntegral?: number;
|
||||
// 推荐
|
||||
recommend?: number;
|
||||
// 商户ID
|
||||
merchantId?: number;
|
||||
// 商户名称
|
||||
merchantName?: string;
|
||||
// 状态(0:未上架,1:上架)
|
||||
isShow?: number;
|
||||
// 状态, 0上架 1待上架 2待审核 3审核不通过
|
||||
status?: number;
|
||||
// 备注
|
||||
comments?: string;
|
||||
// 排序号
|
||||
sortNumber?: number;
|
||||
// 用户ID
|
||||
userId?: number;
|
||||
// 是否删除, 0否, 1是
|
||||
deleted?: number;
|
||||
// 租户id
|
||||
tenantId?: number;
|
||||
// 创建时间
|
||||
createTime?: string;
|
||||
// 修改时间
|
||||
updateTime?: string;
|
||||
// 显示规格名
|
||||
specName?: string;
|
||||
// 商品规格
|
||||
goodsSpecs?: GoodsSpec[];
|
||||
// 商品sku列表
|
||||
goodsSkus?: GoodsSku[];
|
||||
// 单位名称
|
||||
unitName?: string;
|
||||
// 购买数量
|
||||
num?: number;
|
||||
radio?: any;
|
||||
// 店铺信息
|
||||
merchant?: Merchant;
|
||||
}
|
||||
|
||||
export interface BathSet {
|
||||
|
||||
price?: number;
|
||||
salePrice?: number;
|
||||
stock?: number;
|
||||
skuNo?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品记录表搜索条件
|
||||
*/
|
||||
export interface GoodsParam extends PageParam {
|
||||
parentId?: number;
|
||||
categoryId?: number;
|
||||
goodsId?: number;
|
||||
goodsName?: string;
|
||||
isShow?: number;
|
||||
stock?: number;
|
||||
keywords?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user