From 0ed2002103cfe3d0892ee2468d98b7d3fad8e7b9 Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期五, 18 十月 2024 15:45:06 +0800
Subject: [PATCH] ll
---
server/system_service/src/main/java/com/doumee/api/BaseController.java | 21 +++++++++++----------
1 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/server/system_service/src/main/java/com/doumee/api/BaseController.java b/server/system_service/src/main/java/com/doumee/api/BaseController.java
index b19a5e9..3001582 100644
--- a/server/system_service/src/main/java/com/doumee/api/BaseController.java
+++ b/server/system_service/src/main/java/com/doumee/api/BaseController.java
@@ -1,6 +1,7 @@
package com.doumee.api;
import com.alibaba.fastjson.JSONObject;
+import com.doumee.config.jwt.JwtProperties;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.model.LoginUserInfo;
@@ -13,9 +14,11 @@
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
+import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.TimeUnit;
/**
* Controller鍩虹被
@@ -27,22 +30,17 @@
@Autowired
private RedisTemplate<String,Object> stringRedisTemplate;
+ @Resource
+ private JwtProperties jwtProperties;
/**
* 鑾峰彇褰撳墠鐧诲綍鐢ㄦ埛
* @author Eva.Caesar Liu
* @date 2023/03/21 14:49
*/
- protected LoginUserInfo getLoginUser () {
- return (LoginUserInfo)SecurityUtils.getSubject().getPrincipal();
- }
- /**
- * 鑾峰彇褰撳墠鐧诲綍鐢ㄦ埛
- * @author Eva.Caesar Liu
- * @date 2023/03/21 14:49
- */
- protected LoginUserInfo getLoginUser (String token) {
+ public LoginUserInfo getLoginUser (String token) {
if (token == null || token.isEmpty()) {
- throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"鏈櫥褰�");
+ return (LoginUserInfo)SecurityUtils.getSubject().getPrincipal();
+// throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"鏈櫥褰�");
}
String userinfo =(String) stringRedisTemplate.opsForValue().get(Constants.REDIS_TOKEN_KEY + token);
if (StringUtils.isBlank(userinfo)) {
@@ -54,6 +52,9 @@
}
return user;
}
+ public void updateLoginUser (String token,LoginUserInfo userInfo) {
+ stringRedisTemplate.opsForValue().set(Constants.REDIS_TOKEN_KEY+token,JSONObject.toJSONString(userInfo),jwtProperties.getExpiration(), TimeUnit.MILLISECONDS);
+ }
/**
--
Gitblit v1.9.3