|
@ -20,6 +20,7 @@ import com.ruoyi.common.exception.ServiceException; |
|
|
*/ |
|
|
*/ |
|
|
public class SecurityUtils |
|
|
public class SecurityUtils |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 用户ID |
|
|
* 用户ID |
|
|
**/ |
|
|
**/ |
|
@ -49,7 +50,7 @@ public class SecurityUtils |
|
|
throw new ServiceException("获取部门ID异常", HttpStatus.UNAUTHORIZED); |
|
|
throw new ServiceException("获取部门ID异常", HttpStatus.UNAUTHORIZED); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 获取用户账户 |
|
|
* 获取用户账户 |
|
|
**/ |
|
|
**/ |
|
@ -145,7 +146,7 @@ public class SecurityUtils |
|
|
public static boolean hasPermi(Collection<String> authorities, String permission) |
|
|
public static boolean hasPermi(Collection<String> authorities, String permission) |
|
|
{ |
|
|
{ |
|
|
return authorities.stream().filter(StringUtils::hasText) |
|
|
return authorities.stream().filter(StringUtils::hasText) |
|
|
.anyMatch(x -> Constants.ALL_PERMISSION.contains(x) || PatternMatchUtils.simpleMatch(x, permission)); |
|
|
.anyMatch(x -> Constants.ALL_PERMISSION.equals(x) || PatternMatchUtils.simpleMatch(x, permission)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -171,7 +172,7 @@ public class SecurityUtils |
|
|
public static boolean hasRole(Collection<String> roles, String role) |
|
|
public static boolean hasRole(Collection<String> roles, String role) |
|
|
{ |
|
|
{ |
|
|
return roles.stream().filter(StringUtils::hasText) |
|
|
return roles.stream().filter(StringUtils::hasText) |
|
|
.anyMatch(x -> Constants.SUPER_ADMIN.contains(x) || PatternMatchUtils.simpleMatch(x, role)); |
|
|
.anyMatch(x -> Constants.SUPER_ADMIN.equals(x) || PatternMatchUtils.simpleMatch(x, role)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|