瀏覽代碼

add 新增 StringUtils splitTo 与 splitList 方法 优化业务代码

疯狂的狮子li 3 年之前
父節點
當前提交
2039aa4cb4
共有 16 個文件被更改,包括 287 次插入235 次删除
  1. 4 7
      ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/service/DictService.java
  2. 1 1
      ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/ServletUtils.java
  3. 1 1
      ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/StreamUtils.java
  4. 253 201
      ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/StringUtils.java
  5. 3 1
      ruoyi-common/ruoyi-common-excel/src/main/java/com/ruoyi/common/excel/annotation/ExcelDictFormat.java
  6. 2 2
      ruoyi-common/ruoyi-common-excel/src/main/java/com/ruoyi/common/excel/utils/ExcelUtil.java
  7. 2 2
      ruoyi-common/ruoyi-common-mybatis/src/main/java/com/ruoyi/common/mybatis/core/page/PageQuery.java
  8. 1 1
      ruoyi-common/ruoyi-common-sms/src/main/java/com/ruoyi/common/sms/core/TencentSmsTemplate.java
  9. 1 1
      ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/domain/GenTableColumn.java
  10. 3 3
      ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/GenUtils.java
  11. 2 2
      ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/VelocityUtils.java
  12. 3 2
      ruoyi-modules/ruoyi-resource/src/main/java/com/ruoyi/resource/service/impl/SysOssServiceImpl.java
  13. 3 2
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDeptController.java
  14. 4 5
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
  15. 2 2
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java
  16. 2 2
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java

+ 4 - 7
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/service/DictService.java

@@ -1,5 +1,7 @@
 package com.ruoyi.common.core.service;
 
+import com.ruoyi.common.core.utils.StringUtils;
+
 /**
  * 字典服务服务
  *
@@ -7,11 +9,6 @@ package com.ruoyi.common.core.service;
  */
 public interface DictService {
 
-    /**
-     * 分隔符
-     */
-    String SEPARATOR = ",";
-
     /**
      * 根据字典类型和字典值获取字典标签
      *
@@ -20,7 +17,7 @@ public interface DictService {
      * @return 字典标签
      */
     default String getDictLabel(String dictType, String dictValue) {
-        return getDictLabel(dictType, dictValue, SEPARATOR);
+        return getDictLabel(dictType, dictValue, StringUtils.SEPARATOR);
     }
 
     /**
@@ -31,7 +28,7 @@ public interface DictService {
      * @return 字典值
      */
     default String getDictValue(String dictType, String dictLabel) {
-        return getDictValue(dictType, dictLabel, SEPARATOR);
+        return getDictValue(dictType, dictLabel, StringUtils.SEPARATOR);
     }
 
     /**

+ 1 - 1
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/ServletUtils.java

@@ -96,7 +96,7 @@ public class ServletUtils extends ServletUtil {
     public static Map<String, String> getParamMap(ServletRequest request) {
         Map<String, String> params = new HashMap<>();
         for (Map.Entry<String, String[]> entry : getParams(request).entrySet()) {
-            params.put(entry.getKey(), StringUtils.join(entry.getValue(), ","));
+            params.put(entry.getKey(), StringUtils.join(entry.getValue(), StringUtils.SEPARATOR));
         }
         return params;
     }

+ 1 - 1
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/StreamUtils.java

@@ -42,7 +42,7 @@ public class StreamUtils {
      * @return 拼接后的list
      */
     public static <E> String join(Collection<E> collection, Function<E, String> function) {
-        return join(collection, function, ",");
+        return join(collection, function, StringUtils.SEPARATOR);
     }
 
     /**

+ 253 - 201
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/StringUtils.java

@@ -1,16 +1,16 @@
 package com.ruoyi.common.core.utils;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.convert.Convert;
 import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import org.springframework.util.AntPathMatcher;
 
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 
 /**
  * 字符串工具类
@@ -20,237 +20,238 @@ import java.util.Set;
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
 public class StringUtils extends org.apache.commons.lang3.StringUtils {
 
-	/**
-	 * 获取参数不为空值
-	 *
-	 * @param str defaultValue 要判断的value
-	 * @return value 返回值
-	 */
-	public static String blankToDefault(String str, String defaultValue) {
-		return StrUtil.blankToDefault(str, defaultValue);
-	}
+    public static final String SEPARATOR = ",";
 
-	/**
-	 * * 判断一个字符串是否为空串
-	 *
-	 * @param str String
-	 * @return true:为空 false:非空
-	 */
-	public static boolean isEmpty(String str) {
-		return StrUtil.isEmpty(str);
-	}
+    /**
+     * 获取参数不为空值
+     *
+     * @param str defaultValue 要判断的value
+     * @return value 返回值
+     */
+    public static String blankToDefault(String str, String defaultValue) {
+        return StrUtil.blankToDefault(str, defaultValue);
+    }
 
-	/**
-	 * * 判断一个字符串是否为非空串
-	 *
-	 * @param str String
-	 * @return true:非空串 false:空串
-	 */
-	public static boolean isNotEmpty(String str) {
-		return !isEmpty(str);
-	}
+    /**
+     * * 判断一个字符串是否为空串
+     *
+     * @param str String
+     * @return true:为空 false:非空
+     */
+    public static boolean isEmpty(String str) {
+        return StrUtil.isEmpty(str);
+    }
 
-	/**
-	 * 去空格
-	 */
-	public static String trim(String str) {
-		return StrUtil.trim(str);
-	}
+    /**
+     * * 判断一个字符串是否为非空串
+     *
+     * @param str String
+     * @return true:非空串 false:空串
+     */
+    public static boolean isNotEmpty(String str) {
+        return !isEmpty(str);
+    }
 
-	/**
-	 * 截取字符串
-	 *
-	 * @param str   字符串
-	 * @param start 开始
-	 * @return 结果
-	 */
-	public static String substring(final String str, int start) {
-		return substring(str, start, str.length());
-	}
+    /**
+     * 去空格
+     */
+    public static String trim(String str) {
+        return StrUtil.trim(str);
+    }
 
-	/**
-	 * 截取字符串
-	 *
-	 * @param str   字符串
-	 * @param start 开始
-	 * @param end   结束
-	 * @return 结果
-	 */
-	public static String substring(final String str, int start, int end) {
-		return StrUtil.sub(str, start, end);
-	}
+    /**
+     * 截取字符串
+     *
+     * @param str   字符串
+     * @param start 开始
+     * @return 结果
+     */
+    public static String substring(final String str, int start) {
+        return substring(str, start, str.length());
+    }
 
-	/**
-	 * 格式化文本, {} 表示占位符<br>
-	 * 此方法只是简单将占位符 {} 按照顺序替换为参数<br>
-	 * 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可<br>
-	 * 例:<br>
-	 * 通常使用:format("this is {} for {}", "a", "b") -> this is a for b<br>
-	 * 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a<br>
-	 * 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br>
-	 *
-	 * @param template 文本模板,被替换的部分用 {} 表示
-	 * @param params   参数值
-	 * @return 格式化后的文本
-	 */
-	public static String format(String template, Object... params) {
-		return StrUtil.format(template, params);
-	}
+    /**
+     * 截取字符串
+     *
+     * @param str   字符串
+     * @param start 开始
+     * @param end   结束
+     * @return 结果
+     */
+    public static String substring(final String str, int start, int end) {
+        return StrUtil.sub(str, start, end);
+    }
 
-	/**
-	 * 是否为http(s)://开头
-	 *
-	 * @param link 链接
-	 * @return 结果
-	 */
-	public static boolean ishttp(String link) {
-		return Validator.isUrl(link);
-	}
+    /**
+     * 格式化文本, {} 表示占位符<br>
+     * 此方法只是简单将占位符 {} 按照顺序替换为参数<br>
+     * 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可<br>
+     * 例:<br>
+     * 通常使用:format("this is {} for {}", "a", "b") -> this is a for b<br>
+     * 转义{}: format("this is \\{} for {}", "a", "b") -> this is {} for a<br>
+     * 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br>
+     *
+     * @param template 文本模板,被替换的部分用 {} 表示
+     * @param params   参数值
+     * @return 格式化后的文本
+     */
+    public static String format(String template, Object... params) {
+        return StrUtil.format(template, params);
+    }
 
-	/**
-	 * 字符串转set
-	 *
-	 * @param str 字符串
-	 * @param sep 分隔符
-	 * @return set集合
-	 */
-	public static Set<String> str2Set(String str, String sep) {
-		return new HashSet<>(str2List(str, sep, true, false));
-	}
+    /**
+     * 是否为http(s)://开头
+     *
+     * @param link 链接
+     * @return 结果
+     */
+    public static boolean ishttp(String link) {
+        return Validator.isUrl(link);
+    }
 
-	/**
-	 * 字符串转list
-	 *
-	 * @param str         字符串
-	 * @param sep         分隔符
-	 * @param filterBlank 过滤纯空白
-	 * @param trim        去掉首尾空白
-	 * @return list集合
-	 */
-	public static List<String> str2List(String str, String sep, boolean filterBlank, boolean trim) {
-		List<String> list = new ArrayList<>();
-		if (isEmpty(str)) {
-			return list;
-		}
+    /**
+     * 字符串转set
+     *
+     * @param str 字符串
+     * @param sep 分隔符
+     * @return set集合
+     */
+    public static Set<String> str2Set(String str, String sep) {
+        return new HashSet<>(str2List(str, sep, true, false));
+    }
 
-		// 过滤空白字符串
-		if (filterBlank && isBlank(str)) {
-			return list;
-		}
-		String[] split = str.split(sep);
-		for (String string : split) {
-			if (filterBlank && isBlank(string)) {
-				continue;
-			}
-			if (trim) {
-				string = trim(string);
-			}
-			list.add(string);
-		}
+    /**
+     * 字符串转list
+     *
+     * @param str         字符串
+     * @param sep         分隔符
+     * @param filterBlank 过滤纯空白
+     * @param trim        去掉首尾空白
+     * @return list集合
+     */
+    public static List<String> str2List(String str, String sep, boolean filterBlank, boolean trim) {
+        List<String> list = new ArrayList<>();
+        if (isEmpty(str)) {
+            return list;
+        }
 
-		return list;
-	}
+        // 过滤空白字符串
+        if (filterBlank && isBlank(str)) {
+            return list;
+        }
+        String[] split = str.split(sep);
+        for (String string : split) {
+            if (filterBlank && isBlank(string)) {
+                continue;
+            }
+            if (trim) {
+                string = trim(string);
+            }
+            list.add(string);
+        }
 
-	/**
-	 * 查找指定字符串是否包含指定字符串列表中的任意一个字符串同时串忽略大小写
-	 *
-	 * @param cs                  指定字符串
-	 * @param searchCharSequences 需要检查的字符串数组
-	 * @return 是否包含任意一个字符串
-	 */
-	public static boolean containsAnyIgnoreCase(CharSequence cs, CharSequence... searchCharSequences) {
-		return StrUtil.containsAnyIgnoreCase(cs, searchCharSequences);
-	}
+        return list;
+    }
 
-	/**
-	 * 驼峰转下划线命名
-	 */
-	public static String toUnderScoreCase(String str) {
-		return StrUtil.toUnderlineCase(str);
-	}
+    /**
+     * 查找指定字符串是否包含指定字符串列表中的任意一个字符串同时串忽略大小写
+     *
+     * @param cs                  指定字符串
+     * @param searchCharSequences 需要检查的字符串数组
+     * @return 是否包含任意一个字符串
+     */
+    public static boolean containsAnyIgnoreCase(CharSequence cs, CharSequence... searchCharSequences) {
+        return StrUtil.containsAnyIgnoreCase(cs, searchCharSequences);
+    }
 
-	/**
-	 * 是否包含字符串
-	 *
-	 * @param str  验证字符串
-	 * @param strs 字符串组
-	 * @return 包含返回true
-	 */
-	public static boolean inStringIgnoreCase(String str, String... strs) {
-		return StrUtil.equalsAnyIgnoreCase(str, strs);
-	}
+    /**
+     * 驼峰转下划线命名
+     */
+    public static String toUnderScoreCase(String str) {
+        return StrUtil.toUnderlineCase(str);
+    }
 
-	/**
-	 * 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:HELLO_WORLD->HelloWorld
-	 *
-	 * @param name 转换前的下划线大写方式命名的字符串
-	 * @return 转换后的驼峰式命名的字符串
-	 */
-	public static String convertToCamelCase(String name) {
-		return StrUtil.upperFirst(StrUtil.toCamelCase(name));
-	}
+    /**
+     * 是否包含字符串
+     *
+     * @param str  验证字符串
+     * @param strs 字符串组
+     * @return 包含返回true
+     */
+    public static boolean inStringIgnoreCase(String str, String... strs) {
+        return StrUtil.equalsAnyIgnoreCase(str, strs);
+    }
 
-	/**
-	 * 驼峰式命名法 例如:user_name->userName
-	 */
-	public static String toCamelCase(String s) {
-		return StrUtil.toCamelCase(s);
-	}
+    /**
+     * 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:HELLO_WORLD->HelloWorld
+     *
+     * @param name 转换前的下划线大写方式命名的字符串
+     * @return 转换后的驼峰式命名的字符串
+     */
+    public static String convertToCamelCase(String name) {
+        return StrUtil.upperFirst(StrUtil.toCamelCase(name));
+    }
 
-	/**
-	 * 查找指定字符串是否匹配指定字符串列表中的任意一个字符串
-	 *
-	 * @param str  指定字符串
-	 * @param strs 需要检查的字符串数组
-	 * @return 是否匹配
-	 */
-	public static boolean matches(String str, List<String> strs) {
-		if (isEmpty(str) || CollUtil.isEmpty(strs)) {
-			return false;
-		}
-		for (String pattern : strs) {
-			if (isMatch(pattern, str)) {
-				return true;
-			}
-		}
-		return false;
-	}
+    /**
+     * 驼峰式命名法 例如:user_name->userName
+     */
+    public static String toCamelCase(String s) {
+        return StrUtil.toCamelCase(s);
+    }
 
-	/**
-	 * 判断url是否与规则配置:
-	 * ? 表示单个字符;
-	 * * 表示一层路径内的任意字符串,不可跨层级;
-	 * ** 表示任意层路径;
-	 *
-	 * @param pattern 匹配规则
-	 * @param url     需要匹配的url
-	 * @return
-	 */
-	public static boolean isMatch(String pattern, String url) {
-		AntPathMatcher matcher = new AntPathMatcher();
-		return matcher.match(pattern, url);
-	}
+    /**
+     * 查找指定字符串是否匹配指定字符串列表中的任意一个字符串
+     *
+     * @param str  指定字符串
+     * @param strs 需要检查的字符串数组
+     * @return 是否匹配
+     */
+    public static boolean matches(String str, List<String> strs) {
+        if (isEmpty(str) || CollUtil.isEmpty(strs)) {
+            return false;
+        }
+        for (String pattern : strs) {
+            if (isMatch(pattern, str)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * 判断url是否与规则配置:
+     * ? 表示单个字符;
+     * * 表示一层路径内的任意字符串,不可跨层级;
+     * ** 表示任意层路径;
+     *
+     * @param pattern 匹配规则
+     * @param url     需要匹配的url
+     */
+    public static boolean isMatch(String pattern, String url) {
+        AntPathMatcher matcher = new AntPathMatcher();
+        return matcher.match(pattern, url);
+    }
 
     /**
      * 数字左边补齐0,使之达到指定长度。注意,如果数字转换为字符串后,长度大于size,则只保留 最后size个字符。
      *
-     * @param num 数字对象
+     * @param num  数字对象
      * @param size 字符串指定长度
      * @return 返回数字的字符串格式,该字符串为指定长度。
      */
-    public static final String padl(final Number num, final int size) {
+    public static String padl(final Number num, final int size) {
         return padl(num.toString(), size, '0');
     }
 
     /**
      * 字符串左补齐。如果原始字符串s长度大于size,则只保留最后size个字符。
      *
-     * @param s 原始字符串
+     * @param s    原始字符串
      * @param size 字符串指定长度
-     * @param c 用于补齐的字符
+     * @param c    用于补齐的字符
      * @return 返回指定长度的字符串,由原字符串左补齐或截取得到。
      */
-    public static final String padl(final String s, final int size, final char c) {
+    public static String padl(final String s, final int size, final char c) {
         final StringBuilder sb = new StringBuilder(size);
         if (s != null) {
             final int len = s.length();
@@ -270,4 +271,55 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
         return sb.toString();
     }
 
+    /**
+     * 切分字符串(分隔符默认逗号)
+     *
+     * @param str 被切分的字符串
+     * @return 分割后的数据列表
+     */
+    public static List<String> splitList(String str) {
+        return splitTo(str, Convert::toStr);
+    }
+
+    /**
+     * 切分字符串
+     *
+     * @param str       被切分的字符串
+     * @param separator 分隔符
+     * @return 分割后的数据列表
+     */
+    public static List<String> splitList(String str, String separator) {
+        return splitTo(str, separator, Convert::toStr);
+    }
+
+    /**
+     * 切分字符串自定义转换(分隔符默认逗号)
+     *
+     * @param str    被切分的字符串
+     * @param mapper 自定义转换
+     * @return 分割后的数据列表
+     */
+    public static <T> List<T> splitTo(String str, Function<? super Object, T> mapper) {
+        return splitTo(str, SEPARATOR, mapper);
+    }
+
+    /**
+     * 切分字符串自定义转换
+     *
+     * @param str       被切分的字符串
+     * @param separator 分隔符
+     * @param mapper    自定义转换
+     * @return 分割后的数据列表
+     */
+    public static <T> List<T> splitTo(String str, String separator, Function<? super Object, T> mapper) {
+        if (isBlank(str)) {
+            return new ArrayList<>(0);
+        }
+        return StrUtil.split(str, separator)
+            .stream()
+            .filter(Objects::nonNull)
+            .map(mapper)
+            .collect(Collectors.toList());
+    }
+
 }

+ 3 - 1
ruoyi-common/ruoyi-common-excel/src/main/java/com/ruoyi/common/excel/annotation/ExcelDictFormat.java

@@ -1,5 +1,7 @@
 package com.ruoyi.common.excel.annotation;
 
+import com.ruoyi.common.core.utils.StringUtils;
+
 import java.lang.annotation.*;
 
 /**
@@ -25,6 +27,6 @@ public @interface ExcelDictFormat {
     /**
      * 分隔符,读取字符串组内容
      */
-    String separator() default ",";
+    String separator() default StringUtils.SEPARATOR;
 
 }

+ 2 - 2
ruoyi-common/ruoyi-common-excel/src/main/java/com/ruoyi/common/excel/utils/ExcelUtil.java

@@ -270,7 +270,7 @@ public class ExcelUtil {
      */
     public static String convertByExp(String propertyValue, String converterExp, String separator) {
         StringBuilder propertyString = new StringBuilder();
-        String[] convertSource = converterExp.split(",");
+        String[] convertSource = converterExp.split(StringUtils.SEPARATOR);
         for (String item : convertSource) {
             String[] itemArray = item.split("=");
             if (StringUtils.containsAny(propertyValue, separator)) {
@@ -299,7 +299,7 @@ public class ExcelUtil {
      */
     public static String reverseByExp(String propertyValue, String converterExp, String separator) {
         StringBuilder propertyString = new StringBuilder();
-        String[] convertSource = converterExp.split(",");
+        String[] convertSource = converterExp.split(StringUtils.SEPARATOR);
         for (String item : convertSource) {
             String[] itemArray = item.split("=");
             if (StringUtils.containsAny(propertyValue, separator)) {

+ 2 - 2
ruoyi-common/ruoyi-common-mybatis/src/main/java/com/ruoyi/common/mybatis/core/page/PageQuery.java

@@ -87,8 +87,8 @@ public class PageQuery implements Serializable {
         // 兼容前端排序类型
         isAsc = StringUtils.replaceEach(isAsc, new String[]{"ascending", "descending"}, new String[]{"asc", "desc"});
 
-        String[] orderByArr = orderBy.split(",");
-        String[] isAscArr = isAsc.split(",");
+        String[] orderByArr = orderBy.split(StringUtils.SEPARATOR);
+        String[] isAscArr = isAsc.split(StringUtils.SEPARATOR);
         if (isAscArr.length != 1 && isAscArr.length != orderByArr.length) {
             throw new ServiceException("排序参数有误");
         }

+ 1 - 1
ruoyi-common/ruoyi-common-sms/src/main/java/com/ruoyi/common/sms/core/TencentSmsTemplate.java

@@ -52,7 +52,7 @@ public class TencentSmsTemplate implements SmsTemplate {
             throw new SmsException("模板ID不能为空");
         }
         SendSmsRequest req = new SendSmsRequest();
-        Set<String> set = Arrays.stream(phones.split(",")).map(p -> "+86" + p).collect(Collectors.toSet());
+        Set<String> set = Arrays.stream(phones.split(StringUtils.SEPARATOR)).map(p -> "+86" + p).collect(Collectors.toSet());
         req.setPhoneNumberSet(ArrayUtil.toArray(set, String.class));
         if (CollUtil.isNotEmpty(param)) {
             req.setTemplateParamSet(ArrayUtil.toArray(param.values(), String.class));

+ 1 - 1
ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/domain/GenTableColumn.java

@@ -212,7 +212,7 @@ public class GenTableColumn extends BaseEntity {
                 if (StringUtils.isNotEmpty(value)) {
                     Object startStr = value.subSequence(0, 1);
                     String endStr = value.substring(1);
-                    sb.append("").append(startStr).append("=").append(endStr).append(",");
+                    sb.append(StringUtils.EMPTY).append(startStr).append("=").append(endStr).append(StringUtils.SEPARATOR);
                 }
             }
             return sb.deleteCharAt(sb.length() - 1).toString();

+ 3 - 3
ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/GenUtils.java

@@ -57,7 +57,7 @@ public class GenUtils {
             column.setHtmlType(GenConstants.HTML_INPUT);
 
             // 如果是浮点型 统一用BigDecimal
-            String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), ",");
+            String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), StringUtils.SEPARATOR);
             if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0) {
                 column.setJavaType(GenConstants.TYPE_BIGDECIMAL);
             }
@@ -166,7 +166,7 @@ public class GenUtils {
         boolean autoRemovePre = GenConfig.getAutoRemovePre();
         String tablePrefix = GenConfig.getTablePrefix();
         if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix)) {
-            String[] searchList = StringUtils.split(tablePrefix, ",");
+            String[] searchList = StringUtils.split(tablePrefix, StringUtils.SEPARATOR);
             tableName = replaceFirst(tableName, searchList);
         }
         return StringUtils.convertToCamelCase(tableName);
@@ -183,7 +183,7 @@ public class GenUtils {
         String text = replacementm;
         for (String searchString : searchList) {
             if (replacementm.startsWith(searchString)) {
-                text = replacementm.replaceFirst(searchString, "");
+                text = replacementm.replaceFirst(searchString, StringUtils.EMPTY);
                 break;
             }
         }

+ 2 - 2
ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/VelocityUtils.java

@@ -230,7 +230,7 @@ public class VelocityUtils {
     public static HashSet<String> getImportList(GenTable genTable) {
         List<GenTableColumn> columns = genTable.getColumns();
         GenTable subGenTable = genTable.getSubTable();
-        HashSet<String> importList = new HashSet<String>();
+        HashSet<String> importList = new HashSet<>();
         if (ObjectUtil.isNotNull(subGenTable)) {
             importList.add("java.util.List");
         }
@@ -252,7 +252,7 @@ public class VelocityUtils {
      */
     public static String getDicts(GenTable genTable) {
         List<GenTableColumn> columns = genTable.getColumns();
-        Set<String> dicts = new HashSet<String>();
+        Set<String> dicts = new HashSet<>();
         addDicts(dicts, columns);
         if (ObjectUtil.isNotNull(genTable.getSubTable())) {
             List<GenTableColumn> subColumns = genTable.getSubTable().getColumns();

+ 3 - 2
ruoyi-modules/ruoyi-resource/src/main/java/com/ruoyi/resource/service/impl/SysOssServiceImpl.java

@@ -1,6 +1,7 @@
 package com.ruoyi.resource.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.convert.Convert;
 import cn.hutool.core.io.IoUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -70,13 +71,13 @@ public class SysOssServiceImpl implements ISysOssService {
     @Override
     public String selectUrlByIds(String ossIds) {
         List<String> list = new ArrayList<>();
-        for (Long id : Arrays.stream(ossIds.split(",")).map(Long::parseLong).collect(Collectors.toList())) {
+        for (Long id : StringUtils.splitTo(ossIds, Convert::toLong)) {
             SysOssVo vo = SpringUtils.getAopProxy(this).getById(id);
             if (ObjectUtil.isNotNull(vo)) {
                 list.add(this.matchingUrl(vo).getUrl());
             }
         }
-        return String.join(",", list);
+        return String.join(StringUtils.SEPARATOR, list);
     }
 
     private LambdaQueryWrapper<SysOss> buildQueryWrapper(SysOssBo bo) {

+ 3 - 2
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDeptController.java

@@ -1,7 +1,7 @@
 package com.ruoyi.system.controller;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
-import cn.hutool.core.util.ArrayUtil;
+import cn.hutool.core.convert.Convert;
 import com.ruoyi.common.core.constant.UserConstants;
 import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.core.utils.StringUtils;
@@ -48,7 +48,8 @@ public class SysDeptController extends BaseController {
     @GetMapping("/list/exclude/{deptId}")
     public R<List<SysDept>> excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) {
         List<SysDept> depts = deptService.selectDeptList(new SysDept());
-        depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtil.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
+        depts.removeIf(d -> d.getDeptId().intValue() == deptId
+            || StringUtils.splitList(d.getAncestors()).contains(Convert.toStr(deptId)));
         return R.ok(depts);
     }
 

+ 4 - 5
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java

@@ -30,7 +30,6 @@ import org.springframework.stereotype.Service;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
-import java.util.stream.Collectors;
 
 /**
  * 部门管理 服务实现
@@ -131,13 +130,13 @@ public class SysDeptServiceImpl implements ISysDeptService {
     @Override
     public String selectDeptNameByIds(String deptIds) {
         List<String> list = new ArrayList<>();
-        for (Long id : Arrays.stream(deptIds.split(",")).map(Long::parseLong).collect(Collectors.toList())) {
+        for (Long id : StringUtils.splitTo(deptIds, Convert::toLong)) {
             SysDept dept = SpringUtils.getAopProxy(this).selectDeptById(id);
             if (ObjectUtil.isNotNull(dept)) {
                 list.add(dept.getDeptName());
             }
         }
-        return String.join(",", list);
+        return String.join(StringUtils.SEPARATOR, list);
     }
 
     /**
@@ -225,7 +224,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
         if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) {
             throw new ServiceException("部门停用,不允许新增");
         }
-        dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
+        dept.setAncestors(info.getAncestors() + StringUtils.SEPARATOR + dept.getParentId());
         return baseMapper.insert(dept);
     }
 
@@ -241,7 +240,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
         SysDept newParentDept = baseMapper.selectById(dept.getParentId());
         SysDept oldDept = baseMapper.selectById(dept.getDeptId());
         if (ObjectUtil.isNotNull(newParentDept) && ObjectUtil.isNotNull(oldDept)) {
-            String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
+            String newAncestors = newParentDept.getAncestors() + StringUtils.SEPARATOR + newParentDept.getDeptId();
             String oldAncestors = oldDept.getAncestors();
             dept.setAncestors(newAncestors);
             updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);

+ 2 - 2
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java

@@ -92,7 +92,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
         Set<String> permsSet = new HashSet<>();
         for (String perm : perms) {
             if (StringUtils.isNotEmpty(perm)) {
-                permsSet.addAll(Arrays.asList(perm.trim().split(",")));
+                permsSet.addAll(StringUtils.splitList(perm.trim()));
             }
         }
         return permsSet;
@@ -110,7 +110,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
         Set<String> permsSet = new HashSet<>();
         for (String perm : perms) {
             if (StringUtils.isNotEmpty(perm)) {
-                permsSet.addAll(Arrays.asList(perm.trim().split(",")));
+                permsSet.addAll(StringUtils.splitList(perm.trim()));
             }
         }
         return permsSet;

+ 2 - 2
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java

@@ -5,11 +5,11 @@ import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.common.core.constant.UserConstants;
 import com.ruoyi.common.core.exception.ServiceException;
+import com.ruoyi.common.core.utils.StringUtils;
 import com.ruoyi.common.mybatis.core.page.PageQuery;
 import com.ruoyi.common.mybatis.core.page.TableDataInfo;
 import com.ruoyi.common.satoken.utils.LoginHelper;
@@ -106,7 +106,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
         Set<String> permsSet = new HashSet<>();
         for (SysRole perm : perms) {
             if (ObjectUtil.isNotNull(perm)) {
-                permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(",")));
+                permsSet.addAll(StringUtils.splitList(perm.getRoleKey().trim()));
             }
         }
         return permsSet;