update 优化数据权限缓存合并为一个 标注版本注释

feature/model
疯狂的狮子Li 3 years ago
parent d40b9324ca
commit 3fce90dbb9

@ -6,6 +6,7 @@ import java.lang.annotation.*;
*
*
* @author Lion Li
* @version 3.5.0
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)

@ -6,6 +6,7 @@ import java.lang.annotation.*;
*
*
* @author Lion Li
* @version 3.5.0
*/
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)

@ -15,6 +15,7 @@ import lombok.Getter;
* sdss
*
* @author Lion Li
* @version 3.5.0
*/
@Getter
@AllArgsConstructor

@ -41,15 +41,15 @@ import java.util.stream.Collectors;
*
*
* @author Lion Li
* @version 3.5.0
*/
@Slf4j
public class PlusDataPermissionHandler {
/**
*
* ()
*/
private final Map<Method, DataPermission> methodCacheMap = new ConcurrentHashMap<>();
private final Map<Class<?>, DataPermission> classCacheMap = new ConcurrentHashMap<>();
private final Map<String, DataPermission> dataPermissionCacheMap = new ConcurrentHashMap<>();
/**
*
@ -154,24 +154,24 @@ public class PlusDataPermissionHandler {
DataPermission dataPermission;
// 获取方法注解
for (Method method : methods) {
dataPermission = methodCacheMap.get(method);
dataPermission = dataPermissionCacheMap.get(method.getName());
if (ObjectUtil.isNotNull(dataPermission)) {
return dataPermission.value();
}
if (AnnotationUtil.hasAnnotation(method, DataPermission.class)) {
dataPermission = AnnotationUtil.getAnnotation(method, DataPermission.class);
methodCacheMap.put(method, dataPermission);
dataPermissionCacheMap.put(method.getName(), dataPermission);
return dataPermission.value();
}
}
dataPermission = classCacheMap.get(clazz);
dataPermission = dataPermissionCacheMap.get(clazz.getName());
if (ObjectUtil.isNotNull(dataPermission)) {
return dataPermission.value();
}
// 获取类注解
if (AnnotationUtil.hasAnnotation(clazz, DataPermission.class)) {
dataPermission = AnnotationUtil.getAnnotation(clazz, DataPermission.class);
classCacheMap.put(clazz, dataPermission);
dataPermissionCacheMap.put(clazz.getName(), dataPermission);
return dataPermission.value();
}
return null;

@ -24,6 +24,12 @@ import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
/**
*
*
* @author Lion Li
* @version 3.5.0
*/
public class PlusDataPermissionInterceptor extends JsqlParserSupport implements InnerInterceptor {
private final PlusDataPermissionHandler dataPermissionHandler = new PlusDataPermissionHandler();

Loading…
Cancel
Save