#
cl
18 小时以前 217ed5c65b7f72359c241bb35180c0a861a05f52
#
2个文件已修改
30 ■■■■■ 已修改文件
rsf-open-api/src/main/java/com/vincent/rsf/openApi/common/datasource/UseDataSourceAspect.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/common/datasource/UseDataSourceAspect.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-open-api/src/main/java/com/vincent/rsf/openApi/common/datasource/UseDataSourceAspect.java
@@ -4,9 +4,12 @@
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.aop.support.AopUtils;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.util.ClassUtils;
import java.lang.reflect.Method;
@@ -33,13 +36,15 @@
    }
    private UseDataSource resolveAnnotation(ProceedingJoinPoint joinPoint) {
        Object target = joinPoint.getTarget();
        Class<?> userClass = ClassUtils.getUserClass(target);
        MethodSignature signature = (MethodSignature) joinPoint.getSignature();
        Method method = signature.getMethod();
        UseDataSource annotation = method.getAnnotation(UseDataSource.class);
        if (annotation != null) {
            return annotation;
        Method specific = AopUtils.getMostSpecificMethod(method, userClass);
        UseDataSource onMethod = AnnotationUtils.findAnnotation(specific, UseDataSource.class);
        if (onMethod != null) {
            return onMethod;
        }
        Class<?> targetClass = joinPoint.getTarget().getClass();
        return targetClass.getAnnotation(UseDataSource.class);
        return AnnotationUtils.findAnnotation(userClass, UseDataSource.class);
    }
}
rsf-server/src/main/java/com/vincent/rsf/server/common/datasource/UseDataSourceAspect.java
@@ -4,9 +4,12 @@
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.aop.support.AopUtils;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.util.ClassUtils;
import java.lang.reflect.Method;
@@ -33,14 +36,16 @@
    }
    private UseDataSource resolveAnnotation(ProceedingJoinPoint joinPoint) {
        Object target = joinPoint.getTarget();
        Class<?> userClass = ClassUtils.getUserClass(target);
        MethodSignature signature = (MethodSignature) joinPoint.getSignature();
        Method method = signature.getMethod();
        UseDataSource annotation = method.getAnnotation(UseDataSource.class);
        if (annotation != null) {
            return annotation;
        Method specific = AopUtils.getMostSpecificMethod(method, userClass);
        UseDataSource onMethod = AnnotationUtils.findAnnotation(specific, UseDataSource.class);
        if (onMethod != null) {
            return onMethod;
        }
        Class<?> targetClass = joinPoint.getTarget().getClass();
        return targetClass.getAnnotation(UseDataSource.class);
        return AnnotationUtils.findAnnotation(userClass, UseDataSource.class);
    }
}