Эх сурвалжийг харах

修改框架 去除redis 修改相关代码 正常启动访问

Administrator 4 жил өмнө
parent
commit
63ec60a8dc

+ 1 - 0
pom.xml

@@ -31,6 +31,7 @@
         <poi.version>4.1.2</poi.version>
         <velocity.version>1.7</velocity.version>
         <jwt.version>0.9.1</jwt.version>
+        <hutool.version>5.4.7</hutool.version>
     </properties>
 	
     <!-- 依赖声明 -->

+ 9 - 4
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java

@@ -1,3 +1,4 @@
+/*
 package com.ruoyi.web.controller.common;
 
 import java.awt.image.BufferedImage;
@@ -14,15 +15,16 @@ import org.springframework.web.bind.annotation.RestController;
 import com.google.code.kaptcha.Producer;
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.core.domain.AjaxResult;
-import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.utils.sign.Base64;
 import com.ruoyi.common.utils.uuid.IdUtils;
 
+*/
 /**
  * 验证码操作处理
  * 
  * @author ruoyi
- */
+ *//*
+
 @RestController
 public class CaptchaController
 {
@@ -39,9 +41,11 @@ public class CaptchaController
     @Value("${ruoyi.captchaType}")
     private String captchaType;
 
-    /**
+    */
+/**
      * 生成验证码
-     */
+     *//*
+
     @GetMapping("/captchaImage")
     public AjaxResult getCode(HttpServletResponse response) throws IOException
     {
@@ -84,3 +88,4 @@ public class CaptchaController
         return ajax;
     }
 }
+*/

+ 5 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/CacheController.java

@@ -1,3 +1,4 @@
+/*
 package com.ruoyi.web.controller.monitor;
 
 import java.util.ArrayList;
@@ -15,11 +16,13 @@ import org.springframework.web.bind.annotation.RestController;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.utils.StringUtils;
 
+*/
 /**
  * 缓存监控
  * 
  * @author ruoyi
- */
+ *//*
+
 @RestController
 @RequestMapping("/monitor/cache")
 public class CacheController
@@ -51,3 +54,4 @@ public class CacheController
         return AjaxResult.success(result);
     }
 }
+*/

+ 26 - 36
ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java

@@ -1,9 +1,8 @@
 package com.ruoyi.web.controller.monitor;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
+import java.util.*;
+
+import com.ruoyi.framework.web.service.TokenService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.DeleteMapping;
@@ -17,7 +16,7 @@ import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.model.LoginUser;
 import com.ruoyi.common.core.page.TableDataInfo;
-import com.ruoyi.common.core.redis.RedisCache;
+//import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.enums.BusinessType;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.system.domain.SysUserOnline;
@@ -25,51 +24,42 @@ import com.ruoyi.system.service.ISysUserOnlineService;
 
 /**
  * 在线用户监控
- * 
+ *
  * @author ruoyi
  */
 @RestController
 @RequestMapping("/monitor/online")
-public class SysUserOnlineController extends BaseController
-{
+public class SysUserOnlineController extends BaseController {
     @Autowired
     private ISysUserOnlineService userOnlineService;
-
     @Autowired
-    private RedisCache redisCache;
+    private TokenService tokenService;
+
+//    @Autowired
+//    private RedisCache redisCache;
 
     @PreAuthorize("@ss.hasPermi('monitor:online:list')")
     @GetMapping("/list")
-    public TableDataInfo list(String ipaddr, String userName)
-    {
-        Collection<String> keys = redisCache.keys(Constants.LOGIN_TOKEN_KEY + "*");
+    public TableDataInfo list(String ipaddr, String userName) {
+//        Collection<String> keys = redisCache.keys(Constants.LOGIN_TOKEN_KEY + "*");
+        Map<String, Object> keys = tokenService.getLoginUsers();
         List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();
-        for (String key : keys)
-        {
-            LoginUser user = redisCache.getCacheObject(key);
-            if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName))
-            {
-                if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername()))
-                {
+        for (String key : keys.keySet()) {
+            LoginUser user = (LoginUser) keys.get(key);
+//            LoginUser user = redisCache.getCacheObject(key);
+            if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) {
+                if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername())) {
                     userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user));
                 }
