增加 CommonResult 的 check 逻辑

This commit is contained in:
YunaiV
2022-06-17 23:54:42 +08:00
parent ff18d2f30a
commit ca28d791aa
38 changed files with 221 additions and 699 deletions

View File

@@ -77,9 +77,7 @@ public class TokenAuthenticationFilter extends OncePerRequestFilter {
private LoginUser buildLoginUserByToken(String token, Integer userType) {
try {
// 校验访问令牌
CommonResult<OAuth2AccessTokenCheckRespDTO> accessTokenResult = oauth2TokenApi.checkAccessToken(token);
accessTokenResult.checkError();
OAuth2AccessTokenCheckRespDTO accessToken = accessTokenResult.getData();
OAuth2AccessTokenCheckRespDTO accessToken = oauth2TokenApi.checkAccessToken(token).getCheckedData();
if (accessToken == null) {
return null;
}

View File

@@ -38,13 +38,12 @@ public class SecurityFrameworkServiceImpl implements SecurityFrameworkService {
private final LoadingCache<KeyValue<Long, List<String>>, Boolean> hasAnyRolesCache = CacheUtils.buildAsyncReloadingCache(
Duration.ofMinutes(1L), // 过期时间 1 分钟
new CacheLoader<KeyValue<Long, List<String>>, Boolean>() {
@Override
public Boolean load(KeyValue<Long, List<String>> key) {
CommonResult<Boolean> hasAnyRolesResult = permissionApi.hasAnyRoles(key.getKey(),
key.getValue().toArray(new String[0]));
hasAnyRolesResult.checkError();
return hasAnyRolesResult.getData();
return permissionApi.hasAnyRoles(key.getKey(), key.getValue().toArray(new String[0])).getCheckedData();
}
});
/**
@@ -53,13 +52,12 @@ public class SecurityFrameworkServiceImpl implements SecurityFrameworkService {
private final LoadingCache<KeyValue<Long, List<String>>, Boolean> hasAnyPermissionsCache = CacheUtils.buildAsyncReloadingCache(
Duration.ofMinutes(1L), // 过期时间 1 分钟
new CacheLoader<KeyValue<Long, List<String>>, Boolean>() {
@Override
public Boolean load(KeyValue<Long, List<String>> key) {
CommonResult<Boolean> hasAnyPermissionsResult = permissionApi.hasAnyPermissions(key.getKey(),
key.getValue().toArray(new String[0]));
hasAnyPermissionsResult.checkError();
return hasAnyPermissionsResult.getData();
return permissionApi.hasAnyPermissions(key.getKey(), key.getValue().toArray(new String[0])).getCheckedData();
}
});
@Override