|
1
|
package com.ruoyi.framework.aspectj;
|
1
|
package com.ruoyi.framework.aspectj;
|
|
2
|
|
2
|
|
|
3
|
-import java.lang.reflect.Method;
|
3
|
+import java.util.Objects;
|
|
4
|
import org.aspectj.lang.ProceedingJoinPoint;
|
4
|
import org.aspectj.lang.ProceedingJoinPoint;
|
|
5
|
import org.aspectj.lang.annotation.Around;
|
5
|
import org.aspectj.lang.annotation.Around;
|
|
6
|
import org.aspectj.lang.annotation.Aspect;
|
6
|
import org.aspectj.lang.annotation.Aspect;
|
|
@@ -8,6 +8,7 @@ import org.aspectj.lang.annotation.Pointcut; |
|
@@ -8,6 +8,7 @@ import org.aspectj.lang.annotation.Pointcut; |
|
8
|
import org.aspectj.lang.reflect.MethodSignature;
|
8
|
import org.aspectj.lang.reflect.MethodSignature;
|
|
9
|
import org.slf4j.Logger;
|
9
|
import org.slf4j.Logger;
|
|
10
|
import org.slf4j.LoggerFactory;
|
10
|
import org.slf4j.LoggerFactory;
|
|
|
|
11
|
+import org.springframework.core.annotation.AnnotationUtils;
|
|
11
|
import org.springframework.core.annotation.Order;
|
12
|
import org.springframework.core.annotation.Order;
|
|
12
|
import org.springframework.stereotype.Component;
|
13
|
import org.springframework.stereotype.Component;
|
|
13
|
import com.ruoyi.common.utils.StringUtils;
|
14
|
import com.ruoyi.common.utils.StringUtils;
|
|
@@ -60,17 +61,12 @@ public class DataSourceAspect |
|
@@ -60,17 +61,12 @@ public class DataSourceAspect |
|
60
|
public DataSource getDataSource(ProceedingJoinPoint point)
|
61
|
public DataSource getDataSource(ProceedingJoinPoint point)
|
|
61
|
{
|
62
|
{
|
|
62
|
MethodSignature signature = (MethodSignature) point.getSignature();
|
63
|
MethodSignature signature = (MethodSignature) point.getSignature();
|
|
63
|
- Class<? extends Object> targetClass = point.getTarget().getClass();
|
|
|
|
64
|
- DataSource targetDataSource = targetClass.getAnnotation(DataSource.class);
|
|
|
|
65
|
- if (StringUtils.isNotNull(targetDataSource))
|
64
|
+ DataSource dataSource = AnnotationUtils.findAnnotation(signature.getMethod(), DataSource.class);
|
|
|
|
65
|
+ if (Objects.nonNull(dataSource))
|
|
66
|
{
|
66
|
{
|
|
67
|
- return targetDataSource;
|
|
|
|
68
|
- }
|
|
|
|
69
|
- else
|
|
|
|
70
|
- {
|
|
|
|
71
|
- Method method = signature.getMethod();
|
|
|
|
72
|
- DataSource dataSource = method.getAnnotation(DataSource.class);
|
|
|
|
73
|
return dataSource;
|
67
|
return dataSource;
|
|
74
|
}
|
68
|
}
|
|
|
|
69
|
+
|
|
|
|
70
|
+ return AnnotationUtils.findAnnotation(signature.getDeclaringType(), DataSource.class);
|
|
75
|
}
|
71
|
}
|
|
76
|
} |
72
|
} |