疯狂的狮子li
2021-12-23 c82afc8c461956e45be0aa29ca2a7fe3f18ee6f7
ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataSourceAspect.java
@@ -1,8 +1,8 @@
package com.ruoyi.framework.aspectj;
import cn.hutool.core.lang.Validator;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.utils.StringUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
@@ -17,15 +17,17 @@
/**
 * 多数据源处理
 *
 * @author ruoyi
 * @author Lion Li
 * @deprecated 3.6.0 移除 使用原生方法处理 功能更全
 */
@Aspect
@Order(-500)
@Component
@Deprecated
public class DataSourceAspect {
   @Pointcut("@annotation(com.ruoyi.common.annotation.DataSource)"
      + "|| @within(com.ruoyi.common.annotation.DataSource)")
         + "|| @within(com.ruoyi.common.annotation.DataSource)")
   public void dsPointCut() {
   }
@@ -33,7 +35,7 @@
   public Object around(ProceedingJoinPoint point) throws Throwable {
      DataSource dataSource = getDataSource(point);
      if (Validator.isNotNull(dataSource)) {
      if (StringUtils.isNotNull(dataSource)) {
         DynamicDataSourceContextHolder.poll();
         String source = dataSource.value().getSource();
         DynamicDataSourceContextHolder.push(source);
@@ -59,4 +61,5 @@
      return AnnotationUtils.findAnnotation(signature.getDeclaringType(), DataSource.class);
   }
}