fix:动态数据源切面所在目录移动
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package com.cool.store.aspect;
|
||||
|
||||
import com.cool.store.annotation.PlatformDB;
|
||||
import com.cool.store.datasource.DataSourceContextHolder;
|
||||
import org.aspectj.lang.annotation.After;
|
||||
import org.aspectj.lang.annotation.AfterThrowing;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据源切换 切面
|
||||
* </p>
|
||||
*
|
||||
* @author wangff
|
||||
* @since 2025/9/4
|
||||
*/
|
||||
@Aspect
|
||||
@Component
|
||||
public class DataSourceAspect {
|
||||
|
||||
@Before("@annotation(platformDB)")
|
||||
public void before(PlatformDB platformDB) {
|
||||
DataSourceContextHolder.setDataSourceType("platform");
|
||||
}
|
||||
|
||||
@After("@annotation(platformDB)")
|
||||
public void after(PlatformDB platformDB) {
|
||||
DataSourceContextHolder.clearDataSourceType();
|
||||
}
|
||||
|
||||
@AfterThrowing("@annotation(platformDB)")
|
||||
public void afterThrowing(PlatformDB platformDB) {
|
||||
DataSourceContextHolder.clearDataSourceType();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user