1
This commit is contained in:
106
api/cms/cmsProductSpec/index.ts
Normal file
106
api/cms/cmsProductSpec/index.ts
Normal file
@@ -0,0 +1,106 @@
|
||||
import request from '~/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { CmsProductSpec, CmsProductSpecParam } from './model';
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询规格
|
||||
*/
|
||||
export async function pageCmsProductSpec(params: CmsProductSpecParam) {
|
||||
const res = await request.get<ApiResult<PageResult<CmsProductSpec>>>(
|
||||
'/cms/cms-product-spec/page',
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
if (res.code === 0) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询规格列表
|
||||
*/
|
||||
export async function listCmsProductSpec(params?: CmsProductSpecParam) {
|
||||
const res = await request.get<ApiResult<CmsProductSpec[]>>(
|
||||
'/cms/cms-product-spec',
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
if (res.code === 0 && res.data) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加规格
|
||||
*/
|
||||
export async function addCmsProductSpec(data: CmsProductSpec) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
'/cms/cms-product-spec',
|
||||
data
|
||||
);
|
||||
if (res.code === 0) {
|
||||
return res.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改规格
|
||||
*/
|
||||
export async function updateCmsProductSpec(data: CmsProductSpec) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
'/cms/cms-product-spec',
|
||||
data
|
||||
);
|
||||
if (res.code === 0) {
|
||||
return res.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除规格
|
||||
*/
|
||||
export async function removeCmsProductSpec(id?: number) {
|
||||
const res = await request.del<ApiResult<unknown>>(
|
||||
'/cms/cms-product-spec/' + id
|
||||
);
|
||||
if (res.code === 0) {
|
||||
return res.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除规格
|
||||
*/
|
||||
export async function removeBatchCmsProductSpec(data: (number | undefined)[]) {
|
||||
const res = await request.del<ApiResult<unknown>>(
|
||||
'/cms/cms-product-spec/batch',
|
||||
{
|
||||
data
|
||||
}
|
||||
);
|
||||
if (res.code === 0) {
|
||||
return res.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询规格
|
||||
*/
|
||||
export async function getCmsProductSpec(id: number) {
|
||||
const res = await request.get<ApiResult<CmsProductSpec>>(
|
||||
'/cms/cms-product-spec/' + id
|
||||
);
|
||||
if (res.code === 0 && res.data) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.message));
|
||||
}
|
||||
35
api/cms/cmsProductSpec/model/index.ts
Normal file
35
api/cms/cmsProductSpec/model/index.ts
Normal file
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user