瀏覽代碼

删除多余代码

RuoYi 6 年之前
父節點
當前提交
7329cbdceb

+ 0 - 1
ruoyi-admin/src/main/resources/templates/system/role/role.html

@@ -61,7 +61,6 @@
 	<script th:inline="javascript">
 		var editFlag = [[${@permission.hasPermi('system:role:edit')}]];
 		var removeFlag = [[${@permission.hasPermi('system:role:remove')}]];
-		var datas = [[${@dict.getType('sys_normal_disable')}]];
 		var prefix = ctx + "system/role";
 		
 

+ 0 - 1
ruoyi-admin/src/main/resources/templates/system/user/user.html

@@ -93,7 +93,6 @@
 		var editFlag = [[${@permission.hasPermi('system:user:edit')}]];
 		var removeFlag = [[${@permission.hasPermi('system:user:remove')}]];
 		var resetPwdFlag = [[${@permission.hasPermi('system:user:resetPwd')}]];
-		var datas = [[${@dict.getType('sys_normal_disable')}]];
 		var prefix = ctx + "system/user";
 
 		$(function() {

+ 3 - 44
ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java

@@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.spring.SpringUtils;
 import com.ruoyi.framework.shiro.realm.UserRealm;
 import com.ruoyi.framework.shiro.session.OnlineSessionDAO;
 import com.ruoyi.framework.shiro.session.OnlineSessionFactory;
@@ -47,10 +48,6 @@ public class ShiroConfig
     @Value("${shiro.session.expireTime}")
     private int expireTime;
 
-    // 相隔多久检查一次session的有效性,单位毫秒,默认就是10分钟
-    @Value("${shiro.session.validationInterval}")
-    private int validationInterval;
-
     // 验证码开关
     @Value("${shiro.user.captchaEnabled}")
     private boolean captchaEnabled;
@@ -159,44 +156,6 @@ public class ShiroConfig
         return sessionFactory;
     }
 
-    /**
-     * 自定义sessionFactory调度器
-     */
-    @Bean
-    public SpringSessionValidationScheduler sessionValidationScheduler()
-    {
-        SpringSessionValidationScheduler sessionValidationScheduler = new SpringSessionValidationScheduler();
-        // 相隔多久检查一次session的有效性,单位毫秒,默认就是10分钟
-        sessionValidationScheduler.setSessionValidationInterval(validationInterval * 60 * 1000);
-        // 设置会话验证调度器进行会话验证时的会话管理器
-        sessionValidationScheduler.setSessionManager(sessionValidationManager());
-        return sessionValidationScheduler;
-    }
-
-    /**
-     * 会话管理器
-     */
-    @Bean
-    public OnlineWebSessionManager sessionValidationManager()
-    {
-        OnlineWebSessionManager manager = new OnlineWebSessionManager();
-        // 加入缓存管理器
-        manager.setCacheManager(getEhCacheManager());
-        // 删除过期的session
-        manager.setDeleteInvalidSessions(true);
-        // 设置全局session超时时间
-        manager.setGlobalSessionTimeout(expireTime * 60 * 1000);
-        // 去掉 JSESSIONID
-        manager.setSessionIdUrlRewritingEnabled(false);
-        // 是否定时检查session
-        manager.setSessionValidationSchedulerEnabled(true);
-        // 自定义SessionDao
-        manager.setSessionDAO(sessionDAO());
-        // 自定义sessionFactory
-        manager.setSessionFactory(sessionFactory());
-        return manager;
-    }
-
     /**
      * 会话管理器
      */
@@ -213,7 +172,7 @@ public class ShiroConfig
         // 去掉 JSESSIONID
         manager.setSessionIdUrlRewritingEnabled(false);
         // 定义要使用的无效的Session定时调度器
-        manager.setSessionValidationScheduler(sessionValidationScheduler());
+        manager.setSessionValidationScheduler(SpringUtils.getBean(SpringSessionValidationScheduler.class));
         // 是否定时检查session
         manager.setSessionValidationSchedulerEnabled(true);
         // 自定义SessionDao
@@ -227,7 +186,7 @@ public class ShiroConfig
      * 安全管理器
      */
     @Bean
-    public SecurityManager securityManager(UserRealm userRealm)
+    public SecurityManager securityManager(UserRealm userRealm, SpringSessionValidationScheduler springSessionValidationScheduler)
     {
         DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
         // 设置realm.

+ 10 - 28
ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/session/SpringSessionValidationScheduler.java

@@ -9,6 +9,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
 import com.ruoyi.common.utils.Threads;
 
 /**
@@ -16,6 +18,7 @@ import com.ruoyi.common.utils.Threads;
  * 
  * @author ruoyi
  */
+@Component
 public class SpringSessionValidationScheduler implements SessionValidationScheduler
 {
     private static final Logger log = LoggerFactory.getLogger(SpringSessionValidationScheduler.class);
@@ -32,36 +35,15 @@ public class SpringSessionValidationScheduler implements SessionValidationSchedu
     private volatile boolean enabled = false;
 
     /**
-     * The session manager used to validate sessions.
+     * 会话验证管理器
      */
+    @Autowired
+    @Qualifier("sessionManager")
     private ValidatingSessionManager sessionManager;
 
-    /**
-     * The session validation interval in milliseconds.
-     */
-    private long sessionValidationInterval = DEFAULT_SESSION_VALIDATION_INTERVAL;
-
-    /**
-     * Default constructor.
-     */
-    public SpringSessionValidationScheduler()
-    {
-    }
-
-    /**
-     * Constructor that specifies the session manager that should be used for validating sessions.
-     *
-     * @param sessionManager the <tt>SessionManager</tt> that should be used to validate sessions.
-     */
-    public SpringSessionValidationScheduler(ValidatingSessionManager sessionManager)
-    {
-        this.sessionManager = sessionManager;
-    }
-
-    public void setSessionManager(ValidatingSessionManager sessionManager)
-    {
-        this.sessionManager = sessionManager;
-    }
+    // 相隔多久检查一次session的有效性,单位毫秒,默认就是10分钟
+    @Value("${shiro.session.validationInterval}")
+    private long sessionValidationInterval;
 
     @Override
     public boolean isEnabled()
@@ -111,7 +93,7 @@ public class SpringSessionValidationScheduler implements SessionValidationSchedu
                         sessionManager.validateSessions();
                     }
                 }
-            }, 1000, sessionValidationInterval, TimeUnit.MILLISECONDS);
+            }, 1000, sessionValidationInterval * 60 * 1000, TimeUnit.MILLISECONDS);
 
             this.enabled = true;