新增:产品管理模块
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { CmsArticle, CmsArticleParam } from './model';
|
||||
import { MODULES_API_URL, SERVER_API_URL } from "@/config/setting";
|
||||
import type { ArticleParam } from "@/api/cms/article/model";
|
||||
import { SERVER_API_URL } from '@/config/setting';
|
||||
import type { ArticleParam } from '@/api/cms/article/model';
|
||||
|
||||
/**
|
||||
* 分页查询文章
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { CmsProduct, CmsProductParam } from './model';
|
||||
import { SERVER_API_URL } from '@/config/setting';
|
||||
import type { ArticleParam } from "@/api/cms/article/model";
|
||||
|
||||
/**
|
||||
* 分页查询产品
|
||||
*/
|
||||
export async function pageCmsProduct(params: CmsProductParam) {
|
||||
const res = await request.get<ApiResult<PageResult<CmsProduct>>>(
|
||||
SERVER_API_URL + '/cms/cms-product/page',
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询产品列表
|
||||
*/
|
||||
export async function listCmsProduct(params?: CmsProductParam) {
|
||||
const res = await request.get<ApiResult<CmsProduct[]>>(
|
||||
SERVER_API_URL + '/cms/cms-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 addCmsProduct(data: CmsProduct) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
SERVER_API_URL + '/cms/cms-product',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改产品
|
||||
*/
|
||||
export async function updateCmsProduct(data: CmsProduct) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
SERVER_API_URL + '/cms/cms-product',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除产品
|
||||
*/
|
||||
export async function removeCmsProduct(id?: number) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
SERVER_API_URL + '/cms/cms-product/' + id
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除产品
|
||||
*/
|
||||
export async function removeBatchCmsProduct(data: (number | undefined)[]) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
SERVER_API_URL + '/cms/cms-product/batch',
|
||||
{
|
||||
data
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询产品
|
||||
*/
|
||||
export async function getCmsProduct(id: number) {
|
||||
const res = await request.get<ApiResult<CmsProduct>>(
|
||||
SERVER_API_URL + '/cms/cms-product/' + id
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
export async function getCount(params: ArticleParam) {
|
||||
const res = await request.get(SERVER_API_URL + '/cms/cms-product/data', {
|
||||
params
|
||||
});
|
||||
if (res.data.code === 0) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import type { PageParam } from '@/api';
|
||||
|
||||
/**
|
||||
* 产品
|
||||
*/
|
||||
export interface CmsProduct {
|
||||
// 自增ID
|
||||
productId?: number;
|
||||
// 类型 0软件产品 1实物商品 2虚拟商品
|
||||
type?: number;
|
||||
// 产品编码
|
||||
code?: string;
|
||||
// 产品标题
|
||||
title?: string;
|
||||
// 封面图
|
||||
image?: string;
|
||||
// 产品详情
|
||||
content?: string;
|
||||
// 父级分类ID
|
||||
parentId?: number;
|
||||
// 产品分类ID
|
||||
categoryId?: number;
|
||||
// 产品规格 0单规格 1多规格
|
||||
specs?: number;
|
||||
// 货架
|
||||
position?: string;
|
||||
// 单位名称 (个)
|
||||
unitName?: string;
|
||||
// 进货价格
|
||||
price?: string;
|
||||
// 销售价格
|
||||
salePrice?: string;
|
||||
// 库存计算方式(10下单减库存 20付款减库存)
|
||||
deductStockType?: number;
|
||||
// 轮播图
|
||||
files?: string;
|
||||
// 销量
|
||||
sales?: number;
|
||||
// 库存
|
||||
stock?: number;
|
||||
// 消费赚取积分
|
||||
gainIntegral?: string;
|
||||
// 推荐
|
||||
recommend?: number;
|
||||
// 商户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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 产品搜索条件
|
||||
*/
|
||||
export interface CmsProductParam extends PageParam {
|
||||
productId?: number;
|
||||
status?: number;
|
||||
keywords?: string;
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { CmsProductSpec, CmsProductSpecParam } from './model';
|
||||
import { MODULES_API_URL } from '@/config/setting';
|
||||
|
||||
/**
|
||||
* 分页查询规格
|
||||
*/
|
||||
export async function pageCmsProductSpec(params: CmsProductSpecParam) {
|
||||
const res = await request.get<ApiResult<PageResult<CmsProductSpec>>>(
|
||||
MODULES_API_URL + '/cms/cms-product-spec/page',
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询规格列表
|
||||
*/
|
||||
export async function listCmsProductSpec(params?: CmsProductSpecParam) {
|
||||
const res = await request.get<ApiResult<CmsProductSpec[]>>(
|
||||
MODULES_API_URL + '/cms/cms-product-spec',
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加规格
|
||||
*/
|
||||
export async function addCmsProductSpec(data: CmsProductSpec) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/cms/cms-product-spec',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改规格
|
||||
*/
|
||||
export async function updateCmsProductSpec(data: CmsProductSpec) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/cms/cms-product-spec',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除规格
|
||||
*/
|
||||
export async function removeCmsProductSpec(id?: number) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/cms/cms-product-spec/' + id
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除规格
|
||||
*/
|
||||
export async function removeBatchCmsProductSpec(data: (number | undefined)[]) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/cms/cms-product-spec/batch',
|
||||
{
|
||||
data
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询规格
|
||||
*/
|
||||
export async function getCmsProductSpec(id: number) {
|
||||
const res = await request.get<ApiResult<CmsProductSpec>>(
|
||||
MODULES_API_URL + '/cms/cms-product-spec/' + id
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import type { PageParam } from '@/api';
|
||||
|
||||
/**
|
||||
* 规格
|
||||
*/
|
||||
export interface CmsProductSpec {
|
||||
// 规格ID
|
||||
specId?: number;
|
||||
// 规格名称
|
||||
specName?: string;
|
||||
// 规格值
|
||||
specValue?: string;
|
||||
// 创建用户
|
||||
userId?: number;
|
||||
// 更新者
|
||||
updater?: number;
|
||||
// 备注
|
||||
comments?: string;
|
||||
// 状态, 0正常, 1待修,2异常已修,3异常未修
|
||||
status?: number;
|
||||
// 排序号
|
||||
sortNumber?: number;
|
||||
// 租户id
|
||||
tenantId?: number;
|
||||
// 创建时间
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 规格搜索条件
|
||||
*/
|
||||
export interface CmsProductSpecParam extends PageParam {
|
||||
specId?: number;
|
||||
keywords?: string;
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { CmsProductSpecValue, CmsProductSpecValueParam } from './model';
|
||||
import { MODULES_API_URL } from '@/config/setting';
|
||||
|
||||
/**
|
||||
* 分页查询规格值
|
||||
*/
|
||||
export async function pageCmsProductSpecValue(params: CmsProductSpecValueParam) {
|
||||
const res = await request.get<ApiResult<PageResult<CmsProductSpecValue>>>(
|
||||
MODULES_API_URL + '/cms/cms-product-spec-value/page',
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询规格值列表
|
||||
*/
|
||||
export async function listCmsProductSpecValue(params?: CmsProductSpecValueParam) {
|
||||
const res = await request.get<ApiResult<CmsProductSpecValue[]>>(
|
||||
MODULES_API_URL + '/cms/cms-product-spec-value',
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加规格值
|
||||
*/
|
||||
export async function addCmsProductSpecValue(data: CmsProductSpecValue) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/cms/cms-product-spec-value',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改规格值
|
||||
*/
|
||||
export async function updateCmsProductSpecValue(data: CmsProductSpecValue) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/cms/cms-product-spec-value',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除规格值
|
||||
*/
|
||||
export async function removeCmsProductSpecValue(id?: number) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/cms/cms-product-spec-value/' + id
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除规格值
|
||||
*/
|
||||
export async function removeBatchCmsProductSpecValue(data: (number | undefined)[]) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/cms/cms-product-spec-value/batch',
|
||||
{
|
||||
data
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询规格值
|
||||
*/
|
||||
export async function getCmsProductSpecValue(id: number) {
|
||||
const res = await request.get<ApiResult<CmsProductSpecValue>>(
|
||||
MODULES_API_URL + '/cms/cms-product-spec-value/' + id
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import type { PageParam } from '@/api';
|
||||
|
||||
/**
|
||||
* 规格值
|
||||
*/
|
||||
export interface CmsProductSpecValue {
|
||||
// 规格值ID
|
||||
specValueId?: number;
|
||||
// 规格组ID
|
||||
specId?: number;
|
||||
// 规格值
|
||||
specValue?: string;
|
||||
// 备注
|
||||
comments?: string;
|
||||
// 排序号
|
||||
sortNumber?: number;
|
||||
// 租户id
|
||||
tenantId?: number;
|
||||
// 创建时间
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 规格值搜索条件
|
||||
*/
|
||||
export interface CmsProductSpecValueParam extends PageParam {
|
||||
specValueId?: number;
|
||||
keywords?: string;
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { CmsProductUrl, CmsProductUrlParam } from './model';
|
||||
import { MODULES_API_URL } from '@/config/setting';
|
||||
|
||||
/**
|
||||
* 分页查询域名
|
||||
*/
|
||||
export async function pageCmsProductUrl(params: CmsProductUrlParam) {
|
||||
const res = await request.get<ApiResult<PageResult<CmsProductUrl>>>(
|
||||
MODULES_API_URL + '/cms/cms-product-url/page',
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询域名列表
|
||||
*/
|
||||
export async function listCmsProductUrl(params?: CmsProductUrlParam) {
|
||||
const res = await request.get<ApiResult<CmsProductUrl[]>>(
|
||||
MODULES_API_URL + '/cms/cms-product-url',
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加域名
|
||||
*/
|
||||
export async function addCmsProductUrl(data: CmsProductUrl) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/cms/cms-product-url',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改域名
|
||||
*/
|
||||
export async function updateCmsProductUrl(data: CmsProductUrl) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/cms/cms-product-url',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除域名
|
||||
*/
|
||||
export async function removeCmsProductUrl(id?: number) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/cms/cms-product-url/' + id
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除域名
|
||||
*/
|
||||
export async function removeBatchCmsProductUrl(data: (number | undefined)[]) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/cms/cms-product-url/batch',
|
||||
{
|
||||
data
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询域名
|
||||
*/
|
||||
export async function getCmsProductUrl(id: number) {
|
||||
const res = await request.get<ApiResult<CmsProductUrl>>(
|
||||
MODULES_API_URL + '/cms/cms-product-url/' + id
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import type { PageParam } from '@/api';
|
||||
|
||||
/**
|
||||
* 域名
|
||||
*/
|
||||
export interface CmsProductUrl {
|
||||
// 自增ID
|
||||
id?: number;
|
||||
// 产品ID
|
||||
productId?: number;
|
||||
// 域名类型
|
||||
type?: string;
|
||||
// 域名
|
||||
domain?: string;
|
||||
// 账号
|
||||
account?: string;
|
||||
// 密码
|
||||
password?: string;
|
||||
// 商户ID
|
||||
merchantId?: number;
|
||||
// 备注
|
||||
comments?: string;
|
||||
// 排序(数字越小越靠前)
|
||||
sortNumber?: number;
|
||||
// 状态, 0正常, 1待确认
|
||||
status?: number;
|
||||
// 创建时间
|
||||
createTime?: string;
|
||||
// 租户id
|
||||
tenantId?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 域名搜索条件
|
||||
*/
|
||||
export interface CmsProductUrlParam extends PageParam {
|
||||
id?: number;
|
||||
keywords?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user