-            }
-            else if (StringUtils.isNotEmpty(ipaddr))
-            {
-                if (StringUtils.equals(ipaddr, user.getIpaddr()))
-                {
+            } else if (StringUtils.isNotEmpty(ipaddr)) {
+                if (StringUtils.equals(ipaddr, user.getIpaddr())) {
                     userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user));
                 }
-            }
-            else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser()))
-            {
-                if (StringUtils.equals(userName, user.getUsername()))
-                {
+            } else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser())) {
+                if (StringUtils.equals(userName, user.getUsername())) {
                     userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user));
                 }
-            }
-            else
-            {
+            } else {
                 userOnlineList.add(userOnlineService.loginUserToUserOnline(user));
             }
         }
@@ -84,9 +74,9 @@ public class SysUserOnlineController extends BaseController
     @PreAuthorize("@ss.hasPermi('monitor:online:forceLogout')")
     @Log(title = "在线用户", businessType = BusinessType.FORCE)
     @DeleteMapping("/{tokenId}")
-    public AjaxResult forceLogout(@PathVariable String tokenId)
-    {
-        redisCache.deleteObject(Constants.LOGIN_TOKEN_KEY + tokenId);
+    public AjaxResult forceLogout(@PathVariable String tokenId) {
+        tokenService.removeToken(Constants.LOGIN_TOKEN_KEY + tokenId);
+//        redisCache.deleteObject(Constants.LOGIN_TOKEN_KEY + tokenId);
         return AjaxResult.success();
     }
 }

+ 8 - 8
ruoyi-admin/src/main/resources/application-druid.yml

@@ -6,16 +6,16 @@ spring:
         druid:
             # 主库数据源
             master:
-                url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                url: jdbc:mysql://192.168.101.11:3306/zhaoshang?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
                 username: root
-                password: password
+                password: 123456
             # 从库数据源
             slave:
                 # 从数据源开关/默认关闭
                 enabled: false
-                url: 
-                username: 
-                password: 
+                url:
+                username:
+                password:
             # 初始连接数
             initialSize: 5
             # 最小连接池数量
@@ -35,7 +35,7 @@ spring:
             testWhileIdle: true
             testOnBorrow: false
             testOnReturn: false
-            webStatFilter: 
+            webStatFilter:
                 enabled: true
             statViewServlet:
                 enabled: true
@@ -43,8 +43,8 @@ spring:
                 allow:
                 url-pattern: /druid/*
                 # 控制台管理用户名和密码
-                login-username: 
-                login-password: 
+                login-username:
+                login-password:
             filter:
                 stat:
                     enabled: true

+ 22 - 22
ruoyi-admin/src/main/resources/application.yml

@@ -57,27 +57,27 @@ spring:
       # 热部署开关
       enabled: true
   # redis 配置
-  redis:
-    # 地址
-    host: localhost
-    # 端口,默认为6379
-    port: 6379
-    # 数据库索引
-    database: 0
-    # 密码
-    password: 
-    # 连接超时时间
-    timeout: 10s
-    lettuce:
-      pool:
-        # 连接池中的最小空闲连接
-        min-idle: 0
-        # 连接池中的最大空闲连接
-        max-idle: 8
-        # 连接池的最大数据库连接数
-        max-active: 8
-        # #连接池最大阻塞等待时间(使用负值表示没有限制)
-        max-wait: -1ms
+#  redis:
+#    # 地址
+#    host: localhost
+#    # 端口,默认为6379
+#    port: 6379
+#    # 数据库索引
+#    database: 0
+#    # 密码
+#    password:
+#    # 连接超时时间
+#    timeout: 10s
+#    lettuce:
+#      pool:
+#        # 连接池中的最小空闲连接
+#        min-idle: 0
+#        # 连接池中的最大空闲连接
+#        max-idle: 8
+#        # 连接池的最大数据库连接数
+#        max-active: 8
+#        # #连接池最大阻塞等待时间(使用负值表示没有限制)
+#        max-wait: -1ms
 
 # token配置
 token:
@@ -86,7 +86,7 @@ token:
     # 令牌密钥
     secret: abcdefghijklmnopqrstuvwxyz
     # 令牌有效期(默认30分钟)
-    expireTime: 30
+    expireTime: 60
   
 # MyBatis配置
 mybatis:

+ 14 - 2
ruoyi-common/pom.xml

@@ -96,10 +96,10 @@
         </dependency>
 
         <!-- redis 缓存操作 -->
-        <dependency>
+<!--        <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-data-redis</artifactId>
-        </dependency>
+        </dependency>-->
 
         <!-- pool 对象池 -->
         <dependency>
@@ -107,6 +107,18 @@
             <artifactId>commons-pool2</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-cache</artifactId>
+            <version>5.4.7</version>
+        </dependency>
+
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-http</artifactId>
+            <version>5.4.7</version>
+        </dependency>
+
         <!-- 解析客户端操作系统、浏览器等 -->
         <dependency>
             <groupId>eu.bitwalker</groupId>

+ 51 - 71
ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java

@@ -1,46 +1,47 @@
 package com.ruoyi.common.utils;
 
-import java.util.Collection;
-import java.util.List;
+import cn.hutool.cache.Cache;
+import cn.hutool.cache.CacheUtil;
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.core.domain.entity.SysDictData;
-import com.ruoyi.common.core.redis.RedisCache;
-import com.ruoyi.common.utils.spring.SpringUtils;
+
+import java.util.List;
 
 /**
  * 字典工具类
- * 
+ *
  * @author ruoyi
  */
