ソースを参照

用户登录redis的key修改

small 2 年 前
コミット
2de9ff75ae

+ 3 - 4
sckw-auth/src/main/java/com/sckw/auth/service/impl/AuthServiceImpl.java

@@ -9,7 +9,6 @@ import com.sckw.auth.model.vo.res.EntInfoResVo;
 import com.sckw.auth.model.vo.res.LoginResVo;
 import com.sckw.auth.util.AsyncFactory;
 import com.sckw.core.utils.StringUtils;
-import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.system.api.model.dto.req.ForgetPasswordReqDto;
 import com.sckw.system.api.model.dto.req.UserLoginReqDto;
 import com.sckw.system.api.model.dto.res.KwsRoleResDto;
@@ -116,10 +115,10 @@ public class AuthServiceImpl implements IAuthService {
      */
     private void afterProcessor(LoginResVo loginResVo) {
         try {
-            String id = String.valueOf(loginResVo.getId());
-            String token = EncryUtil.encry(Global.PRI_KEY, id);
+            Long id = loginResVo.getId();
+            String token = EncryUtil.encry(Global.PRI_KEY, String.valueOf(id));
             loginResVo.setToken(token);
-            RedissonUtils.putString(Global.REDIS_USER_PREFIX + id + Global.COLON + loginResVo.getClientType(), JSON.toJSONString(loginResVo), Global.PC_TOKEN_EXPIRE);
+            RedissonUtils.putString(Global.getFullUserLoginKey(loginResVo.getSystemType(), loginResVo.getId(), loginResVo.getClientType()), JSON.toJSONString(loginResVo), Global.PC_TOKEN_EXPIRE);
 
             //异步存redis
             AsyncFactory.execute(new SaveMenuInfo(loginResVo.getId()));

+ 2 - 1
sckw-common/sckw-common-core/src/main/java/com/sckw/core/filter/LoginFilter.java

@@ -73,7 +73,8 @@ public class LoginFilter implements Filter {
 
         //从redis获取用户信息
         String clientType = request.getHeader(RequestConstant.CLIENT_TYPE);
-        Object object = RedissonUtils.get(Global.REDIS_USER_PREFIX + key + Global.COLON + clientType);
+        String systemType = request.getHeader(RequestConstant.SYSTEM_TYPE);
+        Object object = RedissonUtils.get(Global.getFullUserLoginKey(Integer.parseInt(systemType), Long.parseLong(key), clientType));
         if (Objects.isNull(object)) {
             throw new SystemException(HttpStatus.PARAMETERS_MISSING_CODE, HttpStatus.TOKEN_INVAILD);
         }

+ 6 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/constant/Global.java

@@ -223,4 +223,10 @@ public class Global {
 
     /**已读*/
     public static final Integer READ = 1;
+
+    /**完成的用户登录信息key*/
+    public static String getFullUserLoginKey (Integer systemType, Long userId, String clientType) {
+        return REDIS_USER_PREFIX + systemType + COLON + userId + COLON + clientType;
+    }
+
 }