sonarqube质量修复

This commit is contained in:
gaoqr
2024-10-08 16:52:56 +08:00
parent 4fe3cfda62
commit 73b4051641
41 changed files with 151 additions and 4400 deletions
@@ -1,7 +1,7 @@
package com.cf.imes.framework.security.core.service;
import cn.hutool.core.collection.CollUtil;
import com.cf.imes.framework.common.core.KeyValue;
import cn.hutool.core.lang.Pair;
import com.cf.imes.framework.common.util.cache.CacheUtils;
import com.cf.imes.framework.security.core.LoginUser;
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
@@ -28,12 +28,12 @@ public class SecurityFrameworkServiceImpl implements SecurityFrameworkService {
/**
* 针对 {@link #hasAnyRoles(String...)} 的缓存
*/
private final LoadingCache<KeyValue<Long, List<String>>, Boolean> hasAnyRolesCache = CacheUtils.buildCache(
private final LoadingCache<Pair<Long, List<String>>, Boolean> hasAnyRolesCache = CacheUtils.buildCache(
Duration.ofMinutes(1L), // 过期时间 1 分钟
new CacheLoader<KeyValue<Long, List<String>>, Boolean>() {
new CacheLoader<>() {
@Override
public Boolean load(KeyValue<Long, List<String>> key) {
public Boolean load(Pair<Long, List<String>> key) {
return permissionApi.hasAnyRoles(key.getKey(), key.getValue().toArray(new String[0])).getCheckedData();
}
@@ -42,12 +42,12 @@ public class SecurityFrameworkServiceImpl implements SecurityFrameworkService {
/**
* 针对 {@link #hasAnyPermissions(String...)} 的缓存
*/
private final LoadingCache<KeyValue<Long, List<String>>, Boolean> hasAnyPermissionsCache = CacheUtils.buildCache(
private final LoadingCache<Pair<Long, List<String>>, Boolean> hasAnyPermissionsCache = CacheUtils.buildCache(
Duration.ofMinutes(1L), // 过期时间 1 分钟
new CacheLoader<KeyValue<Long, List<String>>, Boolean>() {
new CacheLoader<>() {
@Override
public Boolean load(KeyValue<Long, List<String>> key) {
public Boolean load(Pair<Long, List<String>> key) {
Boolean checkedData = permissionApi.hasAnyPermissions(key.getKey(), key.getValue().toArray(new String[0])).getCheckedData();
return checkedData;
}
@@ -62,7 +62,7 @@ public class SecurityFrameworkServiceImpl implements SecurityFrameworkService {
@Override
@SneakyThrows
public boolean hasAnyPermissions(String... permissions) {
return hasAnyPermissionsCache.get(new KeyValue<>(SecurityFrameworkUtils.getLoginUserId(), Arrays.asList(permissions)));
return hasAnyPermissionsCache.get(new Pair<>(SecurityFrameworkUtils.getLoginUserId(), Arrays.asList(permissions)));
}
@Override
@@ -78,13 +78,13 @@ public class SecurityFrameworkServiceImpl implements SecurityFrameworkService {
@Override
@SneakyThrows
public boolean hasAnyRoles(String... roles) {
return hasAnyRolesCache.get(new KeyValue<>(SecurityFrameworkUtils.getLoginUserId(), Arrays.asList(roles)));
return hasAnyRolesCache.get(new Pair<>(SecurityFrameworkUtils.getLoginUserId(), Arrays.asList(roles)));
}
@Override
@SneakyThrows
public boolean hasAnyRoles(Long userId, String... roles) {
return hasAnyRolesCache.get(new KeyValue<>(userId, Arrays.asList(roles)));
return hasAnyRolesCache.get(new Pair<>(userId, Arrays.asList(roles)));
}
@Override