1
0
mirror of https://github.com/FatttSnake/Pinnacle-OA.git synced 2026-04-04 22:41:24 +08:00

Added permission control for WorkController

This commit is contained in:
2023-05-24 02:33:33 +08:00
parent 6fb788df28
commit ffa4f85fc7
3 changed files with 253 additions and 186 deletions

View File

@@ -16,7 +16,7 @@ public class WebUtil {
}
public static String objectResponse(int resultCode, String msg, Object object) throws JsonProcessingException {
ResponseResult result = ResponseResult.build(resultCode, msg, object);
ResponseResult<Object> result = ResponseResult.build(resultCode, msg, object);
return convert2json(result);
}
@@ -32,4 +32,17 @@ public class WebUtil {
Object principal = authentication.getPrincipal();
return (LoginUser) principal;
}
public static boolean hasAuthority(String authority) {
return hasAnyAuthority(authority);
}
public static boolean hasAnyAuthority(String... authorities) {
for (String authority : authorities) {
if (getLoginUser().getAuthorities().stream().anyMatch(grantedAuthority -> grantedAuthority.getAuthority().equals(authority))) {
return true;
}
}
return false;
}
}