重构小程序端管理模块
This commit is contained in:
@@ -67,13 +67,17 @@ export interface MpMenu {
|
||||
// 子菜单
|
||||
children?: MpMenu[];
|
||||
pageName?: string;
|
||||
groupName?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序端菜单搜索条件
|
||||
*/
|
||||
export interface MpMenuParam extends PageParam {
|
||||
parentId?: number;
|
||||
menuId?: number;
|
||||
pageId?: number;
|
||||
subpackage?: string;
|
||||
type?: number;
|
||||
keywords?: string;
|
||||
}
|
||||
|
||||
106
src/api/cms/mpPages/index.ts
Normal file
106
src/api/cms/mpPages/index.ts
Normal file
@@ -0,0 +1,106 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { MpPages, MpPagesParam } from './model';
|
||||
import { MODULES_API_URL } from '@/config/setting';
|
||||
|
||||
/**
|
||||
* 分页查询小程序页面
|
||||
*/
|
||||
export async function pageMpPages(params: MpPagesParam) {
|
||||
const res = await request.get<ApiResult<PageResult<MpPages>>>(
|
||||
MODULES_API_URL + '/cms/mp-pages/page',
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询小程序页面列表
|
||||
*/
|
||||
export async function listMpPages(params?: MpPagesParam) {
|
||||
const res = await request.get<ApiResult<MpPages[]>>(
|
||||
MODULES_API_URL + '/cms/mp-pages',
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加小程序页面
|
||||
*/
|
||||
export async function addMpPages(data: MpPages) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/cms/mp-pages',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改小程序页面
|
||||
*/
|
||||
export async function updateMpPages(data: MpPages) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/cms/mp-pages',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除小程序页面
|
||||
*/
|
||||
export async function removeMpPages(id?: number) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/cms/mp-pages/' + id
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除小程序页面
|
||||
*/
|
||||
export async function removeBatchMpPages(data: (number | undefined)[]) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/cms/mp-pages/batch',
|
||||
{
|
||||
data
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询小程序页面
|
||||
*/
|
||||
export async function getMpPages(id: number) {
|
||||
const res = await request.get<ApiResult<MpPages>>(
|
||||
MODULES_API_URL + '/cms/mp-pages/' + id
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
48
src/api/cms/mpPages/model/index.ts
Normal file
48
src/api/cms/mpPages/model/index.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import type { PageParam } from '@/api';
|
||||
|
||||
/**
|
||||
* 小程序页面
|
||||
*/
|
||||
export interface MpPages {
|
||||
// ID
|
||||
id?: number;
|
||||
// 上级id, 0是顶级
|
||||
parentId?: number;
|
||||
// 页面名称
|
||||
title?: string;
|
||||
// 页面路径
|
||||
path?: string;
|
||||
// 设为首页
|
||||
home?: number;
|
||||
// 分包
|
||||
subpackage?: string;
|
||||
// 图标
|
||||
icon?: string;
|
||||
// 排序(数字越小越靠前)
|
||||
sortNumber?: number;
|
||||
// 备注
|
||||
comments?: string;
|
||||
// 用户ID
|
||||
userId?: number;
|
||||
// 状态, 0正常, 1冻结
|
||||
status?: number;
|
||||
// 是否删除, 0否, 1是
|
||||
deleted?: number;
|
||||
// 租户id
|
||||
tenantId?: number;
|
||||
// 注册时间
|
||||
createTime?: string;
|
||||
// 子页面
|
||||
children?: MpPages[];
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序页面搜索条件
|
||||
*/
|
||||
export interface MpPagesParam extends PageParam {
|
||||
id?: number;
|
||||
title?: string;
|
||||
path?: string;
|
||||
subpackage?: string;
|
||||
keywords?: string;
|
||||
}
|
||||
@@ -213,3 +213,22 @@ export async function uploadOssByGroupId(file: File, GroupId: string) {
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传阿里云OSS
|
||||
*/
|
||||
export async function uploadOssByAppId(file: File, appId: string) {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
const res = await request.post<ApiResult<FileRecord>>(
|
||||
SERVER_API_URL + '/oss/upload',
|
||||
formData,
|
||||
{
|
||||
headers: { appId }
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user