|
@@ -9,8 +9,6 @@ import org.springframework.core.Ordered;
|
|
|
import org.springframework.core.annotation.Order;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
-import java.util.Objects;
|
|
|
-
|
|
|
@Aspect
|
|
|
@Component
|
|
|
@Order(Ordered.HIGHEST_PRECEDENCE)
|
|
@@ -25,22 +23,31 @@ public class DataSourceAspect {
|
|
|
public Object before(ProceedingJoinPoint point) throws Throwable {
|
|
|
Object target = point.getTarget();
|
|
|
String name = target.getClass().getName();
|
|
|
- String moduleName = name.split("\\.")[2];
|
|
|
+ String moduleName = name.split("\\.")[1];
|
|
|
|
|
|
String peek = DynamicDataSourceContextHolder.peek();
|
|
|
- if (Objects.equals(peek, moduleName)) {
|
|
|
- return point.proceed();
|
|
|
- }
|
|
|
-
|
|
|
- if (moduleName.equals("")) {
|
|
|
- try {
|
|
|
- DynamicDataSourceContextHolder.push(moduleName);
|
|
|
+ if ("sd".equals(moduleName)) {
|
|
|
+ if ("business".equals(peek)) {
|
|
|
return point.proceed();
|
|
|
- } finally {
|
|
|
- DynamicDataSourceContextHolder.poll();
|
|
|
+ } else {
|
|
|
+ try {
|
|
|
+ DynamicDataSourceContextHolder.push("business");
|
|
|
+ return point.proceed();
|
|
|
+ } finally {
|
|
|
+ DynamicDataSourceContextHolder.poll();
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
- return point.proceed();
|
|
|
+ if ("base".equals(peek)) {
|
|
|
+ return point.proceed();
|
|
|
+ } else {
|
|
|
+ try {
|
|
|
+ DynamicDataSourceContextHolder.push("base");
|
|
|
+ return point.proceed();
|
|
|
+ } finally {
|
|
|
+ DynamicDataSourceContextHolder.poll();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|