fix(data): 延迟初始化数据权限 Feign 客户端

This commit is contained in:
PIGCLOUD committed 2026-08-01 11:59:35 +08:00
1 parent d9130d4fbf
commit 41f20b2db3
1 file changed
+5 -1
@@ -42,6 +42,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Primary;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@@ -118,13 +119,16 @@ public class MybatisPlusConfiguration implements WebMvcConfigurer {
/**
* 数据权限拦截器
* <p>
* 远程数据权限客户端延迟到首次权限计算时解析,避免 MyBatis 在应用启动期创建
* Feign 子上下文,进而与 MVC、安全拦截器等业务扩展形成循环初始化。
*
* @return DataScopeInterceptor
*/
@Bean
@ConditionalOnMissingBean
@ConditionalOnBean(UserContextHolder.class)
public DataScopeInterceptor dataScopeInterceptor(RemoteDataScopeService dataScopeService,
public DataScopeInterceptor dataScopeInterceptor(@Lazy RemoteDataScopeService dataScopeService,
UserContextHolder userContextHolder) {
DataScopeInnerInterceptor dataScopeInnerInterceptor = new DataScopeInnerInterceptor();
dataScopeInnerInterceptor.setDataScopeHandle(new PigxDefaultDataScopeHandle(dataScopeService, userContextHolder));