初始化
This commit is contained in:
126
api/cms/category/index.ts
Normal file
126
api/cms/category/index.ts
Normal file
@@ -0,0 +1,126 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { ArticleCategory, ArticleCategoryParam } from './model';
|
||||
import { MODULES_API_URL } from '~/config';
|
||||
|
||||
/**
|
||||
* 分页查询文章分类
|
||||
*/
|
||||
export async function pageArticleCategory(params: ArticleCategoryParam) {
|
||||
const res = await request.get<ApiResult<PageResult<ArticleCategory>>>(
|
||||
MODULES_API_URL + '/cms/article-category/page',
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询文章分类列表
|
||||
*/
|
||||
export async function listArticleCategory(params?: ArticleCategoryParam) {
|
||||
const res = await request.get<ApiResult<ArticleCategory[]>>(
|
||||
MODULES_API_URL + '/cms/article-category',
|
||||
{
|
||||
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 getArticleCategory(id: number) {
|
||||
const res = await request.get<ApiResult<ArticleCategory>>(
|
||||
MODULES_API_URL + '/cms/article-category/' + id
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加文章分类
|
||||
*/
|
||||
export async function addArticleCategory(data: ArticleCategory) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/cms/article-category',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改文章分类
|
||||
*/
|
||||
export async function updateArticleCategory(data: ArticleCategory) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/cms/article-category',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文章分类
|
||||
*/
|
||||
export async function removeArticleCategory(id?: number) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/cms/article-category/' + id
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除文章分类
|
||||
*/
|
||||
export async function removeBatchArticleCategory(data: (number | undefined)[]) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/cms/article-category/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 + '/cms/article-category/existence',
|
||||
{
|
||||
params: { field, value, id }
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
82
api/cms/category/model/index.ts
Normal file
82
api/cms/category/model/index.ts
Normal file
@@ -0,0 +1,82 @@
|
||||
import type { PageParam } from '@/api';
|
||||
|
||||
/**
|
||||
* 文章分类
|
||||
*/
|
||||
export interface ArticleCategory {
|
||||
// 文章分类id
|
||||
categoryId?: number;
|
||||
// 文章分类名称
|
||||
categoryName?: string;
|
||||
// 分类类型 0列表 1页面 2链接
|
||||
type?: number;
|
||||
// 文章分类
|
||||
title?: string;
|
||||
// 文章分类图片
|
||||
image?: string;
|
||||
// 路由/链接
|
||||
path?: string;
|
||||
// 组件路径
|
||||
component?: string;
|
||||
// 页面ID
|
||||
pageId?: number;
|
||||
// 页面名称
|
||||
pageName?: string;
|
||||
// 上级分类
|
||||
parentId?: number;
|
||||
// 上级分类名称
|
||||
parentName?: string;
|
||||
// 封面图
|
||||
avatar?: string;
|
||||
// 用户ID
|
||||
userId?: string;
|
||||
// 所属门店ID
|
||||
shopId?: string;
|
||||
// 排序
|
||||
sortNumber?: number;
|
||||
// 备注
|
||||
comments?: string;
|
||||
// 状态
|
||||
status?: number;
|
||||
// 是否显示在首页
|
||||
showIndex?: number;
|
||||
// 是否推荐
|
||||
recommend?: number;
|
||||
// 创建时间
|
||||
createTime?: string;
|
||||
// 更新时间
|
||||
updateTime?: string;
|
||||
key?: number;
|
||||
value?: number;
|
||||
// 子菜单
|
||||
children?: ArticleCategory[];
|
||||
tempPath?: string;
|
||||
disabled?: boolean;
|
||||
tenantId?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 整理分类用于网站导航栏
|
||||
*/
|
||||
export interface ArrangeCategory {
|
||||
categoryId?: number;
|
||||
type?: number;
|
||||
title?: string;
|
||||
parentId?: number;
|
||||
avatar?: string;
|
||||
path?: string;
|
||||
component?: string;
|
||||
pageId?: number;
|
||||
sortNumber?: number;
|
||||
comments?: string;
|
||||
status?: number;
|
||||
children?: ArrangeCategory[];
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章分类搜索条件
|
||||
*/
|
||||
export interface ArticleCategoryParam extends PageParam {
|
||||
title?: string;
|
||||
categoryId?: number;
|
||||
}
|
||||
Reference in New Issue
Block a user