fallback Api接口还是使用默认的接口实现

pull/130/head
1351515658@qq.com 2024-08-18 18:24:06 +08:00
parent bd706ecfd8
commit 464fd60637
6 changed files with 11 additions and 72 deletions

View File

@ -1,6 +1,5 @@
package cn.iocoder.yudao.framework.tenant.config;
import cn.hutool.extra.spring.SpringUtil;
import cn.iocoder.yudao.framework.common.enums.WebFilterOrderEnum;
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
import cn.iocoder.yudao.framework.redis.config.YudaoCacheProperties;
@ -44,13 +43,6 @@ public class YudaoTenantAutoConfiguration {
@Bean
public TenantFrameworkService tenantFrameworkService(TenantApi tenantApi) {
// Cloud 专属逻辑:优先使用本地的 tenantApi 实现类,而不是 Feign 调用
try {
TenantApi tenantApiImpl = SpringUtil.getBean("tenantApiImpl", TenantApi.class);
if (tenantApiImpl != null) {
tenantApi = tenantApiImpl;
}
} catch (Exception ignored) {}
return new TenantFrameworkServiceImpl(tenantApi);
}

View File

@ -1,6 +1,5 @@
package cn.iocoder.yudao.framework.dict.config;
import cn.hutool.extra.spring.SpringUtil;
import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils;
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
import org.springframework.boot.autoconfigure.AutoConfiguration;
@ -12,13 +11,6 @@ public class YudaoDictAutoConfiguration {
@Bean
@SuppressWarnings("InstantiationOfUtilityClass")
public DictFrameworkUtils dictUtils(DictDataApi dictDataApi) {
// Cloud 专属逻辑:优先使用本地的 dictDataApiImpl 实现类,而不是 Feign 调用
try {
DictDataApi apiImpl = SpringUtil.getBean("dictDataApiImpl", DictDataApi.class);
if (apiImpl != null) {
dictDataApi = apiImpl;
}
} catch (Exception ignored) {}
DictFrameworkUtils.init(dictDataApi);
return new DictFrameworkUtils();
}

View File

@ -25,11 +25,19 @@ import java.util.concurrent.TimeUnit;
*
* @author
*/
@AutoConfiguration(before = MybatisPlusAutoConfiguration.class) // 目的:先于 MyBatis Plus 自动配置,避免 @MapperScan 可能扫描不到 Mapper 打印 warn 日志
@AutoConfiguration(before = MybatisPlusAutoConfiguration.class)
// 目的:先于 MyBatis Plus 自动配置,避免 @MapperScan 可能扫描不到 Mapper 打印 warn 日志
@MapperScan(value = "${yudao.info.base-package}", annotationClass = Mapper.class,
lazyInitialization = "${mybatis.lazy-initialization:false}") // Mapper 懒加载,目前仅用于单元测试
public class YudaoMybatisAutoConfiguration {
static {
JsqlParserGlobal.setJsqlParseCache(new JdkSerialCaffeineJsqlParseCache(
(cache) -> cache.maximumSize(1024)
.expireAfterWrite(5, TimeUnit.SECONDS))
);
}
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
@ -38,7 +46,7 @@ public class YudaoMybatisAutoConfiguration {
}
@Bean
public MetaObjectHandler defaultMetaObjectHandler(){
public MetaObjectHandler defaultMetaObjectHandler() {
return new DefaultDBFieldHandler(); // 自动填充参数类
}
@ -65,10 +73,5 @@ public class YudaoMybatisAutoConfiguration {
throw new IllegalArgumentException(StrUtil.format("DbType{} 找不到合适的 IKeyGenerator 实现类", dbType));
}
static {
JsqlParserGlobal.setJsqlParseCache(new JdkSerialCaffeineJsqlParseCache(
(cache) -> cache.maximumSize(1024)
.expireAfterWrite(5, TimeUnit.SECONDS))
);
}
}

View File

@ -1,10 +1,6 @@
package cn.iocoder.yudao.framework.operatelog.config;
import cn.hutool.extra.spring.SpringUtil;
import cn.iocoder.yudao.framework.operatelog.core.service.LogRecordServiceImpl;
import cn.iocoder.yudao.framework.operatelog.core.service.OperateLogFrameworkService;
import cn.iocoder.yudao.framework.operatelog.core.service.OperateLogFrameworkServiceImpl;
import cn.iocoder.yudao.module.system.api.logger.OperateLogApi;
import com.mzt.logapi.service.ILogRecordService;
import com.mzt.logapi.starter.annotation.EnableLogRecord;
import lombok.extern.slf4j.Slf4j;
@ -28,16 +24,4 @@ public class YudaoOperateLogConfiguration {
return new LogRecordServiceImpl();
}
@Bean
public OperateLogFrameworkService operateLogFrameworkServiceImpl(OperateLogApi operateLogApi) {
// Cloud 专属逻辑:优先使用本地的 operateLogApi 实现类,而不是 Feign 调用
try {
OperateLogApi operateLogApiImpl = SpringUtil.getBean("operateLogApiImpl", OperateLogApi.class);
if (operateLogApiImpl != null) {
operateLogApi = operateLogApiImpl;
}
} catch (Exception ignored) {}
return new OperateLogFrameworkServiceImpl(operateLogApi);
}
}

View File

@ -1,6 +1,5 @@
package cn.iocoder.yudao.framework.security.config;
import cn.hutool.extra.spring.SpringUtil;
import cn.iocoder.yudao.framework.security.core.aop.PreAuthenticatedAspect;
import cn.iocoder.yudao.framework.security.core.context.TransmittableThreadLocalSecurityContextHolderStrategy;
import cn.iocoder.yudao.framework.security.core.filter.TokenAuthenticationFilter;
@ -80,27 +79,11 @@ public class YudaoSecurityAutoConfiguration {
@Bean
public TokenAuthenticationFilter authenticationTokenFilter(GlobalExceptionHandler globalExceptionHandler,
OAuth2TokenApi oauth2TokenApi) {
// Cloud 专属逻辑:优先使用本地的 oauth2TokenApi 实现类,而不是 Feign 调用
try {
OAuth2TokenApi oAuth2TokenApiImpl = SpringUtil.getBean("OAuth2TokenApiImpl", OAuth2TokenApi.class);
if (oAuth2TokenApiImpl != null) {
oauth2TokenApi = oAuth2TokenApiImpl;
}
} catch (Exception ignored) {
}
return new TokenAuthenticationFilter(securityProperties, globalExceptionHandler, oauth2TokenApi);
}
@Bean("ss") // 使用 Spring Security 的缩写,方便使用
public SecurityFrameworkService securityFrameworkService(PermissionApi permissionApi) {
// Cloud 专属逻辑:优先使用本地的 permissionApi 实现类,而不是 Feign 调用
try {
PermissionApi permissionApiImpl = SpringUtil.getBean("permissionApiImpl", PermissionApi.class);
if (permissionApiImpl != null) {
permissionApi = permissionApiImpl;
}
} catch (Exception ignored) {
}
return new SecurityFrameworkServiceImpl(permissionApi);
}

View File

@ -1,6 +1,5 @@
package cn.iocoder.yudao.framework.apilog.config;
import cn.hutool.extra.spring.SpringUtil;
import cn.iocoder.yudao.framework.apilog.core.filter.ApiAccessLogFilter;
import cn.iocoder.yudao.framework.apilog.core.interceptor.ApiAccessLogInterceptor;
import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkService;
@ -27,26 +26,12 @@ public class YudaoApiLogAutoConfiguration implements WebMvcConfigurer {
@Bean
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
public ApiAccessLogFrameworkService apiAccessLogFrameworkService(ApiAccessLogApi apiAccessLogApi) {
// Cloud 专属逻辑:优先使用本地的 apiAccessLogApiImpl 实现类,而不是 Feign 调用
try {
ApiAccessLogApi apiImpl = SpringUtil.getBean("apiAccessLogApiImpl", ApiAccessLogApi.class);
if (apiImpl != null) {
apiAccessLogApi = apiImpl;
}
} catch (Exception ignored) {}
return new ApiAccessLogFrameworkServiceImpl(apiAccessLogApi);
}
@Bean
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
public ApiErrorLogFrameworkService apiErrorLogFrameworkService(ApiErrorLogApi apiErrorLogApi) {
// Cloud 专属逻辑:优先使用本地的 apiErrorLogApiImpl 实现类,而不是 Feign 调用
try {
ApiErrorLogApi apiImpl = SpringUtil.getBean("apiErrorLogApiImpl", ApiErrorLogApi.class);
if (apiImpl != null) {
apiErrorLogApi = apiImpl;
}
} catch (Exception ignored) {}
return new ApiErrorLogFrameworkServiceImpl(apiErrorLogApi);
}