【8.3.0】【rule】更新一个pids解析工具类

master
stylefeng 2024-08-30 11:49:55 +08:00
parent 1e87964c7d
commit fef2ce23b7
1 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,46 @@
package cn.stylefeng.roses.kernel.rule.tree.buildpids;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil;
import java.util.ArrayList;
import java.util.List;
/**
* pids
*
* @author fengshuonan
* @since 2024/8/30 11:10
*/
public class PidParseUtil {
/**
* pidLongList
*
* @author fengshuonan
* @since 2024/8/30 11:12
*/
public static List<Long> parseToPidList(String pidListString) {
List<Long> result = new ArrayList<>();
if (StrUtil.isBlank(pidListString)) {
return result;
}
// 去掉中括号符号
pidListString = pidListString.replaceAll("\\[", "");
pidListString = pidListString.replaceAll("]", "");
// 解析出来所有的id列表
String[] pidStringList = pidListString.split(",");
// 查找到缺失的父级id
for (String idString : pidStringList) {
result.add(Convert.toLong(idString));
}
return result;
}
}