From 906bed08ffa383ecbb4421f8d557814e5e4b2d21 Mon Sep 17 00:00:00 2001 From: 935090232@qq.com <ak473600000> Date: Mon, 25 Oct 2021 17:29:56 +0800 Subject: [PATCH] 替换redis缓存 --- zq-erp/src/main/java/com/matrix/core/tools/StringUtils.java | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 42 insertions(+), 0 deletions(-) diff --git a/zq-erp/src/main/java/com/matrix/core/tools/StringUtils.java b/zq-erp/src/main/java/com/matrix/core/tools/StringUtils.java index 60ff28d..673efa2 100644 --- a/zq-erp/src/main/java/com/matrix/core/tools/StringUtils.java +++ b/zq-erp/src/main/java/com/matrix/core/tools/StringUtils.java @@ -8,6 +8,7 @@ import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType; import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; import org.apache.commons.collections.CollectionUtils; +import org.springframework.util.AntPathMatcher; import java.io.UnsupportedEncodingException; import java.util.*; @@ -29,6 +30,47 @@ private static final String EMPTY = ""; + + /** + * 查找指定字符串是否匹配指定字符串列表中的任意一个字符串 + * + * @param str 指定字符串 + * @param strs 需要检查的字符串数组 + * @return 是否匹配 + */ + public static boolean matches(String str, List<String> strs) + { + if (isBlank(str) || CollectionUtils.isEmpty(strs)) + { + return false; + } + for (String pattern : strs) + { + if (isMatch(pattern, str)) + { + return true; + } + } + return false; + } + + /** + * 判断url是否与规则配置: + * ? 表示单个字符; + * * 表示一层路径内的任意字符串,不可跨层级; + * ** 表示任意层路径; + * + * @param pattern 匹配规则 + * @param url 需要匹配的url + * @return + */ + public static boolean isMatch(String pattern, String url) + { + AntPathMatcher matcher = new AntPathMatcher(); + return matcher.match(pattern, url); + } + + /** * 将字符串中的某些值用指定字符代替 * -- Gitblit v1.9.1