Ver Fonte

update 优化 判断当前会话是否已经登录

疯狂的狮子Li há 7 meses atrás
pai
commit
64d9b27310

+ 3 - 13
ruoyi-common/ruoyi-common-tenant/src/main/java/org/dromara/common/tenant/helper/TenantHelper.java

@@ -1,6 +1,5 @@
 package org.dromara.common.tenant.helper;
 
-import cn.dev33.satoken.stp.StpUtil;
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.convert.Convert;
 import cn.hutool.core.util.ObjectUtil;
@@ -130,7 +129,7 @@ public class TenantHelper {
         if (!isEnable()) {
             return;
         }
-        if (!isLogin() || !global) {
+        if (!LoginHelper.isLogin() || !global) {
             TEMP_DYNAMIC_TENANT.set(tenantId);
             return;
         }
@@ -147,7 +146,7 @@ public class TenantHelper {
         if (!isEnable()) {
             return null;
         }
-        if (!isLogin()) {
+        if (!LoginHelper.isLogin()) {
             return TEMP_DYNAMIC_TENANT.get();
         }
         // 如果线程内有值 优先返回
@@ -167,7 +166,7 @@ public class TenantHelper {
         if (!isEnable()) {
             return;
         }
-        if (!isLogin()) {
+        if (!LoginHelper.isLogin()) {
             TEMP_DYNAMIC_TENANT.remove();
             return;
         }
@@ -218,13 +217,4 @@ public class TenantHelper {
         return tenantId;
     }
 
-    private static boolean isLogin() {
-        try {
-            StpUtil.checkLogin();
-            return true;
-        } catch (Exception e) {
-            return false;
-        }
-    }
-
 }