作者 RuoYi

优化代码

@@ -7,6 +7,7 @@ import java.util.List; @@ -7,6 +7,7 @@ import java.util.List;
7 import java.util.Map; 7 import java.util.Map;
8 import java.util.Properties; 8 import java.util.Properties;
9 import java.util.Set; 9 import java.util.Set;
  10 +import java.util.TreeSet;
10 import org.springframework.beans.factory.annotation.Autowired; 11 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.data.redis.core.RedisCallback; 12 import org.springframework.data.redis.core.RedisCallback;
12 import org.springframework.data.redis.core.RedisTemplate; 13 import org.springframework.data.redis.core.RedisTemplate;
@@ -80,7 +81,7 @@ public class CacheController @@ -80,7 +81,7 @@ public class CacheController
80 public AjaxResult getCacheKeys(@PathVariable String cacheName) 81 public AjaxResult getCacheKeys(@PathVariable String cacheName)
81 { 82 {
82 Set<String> cacheKeys = redisTemplate.keys(cacheName + "*"); 83 Set<String> cacheKeys = redisTemplate.keys(cacheName + "*");
83 - return AjaxResult.success(cacheKeys); 84 + return AjaxResult.success(new TreeSet<>(cacheKeys));
84 } 85 }
85 86
86 @PreAuthorize("@ss.hasPermi('monitor:cache:list')") 87 @PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@@ -32,10 +32,10 @@ public class XssFilter implements Filter @@ -32,10 +32,10 @@ public class XssFilter implements Filter
32 String tempExcludes = filterConfig.getInitParameter("excludes"); 32 String tempExcludes = filterConfig.getInitParameter("excludes");
33 if (StringUtils.isNotEmpty(tempExcludes)) 33 if (StringUtils.isNotEmpty(tempExcludes))
34 { 34 {
35 - String[] url = tempExcludes.split(",");  
36 - for (int i = 0; url != null && i < url.length; i++) 35 + String[] urls = tempExcludes.split(",");
  36 + for (String url : urls)
37 { 37 {
38 - excludes.add(url[i]); 38 + excludes.add(url);
39 } 39 }
40 } 40 }
41 } 41 }
@@ -56,6 +56,10 @@ public class DictUtils @@ -56,6 +56,10 @@ public class DictUtils
56 */ 56 */
57 public static String getDictLabel(String dictType, String dictValue) 57 public static String getDictLabel(String dictType, String dictValue)
58 { 58 {
  59 + if (StringUtils.isEmpty(dictValue))
  60 + {
  61 + return StringUtils.EMPTY;
  62 + }
59 return getDictLabel(dictType, dictValue, SEPARATOR); 63 return getDictLabel(dictType, dictValue, SEPARATOR);
60 } 64 }
61 65
@@ -68,6 +72,10 @@ public class DictUtils @@ -68,6 +72,10 @@ public class DictUtils
68 */ 72 */
69 public static String getDictValue(String dictType, String dictLabel) 73 public static String getDictValue(String dictType, String dictLabel)
70 { 74 {
  75 + if (StringUtils.isEmpty(dictLabel))
  76 + {
  77 + return StringUtils.EMPTY;
  78 + }
71 return getDictValue(dictType, dictLabel, SEPARATOR); 79 return getDictValue(dictType, dictLabel, SEPARATOR);
72 } 80 }
73 81