mirror of https://gitee.com/y_project/RuoYi.git
修改数据源类型优先级,先根据方法,再根据类
parent
f24da2fc98
commit
1cb1743445
|
@ -11,8 +11,8 @@ import com.ruoyi.common.enums.DataSourceType;
|
|||
/**
|
||||
* 自定义多数据源切换注解
|
||||
*
|
||||
* 优先级: 先方法,后类,如果方法覆盖了类上的数据源类型,以方法的为准,否则以类上的为准
|
||||
*
|
||||
* 优先级:先方法,后类,如果方法覆盖了类上的数据源类型,以方法的为准,否则以类上的为准
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Target({ ElementType.METHOD, ElementType.TYPE })
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.ruoyi.framework.aspectj;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Objects;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
|
@ -18,7 +17,7 @@ import com.ruoyi.common.utils.StringUtils;
|
|||
|
||||
/**
|
||||
* 多数据源处理
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Aspect
|
||||
|
@ -62,8 +61,6 @@ public class DataSourceAspect
|
|||
public DataSource getDataSource(ProceedingJoinPoint point)
|
||||
{
|
||||
MethodSignature signature = (MethodSignature) point.getSignature();
|
||||
// point.getTarget().getClass(); 这个获取的是动态代理的class,上面获取不到自定义注解
|
||||
// 先获取方法上的,获取不到啊再从class上找
|
||||
DataSource dataSource = AnnotationUtils.findAnnotation(signature.getMethod(), DataSource.class);
|
||||
if (Objects.nonNull(dataSource))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue