| | |
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.Set;
|
| | | import org.springframework.util.AntPathMatcher;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.core.text.StrFormatter;
|
| | |
|
| | | /**
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 是否为http(s)://开头
|
| | | * |
| | | * @param link 链接
|
| | | * @return 结果
|
| | | */
|
| | | public static boolean ishttp(String link)
|
| | | {
|
| | | return StringUtils.startsWithAny(link, Constants.HTTP, Constants.HTTPS);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 字符串转set
|
| | | *
|
| | | * @param str 字符串
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 下划线转驼峰命名
|
| | | * 驼峰转下划线命名
|
| | | */
|
| | | public static String toUnderScoreCase(String str)
|
| | | {
|
| | |
| | | return sb.toString();
|
| | | }
|
| | |
|
| | | /**
|
| | | * 查找指定字符串是否匹配指定字符串列表中的任意一个字符串
|
| | | * |
| | | * @param str 指定字符串
|
| | | * @param strs 需要检查的字符串数组
|
| | | * @return 是否匹配
|
| | | */
|
| | | public static boolean matches(String str, List<String> strs)
|
| | | {
|
| | | if (isEmpty(str) || 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);
|
| | | }
|
| | |
|
| | | @SuppressWarnings("unchecked")
|
| | | public static <T> T cast(Object obj)
|
| | | {
|