💩 feat: 改成restful风格

This commit is contained in:
bunny 2025-05-12 20:40:42 +08:00
parent d38475418b
commit 213a66971d
27 changed files with 80 additions and 93 deletions

View File

@ -23,14 +23,6 @@ server {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# 后端跨域请求
location ~/peiqi/ {
proxy_pass http://172.17.0.1:8000;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
error_page 404 404.html;

View File

@ -3,7 +3,7 @@ import type { BaseResult } from '@/api/service/types';
/** 读取web配置文件并返回给前端 */
export const getWebConfig = () => {
return http.request<any>('get', '/config/public/webConfig');
return http.request<any>('get', '/config/public/web-config');
};
/** 更新web配置文件 */

View File

@ -3,27 +3,27 @@ import type { BaseResult, ResultTable } from '@/api/service/types';
/** 邮件模板表---分页查询邮件模板 */
export const getEmailTemplatePage = (data: any) => {
return http.request<BaseResult<ResultTable>>('get', `emailTemplate/${data.currentPage}/${data.pageSize}`, {
return http.request<BaseResult<ResultTable>>('get', `email-template/${data.currentPage}/${data.pageSize}`, {
params: data,
});
};
/** 邮件模板表---添加邮件模板 */
export const createEmailTemplate = (data: any) => {
return http.request<BaseResult<object>>('post', 'emailTemplate', { data });
return http.request<BaseResult<object>>('post', 'email-template', { data });
};
/** 邮件模板表---更新邮件模板 */
export const updateEmailTemplate = (data: any) => {
return http.request<BaseResult<object>>('put', 'emailTemplate', { data });
return http.request<BaseResult<object>>('put', 'email-template', { data });
};
/** 邮件模板表---删除邮件模板 */
export const deleteEmailTemplate = (data: any) => {
return http.request<BaseResult<object>>('delete', 'emailTemplate', { data });
return http.request<BaseResult<object>>('delete', 'email-template', { data });
};
/** 邮件模板表---获取全部邮件类型列表 */
export const getEmailTypeList = () => {
return http.request<BaseResult<any>>('get', 'emailTemplate/private');
return http.request<BaseResult<any>>('get', 'email-template/private');
};

View File

@ -3,27 +3,27 @@ import type { BaseResult, ResultTable } from '@/api/service/types';
/** 邮箱用户发送配置管理---分页查询邮箱用户发送配置 */
export const getEmailUserPage = (data: any) => {
return http.request<BaseResult<ResultTable>>('get', `emailUsers/${data.currentPage}/${data.pageSize}`, {
return http.request<BaseResult<ResultTable>>('get', `email-users/${data.currentPage}/${data.pageSize}`, {
params: data,
});
};
/** 邮箱用户发送配置管理---添加邮箱用户发送配置 */
export const createEmailUsers = (data: any) => {
return http.request<BaseResult<object>>('post', 'emailUsers', { data });
return http.request<BaseResult<object>>('post', 'email-users', { data });
};
/** 邮箱用户发送配置管理---更新邮箱用户发送配置 */
export const updateEmailUsers = (data: any) => {
return http.request<BaseResult<object>>('put', 'emailUsers', { data });
return http.request<BaseResult<object>>('put', 'email-users', { data });
};
/** 邮箱用户发送配置管理---删除邮箱用户 */
export const deleteEmailUsers = (data: any) => {
return http.request<BaseResult<object>>('delete', 'emailUsers', { data });
return http.request<BaseResult<object>>('delete', 'email-users', { data });
};
/** 邮箱用户发送配置管理---获取全部邮件用户配置 */
export const getEmailUserList = () => {
return http.request<BaseResult<any>>('get', 'emailUsers/private');
return http.request<BaseResult<any>>('get', 'email-users/private');
};

View File

@ -31,5 +31,5 @@ export const downloadFilesByFileId = (data: any) => {
/** 系统文件管理---获取所有文件存储基础路径 */
export const getFilesStoragePath = () => {
return http.request<BaseResult<any>>('get', `files/private/getAllFilesStoragePath`);
return http.request<BaseResult<any>>('get', `files/private/file-storage-paths`);
};

View File

@ -44,22 +44,22 @@ export const uploadI18nFile = (data: any) => {
/** 多语言类型管理---添加多语言类型 */
export const createI18Type = (data: any) => {
return http.request<BaseResult<object>>('post', 'i18nType', { data });
return http.request<BaseResult<object>>('post', 'i18n-type', { data });
};
/** 多语言类型管理---更新多语言类型 */
export const updateI18nType = (data: any) => {
return http.request<BaseResult<object>>('put', 'i18nType', { data });
return http.request<BaseResult<object>>('put', 'i18n-type', { data });
};
/** 多语言类型管理---删除多语言类型 */
export const deleteI18nType = (data: any) => {
return http.request<BaseResult<object>>('delete', 'i18nType', { data });
return http.request<BaseResult<object>>('delete', 'i18n-type', { data });
};
/** 多语言类型管理---获取全部多语言类型列表 */
export const getI18nTypeList = (data: any) => {
return http.request<BaseResult<ResultTable>>('get', 'i18nType/public', {
return http.request<BaseResult<ResultTable>>('get', 'i18n-type/public', {
params: data,
});
};

View File

@ -3,14 +3,14 @@ import type { BaseResult, ResultTable } from '@/api/service/types';
/** 调度任务执行日志---分页查询调度任务执行日志 */
export const getScheduleExecuteLogPage = (data: any) => {
return http.request<BaseResult<ResultTable>>('get', `scheduleExecuteLog/${data.currentPage}/${data.pageSize}`, {
return http.request<BaseResult<ResultTable>>('get', `schedule-execute-log/${data.currentPage}/${data.pageSize}`, {
params: data,
});
};
/** 调度任务执行日志---删除调度任务执行日志 */
export const deleteScheduleExecuteLog = (data: any) => {
return http.request<BaseResult<object>>('delete', 'scheduleExecuteLog', {
return http.request<BaseResult<object>>('delete', 'schedule-execute-log', {
data,
});
};

View File

@ -3,17 +3,17 @@ import type { BaseResult, ResultTable } from '@/api/service/types';
/** 用户登录日志---获取用户登录日志列表 */
export const getUserLoginLogPageByAdmin = (data: any) => {
return http.request<BaseResult<ResultTable>>('get', `userLoginLog/${data.currentPage}/${data.pageSize}`, {
return http.request<BaseResult<ResultTable>>('get', `user-login-log/${data.currentPage}/${data.pageSize}`, {
params: data,
});
};
/** 用户登录日志---删除用户登录日志 */
export const deleteUserLoginLog = (data: any) => {
return http.request<BaseResult<object>>('delete', 'userLoginLog', { data });
return http.request<BaseResult<object>>('delete', 'user-login-log', { data });
};
/** 用户登录日志---获取用户登录日志列表 */
export const getUserLoginLogPageByUser = (data: any) => {
return http.request<BaseResult<ResultTable>>('get', `userLoginLog/private/${data.currentPage}/${data.pageSize}`);
return http.request<BaseResult<ResultTable>>('get', `user-login-log/private/${data.currentPage}/${data.pageSize}`);
};

View File

@ -3,12 +3,7 @@ import type { BaseResult } from '@/api/service/types';
/** 菜单管理-列表 */
export const getRouterList = () => {
return http.request<BaseResult<any>>('get', `router/routerList`);
};
/* 根据路由id获取所有角色 */
export const getRoleListByRouterId = (data: any) => {
return http.request<BaseResult<any>>('get', `routerRole/private/getRoleListByRouterId`, { params: data });
return http.request<BaseResult<any>>('get', `router/routers`);
};
/** 菜单管理-添加菜单 */
@ -16,13 +11,6 @@ export const createRouter = (data?: any) => {
return http.request<BaseResult<any>>('post', `router`, { data });
};
/** 菜单管理-清除选中菜单所有角色 */
export const clearRouterRole = (data: any) => {
return http.request<BaseResult<any>>('delete', `routerRole/clearRouterRole`, {
data,
});
};
/** 菜单管理-更新菜单 */
export const updateRouter = (data?: any) => {
return http.request<BaseResult<any>>('put', `router`, { data });
@ -32,3 +20,15 @@ export const updateRouter = (data?: any) => {
export const deletedRouterByIds = (data?: any) => {
return http.request<BaseResult<any>>('delete', `router`, { data });
};
/* 根据路由id获取所有角色 */
export const getRoleListByRouterId = (data: any) => {
return http.request<BaseResult<any>>('get', `router-role/private/roles/${data.routerId}`);
};
/** 菜单管理-清除选中菜单所有角色 */
export const clearRouterRole = (data: any) => {
return http.request<BaseResult<any>>('delete', `router-role/batch`, {
data,
});
};

View File

@ -3,29 +3,29 @@ import type { BaseResult, ResultTable } from '@/api/service/types';
/** 系统菜单图标---分页查询系统菜单图标 */
export const getMenuIconPage = (data: any) => {
return http.request<BaseResult<ResultTable>>('get', `menuIcon/${data.currentPage}/${data.pageSize}`, {
return http.request<BaseResult<ResultTable>>('get', `menu-icon/${data.currentPage}/${data.pageSize}`, {
params: data,
});
};
/** 系统菜单图标---添加系统菜单图标 */
export const createMenuIcon = (data: any) => {
return http.request<BaseResult<object>>('post', 'menuIcon', { data });
return http.request<BaseResult<object>>('post', 'menu-icon', { data });
};
/** 系统菜单图标---更新系统菜单图标 */
export const updateMenuIcon = (data: any) => {
return http.request<BaseResult<object>>('put', 'menuIcon', { data });
return http.request<BaseResult<object>>('put', 'menu-icon', { data });
};
/** 系统菜单图标---删除系统菜单图标 */
export const deleteMenuIcon = (data: any) => {
return http.request<BaseResult<object>>('delete', 'menuIcon', { data });
return http.request<BaseResult<object>>('delete', 'menu-icon', { data });
};
/** 系统菜单图标---根据名称搜索图标 */
export const getIconNameListByIconName = (data: any) => {
return http.request<BaseResult<object>>('get', 'menuIcon/public', {
return http.request<BaseResult<object>>('get', 'menu-icon/public', {
params: data,
});
};

View File

@ -3,36 +3,36 @@ import type { BaseResult, ResultTable } from '@/api/service/types';
/** 管理员操作用户消息---管理员分页查询用户消息 */
export const getMessageReceivedPage = (data: any) => {
return http.request<BaseResult<ResultTable>>('get', `messageReceived/${data.currentPage}/${data.pageSize}`, {
return http.request<BaseResult<ResultTable>>('get', `message-received/${data.currentPage}/${data.pageSize}`, {
params: data,
});
};
/** 管理员操作用户消息---管理员将用户消息标为已读 */
export const updateMessageReceivedByAdmin = (data: any) => {
return http.request<BaseResult<object>>('put', 'messageReceived', { data });
return http.request<BaseResult<object>>('put', 'message-received', { data });
};
/** 管理员操作用户消息---管理删除用户消息 */
export const deleteMessageReceivedByAdmin = (data: any) => {
return http.request<BaseResult<object>>('delete', 'messageReceived', {
return http.request<BaseResult<object>>('delete', 'message-received', {
data,
});
};
/** 用户系统消息---用户获取系统消息列表 */
export const getMessageReceivedPageByUser = (data: any) => {
return http.request<BaseResult<ResultTable>>('get', `messageReceived/private/${data.currentPage}/${data.pageSize}`, {
return http.request<BaseResult<ResultTable>>('get', `message-received/private/${data.currentPage}/${data.pageSize}`, {
params: data,
});
};
/** 系统消息---用户将消息标为已读 */
export const updateMessageByUser = (data: any) => {
return http.request<BaseResult<object>>('put', 'messageReceived/private/markAsRead', { data });
return http.request<BaseResult<object>>('put', 'message-received/private/user/messages/read-status', { data });
};
/** 系统消息---用户删除系统消息 */
export const deleteMessageReceivedByUser = (data: any) => {
return http.request<BaseResult<object>>('delete', 'messageReceived/private/deleteMessage', { data });
return http.request<BaseResult<object>>('delete', 'message-received/private/user/messages', { data });
};

View File

@ -25,10 +25,10 @@ export const deleteMessage = (data: any) => {
/** 用户系统消息---根据消息id查询消息详情 */
export const getMessageDetailById = (data: any) => {
return http.request<BaseResult<any>>('get', `message/private/getMessageDetailById`, { params: data });
return http.request<BaseResult<any>>('get', `message/private/message/${data.id}`);
};
/** 系统消息---根据消息id获取接收人信息 */
export const getReceivedUserinfoByMessageId = (data: any) => {
return http.request<BaseResult<any>>('get', `message/private/getReceivedUserinfoByMessageId`, { params: data });
return http.request<BaseResult<any>>('get', `message/private/messages/${data.messageId}/recipients`);
};

View File

@ -25,5 +25,5 @@ export const deleteMessageType = (data: any) => {
/** 系统消息类型---获取所有消息列表 */
export const getMessageTypeList = () => {
return http.request<BaseResult<ResultTable>>('get', '/messageType/private/getMessageList');
return http.request<BaseResult<ResultTable>>('get', '/messageType/private/messages');
};

View File

@ -3,29 +3,29 @@ import type { BaseResult, ResultTable } from '@/api/service/types';
/** 任务调度分组---分页查询任务调度分组 */
export const getSchedulersGroupPage = (data: any) => {
return http.request<BaseResult<ResultTable>>('get', `schedulersGroup/${data.currentPage}/${data.pageSize}`, {
return http.request<BaseResult<ResultTable>>('get', `schedulers-group/${data.currentPage}/${data.pageSize}`, {
params: data,
});
};
/** 任务调度分组---添加任务调度分组 */
export const createSchedulersGroup = (data: any) => {
return http.request<BaseResult<object>>('post', 'schedulersGroup', { data });
return http.request<BaseResult<object>>('post', 'schedulers-group', { data });
};
/** 任务调度分组---更新任务调度分组 */
export const updateSchedulersGroup = (data: any) => {
return http.request<BaseResult<object>>('put', 'schedulersGroup', { data });
return http.request<BaseResult<object>>('put', 'schedulers-group', { data });
};
/** 任务调度分组---删除任务调度分组 */
export const deleteSchedulersGroup = (data: any) => {
return http.request<BaseResult<object>>('delete', 'schedulersGroup', {
return http.request<BaseResult<object>>('delete', 'schedulers-group', {
data,
});
};
/** 任务调度分组---获取所有任务调度分组 */
export const getSchedulersGroupList = () => {
return http.request<BaseResult<ResultTable>>('get', 'schedulersGroup/getSchedulersGroupList');
return http.request<BaseResult<ResultTable>>('get', 'schedulers-group/scheduler-groups');
};

View File

@ -56,20 +56,18 @@ export const deleteUserByAdmin = (data: any) => {
};
/** 用户管理---根据用户id查询 */
export const loadUserinfoById = (data?: object) => {
return http.request<BaseResult<UserResult>>('get', 'user/private/getUserinfoById', { params: data });
export const loadUserinfoById = (data?: any) => {
return http.request<BaseResult<UserResult>>('get', `user/private/users/${data.id}`);
};
/** 用户信息---根据用户名查询用户列表 */
export const getUserListByKeyword = (data: any) => {
return http.request<BaseResult<object>>('get', 'user/private/getUserListByKeyword', { params: data });
return http.request<BaseResult<object>>('get', 'user/private/users/search', { params: data });
};
/** 用户管理---强制用户下线 */
export const forcedOfflineByAdmin = (data: any) => {
return http.request<BaseResult<UserResult>>('put', 'user/forcedOffline', {
data,
});
return http.request<BaseResult<UserResult>>('put', `user/${data.id}/force-logout`);
};
// -----------------------------------------
@ -83,12 +81,12 @@ export const userLogin = (data?: object) => {
/** 刷新`token` */
export const refreshTokenApi = (data?: object) => {
return http.request<BaseResult<RefreshTokenResult>>('post', 'user/public/refreshToken', { data });
return http.request<BaseResult<RefreshTokenResult>>('post', 'user/public/refresh-token', { data });
};
/** 发送邮件 */
export const sendLoginEmail = (data: any) => {
return http.request<BaseResult<any>>('post', '/user/public/sendLoginEmail', { data }, { headers: { 'Content-Type': 'multipart/form-data' } });
return http.request<BaseResult<any>>('post', '/user/public/email-code', { data }, { headers: { 'Content-Type': 'multipart/form-data' } });
};
/** 获取用户信息,根据当前token获取 */
@ -113,5 +111,5 @@ export const updateUserPassword = (data: any) => {
/* 查询缓存中的已登录的用户 */
export const getCacheLoggedInPage = (data: any) => {
return http.request<BaseResult<any>>('get', `user/getCacheUserPage/${data.currentPage}/${data.pageSize}`, { data });
return http.request<BaseResult<any>>('get', `user/users/logged-in/${data.currentPage}/${data.pageSize}`, { data });
};

View File

@ -25,5 +25,5 @@ export const deleteDept = (data: any) => {
/** 部门管理---获取所有部门管理列表 */
export const getDeptList = () => {
return http.request<BaseResult<object>>('get', 'dept/private/getDeptList');
return http.request<BaseResult<object>>('get', 'dept/private/departments');
};

View File

@ -35,27 +35,25 @@ export const importPermission = (data: any) => {
/** 权限---获取所有权限 */
export const getPermissionList = () => {
return http.request<BaseResult<any>>('get', `permission/private/getPermissionList`);
return http.request<BaseResult<any>>('get', `permission/private/permissions`);
};
/* 权限---获取系统API信息 */
export const getSystemApiInfoList = () => {
return http.request<BaseResult<any>>('get', 'permission/private/getSystemApiInfoList');
return http.request<BaseResult<any>>('get', 'permission/private/system/apis');
};
/** 权限---批量修改权限父级 */
export const updatePermissionListByParentId = (data: any) => {
return http.request<BaseResult<object>>('patch', 'permission/update/permissionListByParentId', { data });
return http.request<BaseResult<object>>('patch', 'permission/update/permissions/parent', { data });
};
/** 权限---批量更新权限 */
export const updatePermissionBatch = (data: any) => {
return http.request<BaseResult<object>>('patch', 'permission/update/permissionBatch', { data });
return http.request<BaseResult<object>>('patch', 'permission/update/permissions/batch', { data });
};
/** 角色和权限---根据角色id获取权限内容 */
export const getPowerListByRoleId = (data: any) => {
return http.request<BaseResult<object>>('get', 'rolePermission/private/getPermissionListByRoleId', {
params: data,
});
return http.request<BaseResult<object>>('get', `rolePermission/private/permissions/${data.id}`);
};

View File

@ -41,12 +41,12 @@ export const updateRoleByFile = (data: any) => {
/** 为用户分配角色---根据用户id获取所有角色 */
export const getRoleListByUserId = (data: any) => {
return http.request<BaseResult<any>>('get', `userRole/private/getRoleListByUserId`, { params: data });
return http.request<BaseResult<any>>('get', `user-role/private/roles/${data.userId}`);
};
/** 为用户分配角色---为用户分配角色 */
export const createUserRole = (data: object) => {
return http.request<BaseResult<any>>('post', 'userRole', { data });
return http.request<BaseResult<any>>('post', 'user-role', { data });
};
/** 角色和权限---为角色分配权限 */

View File

@ -3,15 +3,15 @@ import type { BaseResult } from '@/api/service/types';
/** 系统管理-用户路由获取 */
export const fetchRouterAsync = () => {
return http.request<BaseResult<any>>('get', 'router/private/routerAsync');
return http.request<BaseResult<any>>('get', 'router/private/router-async');
};
/** 上传文件 */
export const uploadFile = (data: any) => {
return http.request<BaseResult<any>>('post', '/files/private/upload', { data }, { headers: { 'Content-Type': 'multipart/form-data' } });
return http.request<BaseResult<any>>('post', '/files/private/file', { data }, { headers: { 'Content-Type': 'multipart/form-data' } });
};
/** 上传文件 */
export const uploadImage = (data: any) => {
return http.request<BaseResult<any>>('post', '/files/private/uploadImage', { data }, { headers: { 'Content-Type': 'multipart/form-data' } });
return http.request<BaseResult<any>>('post', '/files/private/image', { data }, { headers: { 'Content-Type': 'multipart/form-data' } });
};

View File

@ -32,7 +32,7 @@ export const getPlatformConfig = async (app: App): Promise<undefined> => {
return axios({
method: 'get',
// TODO 後端讀取 platform-config.json
url: `/api/config/public/webConfig`,
url: `/api/config/public/web-config`,
})
.then(({ data: config }) => {
let $config = app.config.globalProperties.$config;

View File

@ -44,7 +44,6 @@ export const useMessageUserStore = defineStore('messageUserStore', {
const data = { ...this.pagination, ...this.form };
delete data.pageSizes;
delete data.total;
delete data.background;
// 获取系统消息列表
const result = await getMessageReceivedPageByUser(data);
@ -62,7 +61,7 @@ export const useMessageUserStore = defineStore('messageUserStore', {
this.messageDetail = result.data;
// 解码消息内容
this.messageDetail.content = decode(this.messageDetail?.content);
(this.messageDetail as any).content = decode((this.messageDetail as any)?.content);
}
},

View File

@ -63,7 +63,6 @@ export const useAdminUserStore = defineStore('adminUserStore', {
const data = { ...this.pagination, ...this.form };
delete data.pageSizes;
delete data.total;
delete data.background;
// 获取用户信息列表
const result = await getUserPageByAdmin(data);
@ -93,7 +92,7 @@ export const useAdminUserStore = defineStore('adminUserStore', {
/** 强制用户下线 */
async forcedOffline(data: any) {
const result = await forcedOfflineByAdmin(data);
const result = await forcedOfflineByAdmin({ data });
return storeMessage(result);
},

View File

@ -10,7 +10,7 @@ import {
updatePermission,
updatePermissionBatch,
updatePermissionListByParentId,
} from '@/api/v1/system/power';
} from '@/api/v1/system/permission';
import { pageSizes } from '@/enums/baseConstant';
import { storeMessage } from '@/utils/message';
import { storePagination } from '@/store/useStorePagination';

View File

@ -15,7 +15,7 @@ const token = ref(getToken().token);
editorConfig.MENU_CONF['uploadImage'] = {
//
server: `${defaultConfig.baseURL}/files/private/upload`,
server: `${defaultConfig.baseURL}/files/private/file`,
// form-data fieldName
fieldName: 'file',
//

View File

@ -14,7 +14,7 @@ const token = ref(getToken().token);
editorConfig.MENU_CONF['uploadImage'] = {
//
server: '/api/files/private/upload',
server: '/api/files/private/file',
// form-data fieldName
fieldName: 'file',
//

View File

@ -10,7 +10,8 @@ export const columns: TableColumnList = [
// 文件在服务器上的存储路径
{ label: $t('files_filepath'), prop: 'filepath' },
// 文件的MIME类型
{ label: $t('files_fileType'), prop: 'fileType', width: 180 },
{ label: $t('files_fileType'), prop: 'contentType', width: 180 },
{ label: '缩略图类型', prop: 'thContentType', width: 180 },
// 下载数量
{ label: $t('files_downloadCount'), prop: 'downloadCount', width: 115 },
{ label: $t('table.updateTime'), prop: 'updateTime', sortable: true, width: 160 },

View File

@ -5,7 +5,7 @@ import { h, ref } from 'vue';
import { messageBox } from '@/utils/message';
import type { FormItemProps } from '@/views/system/role/utils/types';
import { $t } from '@/plugins/i18n';
import { getPowerListByRoleId } from '@/api/v1/system/power';
import { getPowerListByRoleId } from '@/api/v1/system/permission';
// 表格ref
export const tableRef = ref();