初始化
This commit is contained in:
120
api/oa/product/index.ts
Normal file
120
api/oa/product/index.ts
Normal file
@@ -0,0 +1,120 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { Product, ProductParam } from './model';
|
||||
|
||||
/**
|
||||
* 分页查询产品
|
||||
*/
|
||||
export async function pageProduct(params: ProductParam) {
|
||||
const res = await request.get<ApiResult<PageResult<Product>>>(
|
||||
'/oa/product/page',
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询产品列表
|
||||
*/
|
||||
export async function listProduct(params?: ProductParam) {
|
||||
const res = await request.get<ApiResult<Product[]>>('/oa/product', {
|
||||
params
|
||||
});
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加产品
|
||||
*/
|
||||
export async function addProduct(data: Product) {
|
||||
const res = await request.post<ApiResult<unknown>>('/oa/product', data);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改产品
|
||||
*/
|
||||
export async function updateProduct(data: Product) {
|
||||
const res = await request.put<ApiResult<unknown>>('/oa/product', data);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除产品
|
||||
*/
|
||||
export async function removeProduct(id?: number) {
|
||||
const res = await request.delete<ApiResult<unknown>>('/oa/product/' + id);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除产品
|
||||
*/
|
||||
export async function removeBatchProduct(data: (number | undefined)[]) {
|
||||
const res = await request.delete<ApiResult<unknown>>('/oa/product/batch', {
|
||||
data
|
||||
});
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户状态
|
||||
*/
|
||||
export async function updateProductStatus(productId?: number, status?: number) {
|
||||
const res = await request.put<ApiResult<unknown>>('/oa/product/status', {
|
||||
productId,
|
||||
status
|
||||
});
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询产品
|
||||
*/
|
||||
export async function getProduct(id: number) {
|
||||
const res = await request.get<ApiResult<Product>>('/oa/product/' + id);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查IP是否存在
|
||||
*/
|
||||
export async function checkExistence(
|
||||
field: string,
|
||||
value: string,
|
||||
id?: number
|
||||
) {
|
||||
const res = await request.get<ApiResult<unknown>>('/oa/product/existence', {
|
||||
params: { field, value, id }
|
||||
});
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
94
api/oa/product/model/index.ts
Normal file
94
api/oa/product/model/index.ts
Normal file
@@ -0,0 +1,94 @@
|
||||
import type { PageParam } from '@/api';
|
||||
|
||||
/**
|
||||
* 产品
|
||||
*/
|
||||
export interface Product {
|
||||
// 自增ID
|
||||
productId?: number;
|
||||
// 类型 0软件产品 1实物商品 2虚拟商品
|
||||
type?: number;
|
||||
// 产品编码
|
||||
code?: string;
|
||||
// 产品标题
|
||||
title?: string;
|
||||
// 封面图
|
||||
image?: string;
|
||||
// 产品详情
|
||||
content?: string;
|
||||
// 父级分类ID
|
||||
parentId?: number;
|
||||
// 父级栏目名称
|
||||
parentName?: string;
|
||||
// 产品分类ID
|
||||
categoryId?: number;
|
||||
// 产品分类名称
|
||||
categoryName?: string;
|
||||
// 标签
|
||||
tag?: string;
|
||||
// 产品规格 0单规格 1多规格
|
||||
specs?: number;
|
||||
// 货架
|
||||
position?: string;
|
||||
// 单位名称 (个)
|
||||
unitName?: string;
|
||||
// 进货价格
|
||||
price?: number;
|
||||
// 销售价格
|
||||
salePrice?: number;
|
||||
// 库存计算方式(10下单减库存 20付款减库存)
|
||||
deductStockType?: number;
|
||||
// 启用交付方式
|
||||
deliveryMethod?: number;
|
||||
// 启用购买时长
|
||||
durationMethod?: number;
|
||||
// 启用套餐版本
|
||||
packageMethod?: number;
|
||||
// 最大可购买数量
|
||||
canBuyNumber?: number;
|
||||
// 轮播图
|
||||
files?: string;
|
||||
// 销量
|
||||
sales?: number;
|
||||
// 库存
|
||||
stock?: number;
|
||||
// 消费赚取积分
|
||||
gainIntegral?: string;
|
||||
// 推荐
|
||||
recommend?: number;
|
||||
// 是否官方自营
|
||||
official?: boolean;
|
||||
// 商户ID
|
||||
merchantId?: number;
|
||||
// 状态(0:未上架,1:上架)
|
||||
isShow?: string;
|
||||
// 状态, 0上架 1待上架 2待审核 3审核不通过
|
||||
status?: number;
|
||||
// 备注
|
||||
comments?: string;
|
||||
// 排序号
|
||||
sortNumber?: number;
|
||||
// 用户ID
|
||||
userId?: number;
|
||||
// 是否删除, 0否, 1是
|
||||
deleted?: number;
|
||||
// 租户id
|
||||
tenantId?: number;
|
||||
// 创建时间
|
||||
createTime?: string;
|
||||
// 修改时间
|
||||
updateTime?: string;
|
||||
// 购买数量
|
||||
num?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 产品搜索条件
|
||||
*/
|
||||
export interface ProductParam extends PageParam {
|
||||
productId?: number;
|
||||
type?: number;
|
||||
official?: boolean;
|
||||
status?: number;
|
||||
keywords?: string;
|
||||
}
|
||||
129
api/oa/product/tabs/index.ts
Normal file
129
api/oa/product/tabs/index.ts
Normal file
@@ -0,0 +1,129 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type {
|
||||
ProductTabs,
|
||||
ProductTabsParam
|
||||
} from '@/api/oa/product/tabs/model';
|
||||
import { MODULES_API_URL } from '@/config';
|
||||
|
||||
/**
|
||||
* 分页查询产品属性
|
||||
*/
|
||||
export async function pageProductTabs(params: ProductTabsParam) {
|
||||
const res = await request.get<ApiResult<PageResult<ProductTabs>>>(
|
||||
MODULES_API_URL + '/oa/product-tabs/page',
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询产品属性列表
|
||||
*/
|
||||
export async function listProductTabs(params?: ProductTabsParam) {
|
||||
const res = await request.get<ApiResult<ProductTabs[]>>(
|
||||
MODULES_API_URL + '/oa/product-tabs',
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询产品属性
|
||||
*/
|
||||
export async function getProductTabs(id: number) {
|
||||
const res = await request.get<ApiResult<ProductTabs>>(
|
||||
MODULES_API_URL + '/oa/product-tabs/' + id
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加产品属性
|
||||
*/
|
||||
export async function addProductTabs(data: ProductTabs) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/oa/product-tabs',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改产品属性
|
||||
*/
|
||||
export async function updateProductTabs(data: ProductTabs) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/oa/product-tabs',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除产品属性
|
||||
*/
|
||||
export async function removeProductTabs(id?: number) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/oa/product-tabs/' + id
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除产品属性
|
||||
*/
|
||||
export async function removeBatchProductTabs(data: (number | undefined)[]) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/oa/product-tabs/batch',
|
||||
{
|
||||
data
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查IP是否存在
|
||||
*/
|
||||
export async function checkExistence(
|
||||
field: string,
|
||||
value: string,
|
||||
id?: number
|
||||
) {
|
||||
const res = await request.get<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/oa/product-tabs/existence',
|
||||
{
|
||||
params: { field, value, id }
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
24
api/oa/product/tabs/model/index.ts
Normal file
24
api/oa/product/tabs/model/index.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import type { PageParam } from '@/api';
|
||||
|
||||
/**
|
||||
* 产品属性
|
||||
*/
|
||||
export interface ProductTabs {
|
||||
productId?: number;
|
||||
name?: string;
|
||||
type?: string;
|
||||
comments?: string;
|
||||
userId?: number;
|
||||
appId?: number;
|
||||
status?: any;
|
||||
sortNumber?: number;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 项目参数搜索条件
|
||||
*/
|
||||
export interface ProductTabsParam extends PageParam {
|
||||
productId?: number;
|
||||
userId?: number;
|
||||
}
|
||||
Reference in New Issue
Block a user