From d447ae83be583fa06c72a5d7c7796fc89c87bce4 Mon Sep 17 00:00:00 2001 From: tanyp <742354529@qq.com> Date: Fri, 7 Apr 2023 14:56:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=AA=8C=E8=AF=81=E7=A0=81?= =?UTF-8?q?=E3=80=81=E7=99=BB=E5=BD=95=E6=97=A5=E5=BF=97=E3=80=81=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/tansci_boot.sql | 8 +- tansci-boot-ui/src/api/auth.ts | 14 ++ tansci-boot-ui/src/utils/request.ts | 4 +- tansci-boot-ui/src/views/common/Login.vue | 23 ++- tansci-boot/pom.xml | 18 ++ .../com/tansci/common/annotation/Log.java | 38 ++++ .../com/tansci/common/aop/OperLogAspect.java | 180 ++++++++++++++++++ .../com/tansci/common/constant/Constants.java | 19 +- .../com/tansci/controller/AuthController.java | 20 +- .../tansci/controller/SysMenuController.java | 4 + .../tansci/controller/SysUserController.java | 8 + .../java/com/tansci/domain/SysOperLog.java | 6 + .../main/java/com/tansci/domain/SysUser.java | 4 + .../com/tansci/service/SysUserService.java | 3 +- .../service/impl/SysUserServiceImpl.java | 39 +++- .../java/com/tansci/utils/SystemUtils.java | 99 ++++------ 16 files changed, 404 insertions(+), 83 deletions(-) create mode 100644 tansci-boot/src/main/java/com/tansci/common/annotation/Log.java create mode 100644 tansci-boot/src/main/java/com/tansci/common/aop/OperLogAspect.java diff --git a/sql/tansci_boot.sql b/sql/tansci_boot.sql index adedc60..2e296f2 100644 --- a/sql/tansci_boot.sql +++ b/sql/tansci_boot.sql @@ -11,7 +11,7 @@ Target Server Version : 50721 File Encoding : 65001 - Date: 06/04/2023 17:20:01 + Date: 07/04/2023 14:54:55 */ SET NAMES utf8mb4; @@ -64,6 +64,7 @@ CREATE TABLE `sys_login_log` ( -- ---------------------------- -- Records of sys_login_log -- ---------------------------- +INSERT INTO `sys_login_log` VALUES ('165965da5e98b46703683bc655004384', 'admin', '123456', '成功', 'Unknown', 'Unknown', '内网IP', '127.0.0.1', '19aa0675-d451-4232-9221-73babda49078', '2023-04-07 11:33:04'); -- ---------------------------- -- Table structure for sys_menu @@ -107,6 +108,7 @@ DROP TABLE IF EXISTS `sys_oper_log`; CREATE TABLE `sys_oper_log` ( `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键id', `module` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '功能模块', + `method` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作方法', `type` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作类型', `message` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作描述', `req_param` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '请求参数', @@ -114,9 +116,10 @@ CREATE TABLE `sys_oper_log` ( `take_up_time` int(64) NULL DEFAULT NULL COMMENT '耗时', `user_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作用户id', `user_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作用户名称', - `method` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作方法', + `status` int(1) NULL DEFAULT NULL COMMENT '状态:0、成功,1、失败', `uri` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '请求url', `ip` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '请求IP', + `unusual` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '异常信息', `version` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '版本号', `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间', PRIMARY KEY (`id`) USING BTREE @@ -125,6 +128,7 @@ CREATE TABLE `sys_oper_log` ( -- ---------------------------- -- Records of sys_oper_log -- ---------------------------- +INSERT INTO `sys_oper_log` VALUES ('f052dcb16aeb0fa199bd82aa058e8eee', '菜单管理-当前用户权限菜单列表', 'com.tansci.controller.SysMenuController.menus', 'SELECT', '当前用户权限菜单列表', '{}', '{\"code\":200,\"message\":\"操作成功\",\"result\":[{\"children\":[{\"component\":\"Layout\",\"icon\":\"Grid\",\"id\":\"10001dsgf\",\"isShow\":true,\"meta\":{\"keepAlive\":false,\"openMode\":0,\"id\":\"10001dsgf\",\"title\":\"Iframe测试\",\"isShow\":true},\"name\":\"Iframe\",\"parentId\":\"b1851d1b13594e71840103c11a37a002\",\"path\":\"https://www.bing.com/?mkt=zh-CN\",\"sort\":6},{\"component\":\"Layout\",\"icon\":\"Grid\",\"id\":\"b1851d1b13594e71840103c11a37a003\",\"isShow\":true,\"meta\":{\"keepAlive\":false,\"openMode\":0,\"id\":\"b1851d1b13594e71840103c11a37a003\",\"title\":\"菜单管理\",\"isShow\":true},\"name\":\"menu\",\"parentId\":\"b1851d1b13594e71840103c11a37a002\",\"path\":\"/system/Menu\",\"sort\":2},{\"component\":\"Layout\",\"icon\":\"QuestionFilled\",\"id\":\"b1851d1b13594e71840103c11a37a004\",\"isShow\":true,\"meta\":{\"keepAlive\":false,\"openMode\":0,\"id\":\"b1851d1b13594e71840103c11a37a004\",\"title\":\"组织管理\",\"isShow\":true},\"name\":\"org\",\"parentId\":\"b1851d1b13594e71840103c11a37a002\",\"path\":\"/system/Org\",\"sort\":3},{\"component\":\"Layout\",\"icon\":\"Grid\",\"id\":\"b1851d1b13594e71840103c11a37a005\",\"isShow\":true,\"meta\":{\"keepAlive\":false,\"openMode\":0,\"id\":\"b1851d1b13594e71840103c11a37a005\",\"title\":\"权限管理\",\"isShow\":true},\"name\":\"role\",\"parentId\":\"b1851d1b13594e71840103c11a37a002\",\"path\":\"/system/Role\",\"sort\":4},{\"component\":\"Layout\",\"icon\":\"Grid\",\"id\":\"b1851d1b13594e71840103c11a37a006\",\"isShow\":true,\"meta\":{\"keepAlive\":false,\"openMode\":0,\"id\":\"b1851d1b13594e71840103c11a37a006\",\"title\":\"用户管理\",\"isShow\":true},\"name\":\"user\",\"parentId\":\"b1851d1b13594e71840103c11a37a002\",\"path\":\"/system/User\",\"sort\":5}],\"component\":\"Layout\",\"icon\":\"Grid\",\"id\":\"b1851d1b13594e71840103c11a37a002\",\"isShow\":true,\"meta\":{\"keepAlive\":false,\"openMode\":0,\"id\":\"b1851d1b13594e71840103c11a37a002\",\"title\":\"系统管理\",\"isShow\":true},\"name\":\"system\",\"parentId\":\"0\",\"path\":\"/system\",\"sort\":1}]}', 49, '534a37c366ec47878a6b0c85703d0bc2', NULL, 0, '/tansci/sysmenu/menus', '127.0.0.1', NULL, NULL, '2023-04-07 14:50:17'); -- ---------------------------- -- Table structure for sys_org diff --git a/tansci-boot-ui/src/api/auth.ts b/tansci-boot-ui/src/api/auth.ts index 326e908..750c815 100644 --- a/tansci-boot-ui/src/api/auth.ts +++ b/tansci-boot-ui/src/api/auth.ts @@ -69,4 +69,18 @@ export function logout(){ removeUser() location.reload() }) +} + +// 验证码 +export function getCode(){ + return new Promise((resolve, reject) => { + request({ + url: '/tansci/auth/code', + method: 'get' + }).then((res:any) => { + resolve(res) + }).catch((e:any) => { + reject(e) + }) + }) } \ No newline at end of file diff --git a/tansci-boot-ui/src/utils/request.ts b/tansci-boot-ui/src/utils/request.ts index bc9224a..099e89a 100644 --- a/tansci-boot-ui/src/utils/request.ts +++ b/tansci-boot-ui/src/utils/request.ts @@ -30,10 +30,10 @@ axiosInstance.interceptors.request.use((config: AxiosRequestConfig) => { // axios实例拦截响应 axiosInstance.interceptors.response.use( (response: AxiosResponse) => { - if (response.status === 200 && response.data.code == 200) { + if (response.status === 200 && response.data.code === 200) { return response; } else { - ElMessage.warning(showMessage(response.status)); + ElMessage.warning(showMessage(response.data.code)); if (response.data.code === 402) { logout() } diff --git a/tansci-boot-ui/src/views/common/Login.vue b/tansci-boot-ui/src/views/common/Login.vue index f51d693..f335fc5 100644 --- a/tansci-boot-ui/src/views/common/Login.vue +++ b/tansci-boot-ui/src/views/common/Login.vue @@ -1,14 +1,15 @@