-public class DictUtils
-{
+public class DictUtils {
     /**
      * 分隔符
      */
     public static final String SEPARATOR = ",";
+    private static final Cache<String, Object> CACHE_OBJECT = CacheUtil.newLFUCache(500);
 
     /**
      * 设置字典缓存
-     * 
-     * @param key 参数键
+     *
+     * @param key       参数键
      * @param dictDatas 字典数据列表
      */
-    public static void setDictCache(String key, List<SysDictData> dictDatas)
-    {
-        SpringUtils.getBean(RedisCache.class).setCacheObject(getCacheKey(key), dictDatas);
+    public static void setDictCache(String key, List<SysDictData> dictDatas) {
+
+        CACHE_OBJECT.put(getCacheKey(key), dictDatas);
+
+//        SpringUtils.getBean(RedisCache.class).setCacheObject(getCacheKey(key), dictDatas);
     }
 
     /**
      * 获取字典缓存
-     * 
+     *
      * @param key 参数键
      * @return dictDatas 字典数据列表
      */
-    public static List<SysDictData> getDictCache(String key)
-    {
-        Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key));
-        if (StringUtils.isNotNull(cacheObj))
-        {
+    public static List<SysDictData> getDictCache(String key) {
+        Object cacheObj = CACHE_OBJECT.get(getCacheKey(key));
+//        Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key));
+        if (StringUtils.isNotNull(cacheObj)) {
             List<SysDictData> dictDatas = StringUtils.cast(cacheObj);
             return dictDatas;
         }
@@ -49,61 +50,50 @@ public class DictUtils
 
     /**
      * 根据字典类型和字典值获取字典标签
-     * 
-     * @param dictType 字典类型
+     *
+     * @param dictType  字典类型
      * @param dictValue 字典值
      * @return 字典标签
      */
-    public static String getDictLabel(String dictType, String dictValue)
-    {
+    public static String getDictLabel(String dictType, String dictValue) {
         return getDictLabel(dictType, dictValue, SEPARATOR);
     }
 
     /**
      * 根据字典类型和字典标签获取字典值
-     * 
-     * @param dictType 字典类型
+     *
+     * @param dictType  字典类型
      * @param dictLabel 字典标签
      * @return 字典值
      */
-    public static String getDictValue(String dictType, String dictLabel)
-    {
+    public static String getDictValue(String dictType, String dictLabel) {
         return getDictValue(dictType, dictLabel, SEPARATOR);
     }
 
     /**
      * 根据字典类型和字典值获取字典标签
-     * 
-     * @param dictType 字典类型
+     *
+     * @param dictType  字典类型
      * @param dictValue 字典值
      * @param separator 分隔符
      * @return 字典标签
      */
-    public static String getDictLabel(String dictType, String dictValue, String separator)
-    {
+    public static String getDictLabel(String dictType, String dictValue, String separator) {
         StringBuilder propertyString = new StringBuilder();
         List<SysDictData> datas = getDictCache(dictType);
 
-        if (StringUtils.containsAny(separator, dictValue) && StringUtils.isNotEmpty(datas))
-        {
-            for (SysDictData dict : datas)
-            {
-                for (String value : dictValue.split(separator))
-                {
-                    if (value.equals(dict.getDictValue()))
-                    {
+        if (StringUtils.containsAny(separator, dictValue) && StringUtils.isNotEmpty(datas)) {
+            for (SysDictData dict : datas) {
+                for (String value : dictValue.split(separator)) {
+                    if (value.equals(dict.getDictValue())) {
                         propertyString.append(dict.getDictLabel() + separator);
                         break;
                     }
                 }
             }
-        }
-        else
-        {
-            for (SysDictData dict : datas)
-            {
-                if (dictValue.equals(dict.getDictValue()))
-                {
+        } else {
+            for (SysDictData dict : datas) {
+                if (dictValue.equals(dict.getDictValue())) {
                     return dict.getDictLabel();
                 }
             }
@@ -113,37 +103,28 @@ public class DictUtils
 
     /**
      * 根据字典类型和字典标签获取字典值
-     * 
-     * @param dictType 字典类型
+     *
+     * @param dictType  字典类型
      * @param dictLabel 字典标签
      * @param separator 分隔符
      * @return 字典值
      */
-    public static String getDictValue(String dictType, String dictLabel, String separator)
-    {
+    public static String getDictValue(String dictType, String dictLabel, String separator) {
         StringBuilder propertyString = new StringBuilder();
         List<SysDictData> datas = getDictCache(dictType);
 
-        if (StringUtils.containsAny(separator, dictLabel) && StringUtils.isNotEmpty(datas))
-        {
-            for (SysDictData dict : datas)
-            {
-                for (String label : dictLabel.split(separator))
-                {
-                    if (label.equals(dict.getDictLabel()))
-                    {
+        if (StringUtils.containsAny(separator, dictLabel) && StringUtils.isNotEmpty(datas)) {
+            for (SysDictData dict : datas) {
+                for (String label : dictLabel.split(separator)) {
+                    if (label.equals(dict.getDictLabel())) {
                         propertyString.append(dict.getDictValue() + separator);
                         break;
                     }
                 }
             }
-        }
-        else
-        {
-            for (SysDictData dict : datas)
-            {
-                if (dictLabel.equals(dict.getDictLabel()))
-                {
+        } else {
+            for (SysDictData dict : datas) {
+                if (dictLabel.equals(dict.getDictLabel())) {
                     return dict.getDictValue();
                 }
             }
@@ -154,20 +135,19 @@ public class DictUtils
     /**
      * 清空字典缓存
      */
-    public static void clearDictCache()
-    {
-        Collection<String> keys = SpringUtils.getBean(RedisCache.class).keys(Constants.SYS_DICT_KEY + "*");
-        SpringUtils.getBean(RedisCache.class).deleteObject(keys);
+    public static void clearDictCache() {
+        CACHE_OBJECT.clear();
+//        Collection<String> keys = SpringUtils.getBean(RedisCache.class).keys(Constants.SYS_DICT_KEY + "*");
+//        SpringUtils.getBean(RedisCache.class).deleteObject(keys);
     }
 
     /**
      * 设置cache key
-     * 
+     *
      * @param configKey 参数键
      * @return 缓存键key
      */
-    public static String getCacheKey(String configKey)
-    {
+    public static String getCacheKey(String configKey) {
         return Constants.SYS_DICT_KEY + configKey;
     }
 }

+ 5 - 3
ruoyi-framework/src/main/java/com/ruoyi/framework/config/FastJson2JsonRedisSerializer.java

@@ -1,3 +1,4 @@
+/*
 package com.ruoyi.framework.config;
 
 import com.alibaba.fastjson.JSON;
@@ -5,17 +6,17 @@ import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.fasterxml.jackson.databind.JavaType;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.type.TypeFactory;
-import org.springframework.data.redis.serializer.RedisSerializer;
-import org.springframework.data.redis.serializer.SerializationException;
 import com.alibaba.fastjson.parser.ParserConfig;
 import org.springframework.util.Assert;
 import java.nio.charset.Charset;
 
+*/
 /**
  * Redis使用FastJson序列化
  * 
  * @author ruoyi
- */
+ *//*
+
 public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T>
 {
     @SuppressWarnings("unused")
@@ -69,3 +70,4 @@ public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T>
         return TypeFactory.defaultInstance().constructType(clazz);
     }
 }
+*/

+ 5 - 1
ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java

@@ -1,3 +1,4 @@
+/*
 package com.ruoyi.framework.config;
 
 import org.springframework.cache.annotation.CachingConfigurerSupport;
@@ -13,11 +14,13 @@ import com.fasterxml.jackson.annotation.PropertyAccessor;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
 
+*/
 /**
  * redis配置
  * 
  * @author ruoyi
- */
+ *//*
+
 @Configuration
 @EnableCaching
 public class RedisConfig extends CachingConfigurerSupport
@@ -43,3 +46,4 @@ public class RedisConfig extends CachingConfigurerSupport
         return template;
     }
 }
+*/

+ 29 - 35
ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java

@@ -2,28 +2,28 @@ package com.ruoyi.framework.interceptor.impl;
 
 import java.util.HashMap;
 import java.util.Map;
-import java.util.concurrent.TimeUnit;
 import javax.servlet.http.HttpServletRequest;
-import org.springframework.beans.factory.annotation.Autowired;
+
+import cn.hutool.cache.Cache;
+import cn.hutool.cache.CacheUtil;
+import com.ruoyi.common.utils.http.HttpHelper;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 import com.alibaba.fastjson.JSONObject;
 import com.ruoyi.common.constant.Constants;
-import com.ruoyi.common.core.redis.RedisCache;
+//import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.filter.RepeatedlyRequestWrapper;
 import com.ruoyi.common.utils.StringUtils;
-import com.ruoyi.common.utils.http.HttpHelper;
 import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor;
 
 /**
  * 判断请求url和数据是否和上一次相同,
  * 如果和上次相同,则是重复提交表单。 有效时间为10秒内。
- * 
+ *
  * @author ruoyi
  */
 @Component
-public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
-{
+public class SameUrlDataInterceptor extends RepeatSubmitInterceptor {
     public final String REPEAT_PARAMS = "repeatParams";
 
     public final String REPEAT_TIME = "repeatTime";
@@ -32,35 +32,35 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
     @Value("${token.header}")
     private String header;
 
-    @Autowired
-    private RedisCache redisCache;
-
     /**
      * 间隔时间,单位:秒 默认10秒
-     * 
+     * <p>
      * 两次相同参数的请求,如果间隔时间大于该参数,系统不会认定为重复提交的数据
      */
     private int intervalTime = 10;
 
-    public void setIntervalTime(int intervalTime)
-    {
+
+    private final Cache<String, Object> CACHE_OBJECT = CacheUtil.newTimedCache(intervalTime * 1000);
+
+//    @Autowired
+//    private RedisCache redisCache;
+
+
+    public void setIntervalTime(int intervalTime) {
         this.intervalTime = intervalTime;
     }
 
     @SuppressWarnings("unchecked")
     @Override
-    public boolean isRepeatSubmit(HttpServletRequest request)
-    {
+    public boolean isRepeatSubmit(HttpServletRequest request) {
         String nowParams = "";
-        if (request instanceof RepeatedlyRequestWrapper)
-        {
+        if (request instanceof RepeatedlyRequestWrapper) {
             RepeatedlyRequestWrapper repeatedlyRequest = (RepeatedlyRequestWrapper) request;
             nowParams = HttpHelper.getBodyString(repeatedlyRequest);
         }
 
         // body参数为空,获取Parameter的数据
-        if (StringUtils.isEmpty(nowParams))
-        {
+        if (StringUtils.isEmpty(nowParams)) {
             nowParams = JSONObject.toJSONString(request.getParameterMap());
         }
         Map<String, Object> nowDataMap = new HashMap<String, Object>();
@@ -72,38 +72,34 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
 
         // 唯一值(没有消息头则使用请求地址)
         String submitKey = request.getHeader(header);
-        if (StringUtils.isEmpty(submitKey))
-        {
+        if (StringUtils.isEmpty(submitKey)) {
             submitKey = url;
         }
 
         // 唯一标识(指定key + 消息头)
         String cache_repeat_key = Constants.REPEAT_SUBMIT_KEY + submitKey;
 
-        Object sessionObj = redisCache.getCacheObject(cache_repeat_key);
-        if (sessionObj != null)
-        {
+        Object sessionObj = CACHE_OBJECT.get(cache_repeat_key);
+//        Object sessionObj = redisCache.getCacheObject(cache_repeat_key);
+        if (sessionObj != null) {
             Map<String, Object> sessionMap = (Map<String, Object>) sessionObj;
-            if (sessionMap.containsKey(url))
-            {
+            if (sessionMap.containsKey(url)) {
                 Map<String, Object> preDataMap = (Map<String, Object>) sessionMap.get(url);
-                if (compareParams(nowDataMap, preDataMap) && compareTime(nowDataMap, preDataMap))
-                {
+                if (compareParams(nowDataMap, preDataMap) && compareTime(nowDataMap, preDataMap)) {
                     return true;
                 }
             }
         }
         Map<String, Object> cacheMap = new HashMap<String, Object>();
         cacheMap.put(url, nowDataMap);
-        redisCache.setCacheObject(cache_repeat_key, cacheMap, intervalTime, TimeUnit.SECONDS);
+        CACHE_OBJECT.put(cache_repeat_key, cacheMap);
         return false;
     }
 
     /**
      * 判断参数是否相同
      */
-    private boolean compareParams(Map<String, Object> nowMap, Map<String, Object> preMap)
-    {
+    private boolean compareParams(Map<String, Object> nowMap, Map<String, Object> preMap) {
         String nowParams = (String) nowMap.get(REPEAT_PARAMS);
         String preParams = (String) preMap.get(REPEAT_PARAMS);
         return nowParams.equals(preParams);
@@ -112,12 +108,10 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
     /**
      * 判断两次间隔时间
      */
-    private boolean compareTime(Map<String, Object> nowMap, Map<String, Object> preMap)
-    {
+    private boolean compareTime(Map<String, Object> nowMap, Map<String, Object> preMap) {
         long time1 = (Long) nowMap.get(REPEAT_TIME);
         long time2 = (Long) preMap.get(REPEAT_TIME);
-        if ((time1 - time2) < (this.intervalTime * 1000))
-        {
+        if ((time1 - time2) < (this.intervalTime * 1000)) {
             return true;
         }
         return false;

+ 2 - 16
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java

@@ -9,7 +9,6 @@ import org.springframework.security.core.Authentication;
 import org.springframework.stereotype.Component;
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.core.domain.model.LoginUser;
-import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.exception.CustomException;
 import com.ruoyi.common.exception.user.CaptchaException;
 import com.ruoyi.common.exception.user.CaptchaExpireException;
@@ -32,8 +31,8 @@ public class SysLoginService
     @Resource
     private AuthenticationManager authenticationManager;
 
-    @Autowired
-    private RedisCache redisCache;
+/*    @Autowired
+    private RedisCache redisCache;*/
 
     /**
      * 登录验证
@@ -46,19 +45,6 @@ public class SysLoginService
      */
     public String login(String username, String password, String code, String uuid)
     {
-        String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
-        String captcha = redisCache.getCacheObject(verifyKey);
-        redisCache.deleteObject(verifyKey);
-        if (captcha == null)
-        {
-            AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire")));
-            throw new CaptchaExpireException();
-        }
-        if (!code.equalsIgnoreCase(captcha))
-        {
-            AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error")));
-            throw new CaptchaException();
-        }
         // 用户验证
         Authentication authentication = null;
         try

+ 32 - 6
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java

@@ -1,15 +1,19 @@
 package com.ruoyi.framework.web.service;
 
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 import javax.servlet.http.HttpServletRequest;
+
+import cn.hutool.cache.CacheUtil;
+import cn.hutool.cache.impl.CacheObj;
+import cn.hutool.cache.impl.TimedCache;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.core.domain.model.LoginUser;
-import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.utils.ServletUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.ip.AddressUtils;
@@ -45,9 +49,12 @@ public class TokenService
     protected static final long MILLIS_MINUTE = 60 * MILLIS_SECOND;
 
     private static final Long MILLIS_MINUTE_TEN = 20 * 60 * 1000L;
-
+/*
     @Autowired
-    private RedisCache redisCache;
+    private RedisCache redisCache;*/
+
+    private final TimedCache<String, Object> CACHE_OBJECT = CacheUtil.newTimedCache(expireTime * 60 * 1000);
+
 
     /**
      * 获取用户身份信息
@@ -64,7 +71,8 @@ public class TokenService
             // 解析对应的权限以及用户信息
             String uuid = (String) claims.get(Constants.LOGIN_USER_KEY);
             String userKey = getTokenKey(uuid);
-            LoginUser user = redisCache.getCacheObject(userKey);
+            LoginUser user = (LoginUser) CACHE_OBJECT.get(userKey);
+            //LoginUser user = redisCache.getCacheObject(userKey);
             return user;
         }
         return null;
@@ -89,7 +97,9 @@ public class TokenService
         if (StringUtils.isNotEmpty(token))
         {
             String userKey = getTokenKey(token);
-            redisCache.deleteObject(userKey);
+            CACHE_OBJECT.remove(userKey);
+
+            //redisCache.deleteObject(userKey);
         }
     }
 
@@ -138,7 +148,9 @@ public class TokenService
         loginUser.setExpireTime(loginUser.getLoginTime() + expireTime * MILLIS_MINUTE);
         // 根据uuid将loginUser缓存
         String userKey = getTokenKey(loginUser.getToken());
-        redisCache.setCacheObject(userKey, loginUser, expireTime, TimeUnit.MINUTES);
+        CACHE_OBJECT.put(userKey, loginUser);
+
+        //redisCache.setCacheObject(userKey, loginUser, expireTime, TimeUnit.MINUTES);
     }
 
     /**
@@ -212,8 +224,22 @@ public class TokenService
         return token;
     }
 
+    public Map<String, Object> getLoginUsers() {
+        HashMap<String, Object> resultMap = new HashMap<>();
+        Iterator<CacheObj<String, Object>> cacheObjIterator = CACHE_OBJECT.cacheObjIterator();
+        while (cacheObjIterator.hasNext()) {
+            CacheObj<String, Object> next = cacheObjIterator.next();
+            resultMap.put(next.getKey(), next.getValue());
+        }
+        return resultMap;
+    }
+
     private String getTokenKey(String uuid)
     {
         return Constants.LOGIN_TOKEN_KEY + uuid;
     }
+
+    public void removeToken(String key) {
+        CACHE_OBJECT.remove(key);
+    }
 }

+ 25 - 15
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java

@@ -1,14 +1,13 @@
 package com.ruoyi.system.service.impl;
 
-import java.util.Collection;
 import java.util.List;
 import javax.annotation.PostConstruct;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
+
+import cn.hutool.cache.Cache;
+import cn.hutool.cache.CacheUtil;
 import com.ruoyi.common.annotation.DataSource;
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.constant.UserConstants;
-import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.core.text.Convert;
 import com.ruoyi.common.enums.DataSourceType;
 import com.ruoyi.common.exception.CustomException;
@@ -16,6 +15,8 @@ import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.system.domain.SysConfig;
 import com.ruoyi.system.mapper.SysConfigMapper;
 import com.ruoyi.system.service.ISysConfigService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
 
 /**
  * 参数配置 服务层实现
@@ -28,8 +29,8 @@ public class SysConfigServiceImpl implements ISysConfigService
     @Autowired
     private SysConfigMapper configMapper;
 
-    @Autowired
-    private RedisCache redisCache;
+    private final Cache<String, Object> CACHE_OBJECT = CacheUtil.newLFUCache(500);
+
 
     /**
      * 项目启动时,初始化参数到缓存
@@ -40,7 +41,8 @@ public class SysConfigServiceImpl implements ISysConfigService
         List<SysConfig> configsList = configMapper.selectConfigList(new SysConfig());
         for (SysConfig config : configsList)
         {
-            redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
+            CACHE_OBJECT.put(getCacheKey(config.getConfigKey()), config.getConfigValue());
+            //redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
         }
     }
 
@@ -68,7 +70,7 @@ public class SysConfigServiceImpl implements ISysConfigService
     @Override
     public String selectConfigByKey(String configKey)
     {
-        String configValue = Convert.toStr(redisCache.getCacheObject(getCacheKey(configKey)));
+        String configValue = Convert.toStr(CACHE_OBJECT.get(getCacheKey(configKey)));
         if (StringUtils.isNotEmpty(configValue))
         {
             return configValue;
@@ -78,7 +80,8 @@ public class SysConfigServiceImpl implements ISysConfigService
         SysConfig retConfig = configMapper.selectConfig(config);
         if (StringUtils.isNotNull(retConfig))
         {
-            redisCache.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue());
+            CACHE_OBJECT.put(getCacheKey(configKey), retConfig.getConfigValue());
+            //redisCache.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue());
             return retConfig.getConfigValue();
         }
         return StringUtils.EMPTY;
@@ -108,7 +111,9 @@ public class SysConfigServiceImpl implements ISysConfigService
         int row = configMapper.insertConfig(config);
         if (row > 0)
         {
-            redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
+            CACHE_OBJECT.put(getCacheKey(config.getConfigKey()), config.getConfigValue());
+
+            //redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
         }
         return row;
     }
@@ -125,7 +130,9 @@ public class SysConfigServiceImpl implements ISysConfigService
         int row = configMapper.updateConfig(config);
         if (row > 0)
         {
-            redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
+            CACHE_OBJECT.put(getCacheKey(config.getConfigKey()), config.getConfigValue());
+
+            //redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
         }
         return row;
     }
@@ -150,8 +157,9 @@ public class SysConfigServiceImpl implements ISysConfigService
         int count = configMapper.deleteConfigByIds(configIds);
         if (count > 0)
         {
-            Collection<String> keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*");
-            redisCache.deleteObject(keys);
+            CACHE_OBJECT.clear();
+            //Collection<String> keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*");
+            //redisCache.deleteObject(keys);
         }
         return count;
     }
@@ -162,8 +170,10 @@ public class SysConfigServiceImpl implements ISysConfigService
     @Override
     public void clearCache()
     {
-        Collection<String> keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*");
-        redisCache.deleteObject(keys);
+        CACHE_OBJECT.clear();
+
+        //Collection<String> keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*");
+        //redisCache.deleteObject(keys);
     }
 
     /**

+ 2 - 0
ruoyi-ui/.env.development

@@ -6,3 +6,5 @@ VUE_APP_BASE_API = '/dev-api'
 
 # 路由懒加载
 VUE_CLI_BABEL_TRANSPILE_MODULES = true
+#端口
+prot = 8081

+ 2 - 1
ruoyi-ui/src/api/login.js

@@ -31,10 +31,11 @@ export function logout() {
   })
 }
 
+/*
 // 获取验证码
 export function getCodeImg() {
   return request({
     url: '/captchaImage',
     method: 'get'
   })
-}
+}*/

+ 2 - 1
ruoyi-ui/src/settings.js

@@ -32,5 +32,6 @@ module.exports = {
    * The default is only used in the production env
    * If you want to also use it in dev, you can pass ['production', 'development']
    */
-  errorLog: 'production'
+  errorLog: 'production',
+  apiUrl: 'http://192.168.101.11:8080'
 }

+ 8 - 8
ruoyi-ui/src/views/login.vue

@@ -18,7 +18,7 @@
           <svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
         </el-input>
       </el-form-item>
-      <el-form-item prop="code">
+<!--      <el-form-item prop="code">
         <el-input
           v-model="loginForm.code"
           auto-complete="off"
@@ -31,7 +31,7 @@
         <div class="login-code">
           <img :src="codeUrl" @click="getCode" class="login-code-img"/>
         </div>
-      </el-form-item>
+      </el-form-item>-->
       <el-checkbox v-model="loginForm.rememberMe" style="margin:0px 0px 25px 0px;">记住密码</el-checkbox>
       <el-form-item style="width:100%;">
         <el-button
@@ -77,8 +77,8 @@ export default {
         ],
         password: [
           { required: true, trigger: "blur", message: "密码不能为空" }
-        ],
-        code: [{ required: true, trigger: "change", message: "验证码不能为空" }]
+        ]
+/*        code: [{ required: true, trigger: "change", message: "验证码不能为空" }]*/
       },
       loading: false,
       redirect: undefined
@@ -93,16 +93,16 @@ export default {
     }
   },
   created() {
-    this.getCode();
+    /*this.getCode();*/
     this.getCookie();
   },
   methods: {
-    getCode() {
+/*    getCode() {
       getCodeImg().then(res => {
         this.codeUrl = "data:image/gif;base64," + res.img;
         this.loginForm.uuid = res.uuid;
       });
-    },
+    },*/
     getCookie() {
       const username = Cookies.get("username");
       const password = Cookies.get("password");
@@ -130,7 +130,7 @@ export default {
             this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
           }).catch(() => {
             this.loading = false;
-            this.getCode();
+           /* this.getCode();*/
           });
         }
       });

+ 1 - 1
ruoyi-ui/vue.config.js

@@ -34,7 +34,7 @@ module.exports = {
     proxy: {
       // detail: https://cli.vuejs.org/config/#devserver-proxy
       [process.env.VUE_APP_BASE_API]: {
-        target: `http://localhost:8080`,
+        target: `http://192.168.101.11:8080`,
         changeOrigin: true,
         pathRewrite: {
           ['^' + process.env.VUE_APP_BASE_API]: ''