optimize 框架组件的api尽量用本地实现类,提升执行效率
parent
77e082c17c
commit
0431201141
|
@ -1,5 +1,6 @@
|
||||||
package cn.iocoder.yudao.framework.tenant.config;
|
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.common.enums.WebFilterOrderEnum;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
|
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
|
||||||
import cn.iocoder.yudao.framework.redis.config.YudaoCacheProperties;
|
import cn.iocoder.yudao.framework.redis.config.YudaoCacheProperties;
|
||||||
|
@ -43,6 +44,13 @@ public class YudaoTenantAutoConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public TenantFrameworkService tenantFrameworkService(TenantApi tenantApi) {
|
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);
|
return new TenantFrameworkServiceImpl(tenantApi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package cn.iocoder.yudao.framework.dict.config;
|
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.framework.dict.core.DictFrameworkUtils;
|
||||||
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
|
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
|
@ -11,6 +12,13 @@ public class YudaoDictAutoConfiguration {
|
||||||
@Bean
|
@Bean
|
||||||
@SuppressWarnings("InstantiationOfUtilityClass")
|
@SuppressWarnings("InstantiationOfUtilityClass")
|
||||||
public DictFrameworkUtils dictUtils(DictDataApi dictDataApi) {
|
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);
|
DictFrameworkUtils.init(dictDataApi);
|
||||||
return new DictFrameworkUtils();
|
return new DictFrameworkUtils();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package cn.iocoder.yudao.framework.operatelog.config;
|
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.LogRecordServiceImpl;
|
||||||
|
import cn.iocoder.yudao.module.system.api.logger.OperateLogApi;
|
||||||
import com.mzt.logapi.service.ILogRecordService;
|
import com.mzt.logapi.service.ILogRecordService;
|
||||||
import com.mzt.logapi.starter.annotation.EnableLogRecord;
|
import com.mzt.logapi.starter.annotation.EnableLogRecord;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
@ -20,8 +22,15 @@ public class YudaoOperateLogConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Primary
|
@Primary
|
||||||
public ILogRecordService iLogRecordServiceImpl() {
|
public ILogRecordService iLogRecordServiceImpl(OperateLogApi operateLogApi) {
|
||||||
return new LogRecordServiceImpl();
|
// 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 cn.iocoder.yudao.module.system.api.logger.dto.OperateLogCreateReqDTO;
|
||||||
import com.mzt.logapi.beans.LogRecord;
|
import com.mzt.logapi.beans.LogRecord;
|
||||||
import com.mzt.logapi.service.ILogRecordService;
|
import com.mzt.logapi.service.ILogRecordService;
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -21,11 +21,11 @@ import java.util.List;
|
||||||
*
|
*
|
||||||
* @author HUIHUI
|
* @author HUIHUI
|
||||||
*/
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class LogRecordServiceImpl implements ILogRecordService {
|
public class LogRecordServiceImpl implements ILogRecordService {
|
||||||
|
|
||||||
@Resource
|
private final OperateLogApi operateLogApi;
|
||||||
private OperateLogApi operateLogApi;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void record(LogRecord logRecord) {
|
public void record(LogRecord logRecord) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package cn.iocoder.yudao.framework.apilog.config;
|
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.filter.ApiAccessLogFilter;
|
||||||
import cn.iocoder.yudao.framework.apilog.core.interceptor.ApiAccessLogInterceptor;
|
import cn.iocoder.yudao.framework.apilog.core.interceptor.ApiAccessLogInterceptor;
|
||||||
import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkService;
|
import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkService;
|
||||||
|
@ -26,12 +27,26 @@ public class YudaoApiLogAutoConfiguration implements WebMvcConfigurer {
|
||||||
@Bean
|
@Bean
|
||||||
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
|
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
|
||||||
public ApiAccessLogFrameworkService apiAccessLogFrameworkService(ApiAccessLogApi apiAccessLogApi) {
|
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);
|
return new ApiAccessLogFrameworkServiceImpl(apiAccessLogApi);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
|
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
|
||||||
public ApiErrorLogFrameworkService apiErrorLogFrameworkService(ApiErrorLogApi apiErrorLogApi) {
|
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);
|
return new ApiErrorLogFrameworkServiceImpl(apiErrorLogApi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue