修改缓存用户信息
This commit is contained in:
@@ -39,6 +39,11 @@
|
|||||||
<version>1.9.6</version>
|
<version>1.9.6</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>fastjson</artifactId>
|
||||||
|
<version>1.2.83</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.njcn.gather.system.auth.controller;
|
|||||||
import cn.hutool.core.date.DateUnit;
|
import cn.hutool.core.date.DateUnit;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.njcn.common.bean.CustomCacheUtil;
|
import com.njcn.common.bean.CustomCacheUtil;
|
||||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
import com.njcn.common.pojo.constant.OperateType;
|
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.pojo.response.HttpResult;
|
||||||
import com.njcn.common.utils.JwtUtil;
|
import com.njcn.common.utils.JwtUtil;
|
||||||
import com.njcn.common.utils.LogUtil;
|
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.system.auth.pojo.Token;
|
||||||
import com.njcn.gather.user.pojo.constant.UserValidMessage;
|
import com.njcn.gather.user.pojo.constant.UserValidMessage;
|
||||||
import com.njcn.gather.user.user.pojo.param.SysUserParam;
|
import com.njcn.gather.user.user.pojo.param.SysUserParam;
|
||||||
@@ -81,8 +81,7 @@ public class AuthController extends BaseController {
|
|||||||
map.put("name", user.getName());
|
map.put("name", user.getName());
|
||||||
token.setUserInfo(map);
|
token.setUserInfo(map);
|
||||||
CustomCacheUtil customCacheUtil = SpringUtil.getBean(CustomCacheUtil.CACHE_NAME);
|
CustomCacheUtil customCacheUtil = SpringUtil.getBean(CustomCacheUtil.CACHE_NAME);
|
||||||
customCacheUtil.putWithExpireTime(UserConstant.USER_ID, user.getId(), DateUnit.DAY.getMillis());
|
customCacheUtil.putWithExpireTime(tokenStr, JSON.toJSONString(user), DateUnit.DAY.getMillis());
|
||||||
customCacheUtil.putWithExpireTime(UserConstant.USER_NAME, user.getName(), DateUnit.DAY.getMillis());
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, token, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, token, methodDescribe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -95,10 +94,10 @@ public class AuthController extends BaseController {
|
|||||||
LogUtil.njcnDebug(log, "{},注销登录", methodDescribe);
|
LogUtil.njcnDebug(log, "{},注销登录", methodDescribe);
|
||||||
String authorization = request.getHeader(SecurityConstants.AUTHORIZATION_KEY);
|
String authorization = request.getHeader(SecurityConstants.AUTHORIZATION_KEY);
|
||||||
if (StrUtil.isNotBlank(authorization)) {
|
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 customCacheUtil = SpringUtil.getBean(CustomCacheUtil.CACHE_NAME);
|
||||||
customCacheUtil.remove(UserConstant.USER_ID);
|
customCacheUtil.remove(tokenStr);
|
||||||
JwtUtil.invalidateToken(token);
|
JwtUtil.invalidateToken(tokenStr);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
}
|
}
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class LogAdvice implements ApplicationListener<ContextRefreshedEvent> {
|
|||||||
@Around("logPointcut()")
|
@Around("logPointcut()")
|
||||||
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
|
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||||
CustomCacheUtil customCacheUtil = SpringUtil.getBean(CustomCacheUtil.CACHE_NAME);
|
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 operationType = "";
|
||||||
// String operateResult = "成功";
|
// String operateResult = "成功";
|
||||||
// Integer level = 0;
|
// Integer level = 0;
|
||||||
@@ -55,9 +55,9 @@ public class LogAdvice implements ApplicationListener<ContextRefreshedEvent> {
|
|||||||
Object result = null;
|
Object result = null;
|
||||||
try {
|
try {
|
||||||
result = joinPoint.proceed();
|
result = joinPoint.proceed();
|
||||||
addLogToQueue(joinPoint, username, "操作日志", "成功", 0, 0);
|
//addLogToQueue(joinPoint, username, "操作日志", "成功", 0, 0);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
addLogToQueue(joinPoint, username, "告警日志", "失败", 1, 1);
|
//addLogToQueue(joinPoint, username, "告警日志", "失败", 1, 1);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in New Issue
Block a user