From 8d78cede6800be6c590ed6b2b8dfe84c2ec4a1a5 Mon Sep 17 00:00:00 2001 From: caozehui <2427765068@qq.com> Date: Fri, 10 Jan 2025 09:03:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BC=93=E5=AD=98=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- system/pom.xml | 5 +++++ .../gather/system/auth/controller/AuthController.java | 11 +++++------ .../com/njcn/gather/system/log/aop/LogAdvice.java | 6 +++--- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/system/pom.xml b/system/pom.xml index 0201fed2..e9df93ef 100644 --- a/system/pom.xml +++ b/system/pom.xml @@ -39,6 +39,11 @@ 1.9.6 compile + + com.alibaba + fastjson + 1.2.83 + diff --git a/system/src/main/java/com/njcn/gather/system/auth/controller/AuthController.java b/system/src/main/java/com/njcn/gather/system/auth/controller/AuthController.java index 9a3f47fe..e91b8634 100644 --- a/system/src/main/java/com/njcn/gather/system/auth/controller/AuthController.java +++ b/system/src/main/java/com/njcn/gather/system/auth/controller/AuthController.java @@ -3,6 +3,7 @@ package com.njcn.gather.system.auth.controller; import cn.hutool.core.date.DateUnit; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.spring.SpringUtil; +import com.alibaba.fastjson.JSON; import com.njcn.common.bean.CustomCacheUtil; import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.constant.OperateType; @@ -12,7 +13,6 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.utils.JwtUtil; import com.njcn.common.utils.LogUtil; -import com.njcn.db.mybatisplus.constant.UserConstant; import com.njcn.gather.system.auth.pojo.Token; import com.njcn.gather.user.pojo.constant.UserValidMessage; import com.njcn.gather.user.user.pojo.param.SysUserParam; @@ -81,8 +81,7 @@ public class AuthController extends BaseController { map.put("name", user.getName()); token.setUserInfo(map); CustomCacheUtil customCacheUtil = SpringUtil.getBean(CustomCacheUtil.CACHE_NAME); - customCacheUtil.putWithExpireTime(UserConstant.USER_ID, user.getId(), DateUnit.DAY.getMillis()); - customCacheUtil.putWithExpireTime(UserConstant.USER_NAME, user.getName(), DateUnit.DAY.getMillis()); + customCacheUtil.putWithExpireTime(tokenStr, JSON.toJSONString(user), DateUnit.DAY.getMillis()); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, token, methodDescribe); } } @@ -95,10 +94,10 @@ public class AuthController extends BaseController { LogUtil.njcnDebug(log, "{},注销登录", methodDescribe); String authorization = request.getHeader(SecurityConstants.AUTHORIZATION_KEY); if (StrUtil.isNotBlank(authorization)) { - String token = authorization.replace(SecurityConstants.AUTHORIZATION_PREFIX, Strings.EMPTY); + String tokenStr = authorization.replace(SecurityConstants.AUTHORIZATION_PREFIX, Strings.EMPTY); CustomCacheUtil customCacheUtil = SpringUtil.getBean(CustomCacheUtil.CACHE_NAME); - customCacheUtil.remove(UserConstant.USER_ID); - JwtUtil.invalidateToken(token); + customCacheUtil.remove(tokenStr); + JwtUtil.invalidateToken(tokenStr); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); } return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe); diff --git a/system/src/main/java/com/njcn/gather/system/log/aop/LogAdvice.java b/system/src/main/java/com/njcn/gather/system/log/aop/LogAdvice.java index 6d3677eb..b8029b90 100644 --- a/system/src/main/java/com/njcn/gather/system/log/aop/LogAdvice.java +++ b/system/src/main/java/com/njcn/gather/system/log/aop/LogAdvice.java @@ -46,7 +46,7 @@ public class LogAdvice implements ApplicationListener { @Around("logPointcut()") public Object around(ProceedingJoinPoint joinPoint) throws Throwable { CustomCacheUtil customCacheUtil = SpringUtil.getBean(CustomCacheUtil.CACHE_NAME); - String username = customCacheUtil.get(UserConstant.USER_NAME, false); + //String username = customCacheUtil.get(UserConstant.USER_NAME, false); // String operationType = ""; // String operateResult = "成功"; // Integer level = 0; @@ -55,9 +55,9 @@ public class LogAdvice implements ApplicationListener { Object result = null; try { result = joinPoint.proceed(); - addLogToQueue(joinPoint, username, "操作日志", "成功", 0, 0); + //addLogToQueue(joinPoint, username, "操作日志", "成功", 0, 0); } catch (Throwable e) { - addLogToQueue(joinPoint, username, "告警日志", "失败", 1, 1); + //addLogToQueue(joinPoint, username, "告警日志", "失败", 1, 1); throw e; } return result;