optimize 框架组件的api尽量用本地实现类,提升执行效率
parent
77e082c17c
commit
0431201141
|
@ -1,5 +1,6 @@
|
|||
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;
|
||||
|
@ -43,6 +44,13 @@ 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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;
|
||||
|
@ -11,6 +12,13 @@ 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();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
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.module.system.api.logger.OperateLogApi;
|
||||
import com.mzt.logapi.service.ILogRecordService;
|
||||
import com.mzt.logapi.starter.annotation.EnableLogRecord;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -20,8 +22,15 @@ public class YudaoOperateLogConfiguration {
|
|||
|
||||
@Bean
|
||||
@Primary
|
||||
public ILogRecordService iLogRecordServiceImpl() {
|
||||
return new LogRecordServiceImpl();
|
||||
public ILogRecordService iLogRecordServiceImpl(OperateLogApi operateLogApi) {
|
||||
// Cloud 专属逻辑:优先使用本地的 operateLogApi 实现类,而不是 Feign 调用
|
||||
try {
|
||||
OperateLogApi operateLogApiImpl = SpringUtil.getBean("operateLogApiImpl", OperateLogApi.class);
|
||||
if (operateLogApiImpl != null) {
|
||||
operateLogApi = operateLogApiImpl;
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
return new LogRecordServiceImpl(operateLogApi);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@ import cn.iocoder.yudao.module.system.api.logger.OperateLogApi;
|
|||
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogCreateReqDTO;
|
||||
import com.mzt.logapi.beans.LogRecord;
|
||||
import com.mzt.logapi.service.ILogRecordService;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -21,11 +21,11 @@ import java.util.List;
|
|||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class LogRecordServiceImpl implements ILogRecordService {
|
||||
|
||||
@Resource
|
||||
private OperateLogApi operateLogApi;
|
||||
private final OperateLogApi operateLogApi;
|
||||
|
||||
@Override
|
||||
public void record(LogRecord logRecord) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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;
|
||||
|
@ -26,12 +27,26 @@ 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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue