Browse Source

优化代码

RuoYi 1 year ago
parent
commit
f0efa914fe

+ 8 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java

@@ -54,6 +54,10 @@ public class DictUtils
      */
      */
     public static String getDictLabel(String dictType, String dictValue)
     public static String getDictLabel(String dictType, String dictValue)
     {
     {
+        if (StringUtils.isEmpty(dictValue))
+        {
+            return StringUtils.EMPTY;
+        }
         return getDictLabel(dictType, dictValue, SEPARATOR);
         return getDictLabel(dictType, dictValue, SEPARATOR);
     }
     }
 
 
@@ -66,6 +70,10 @@ public class DictUtils
      */
      */
     public static String getDictValue(String dictType, String dictLabel)
     public static String getDictValue(String dictType, String dictLabel)
     {
     {
+        if (StringUtils.isEmpty(dictLabel))
+        {
+            return StringUtils.EMPTY;
+        }
         return getDictValue(dictType, dictLabel, SEPARATOR);
         return getDictValue(dictType, dictLabel, SEPARATOR);
     }
     }
 
 

+ 3 - 3
ruoyi-common/src/main/java/com/ruoyi/common/xss/XssFilter.java

@@ -31,10 +31,10 @@ public class XssFilter implements Filter
         String tempExcludes = filterConfig.getInitParameter("excludes");
         String tempExcludes = filterConfig.getInitParameter("excludes");
         if (StringUtils.isNotEmpty(tempExcludes))
         if (StringUtils.isNotEmpty(tempExcludes))
         {
         {
-            String[] url = tempExcludes.split(",");
-            for (int i = 0; url != null && i < url.length; i++)
+            String[] urls = tempExcludes.split(",");
+            for (String url : urls)
             {
             {
-                excludes.add(url[i]);
+                excludes.add(url);
             }
             }
         }
         }
     }
     }

+ 2 - 1
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/CacheService.java

@@ -1,6 +1,7 @@
 package com.ruoyi.framework.web.service;
 package com.ruoyi.framework.web.service;
 
 
 import java.util.Set;
 import java.util.Set;
+import java.util.TreeSet;
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.lang3.ArrayUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.constant.Constants;
@@ -33,7 +34,7 @@ public class CacheService
      */
      */
     public Set<String> getCacheKeys(String cacheName)
     public Set<String> getCacheKeys(String cacheName)
     {
     {
-        return CacheUtils.getCache(cacheName).keys();
+        return new TreeSet<>(CacheUtils.getCache(cacheName).keys());
     }
     }
 
 
     /**
     /**