From 77e082c17c3bcfc51b2e4cb60d3f940d5e66781a Mon Sep 17 00:00:00 2001
From: "1351515658@qq.com" <1351515658@qq.com>
Date: Mon, 29 Jul 2024 17:29:08 +0800
Subject: [PATCH 02/15] =?UTF-8?q?add=20=E9=85=8D=E7=BD=AE=E6=9C=AC?=
=?UTF-8?q?=E5=9C=B0=E7=BC=93=E5=AD=98SQL=E8=A7=A3=E6=9E=90=E7=BC=93?=
=?UTF-8?q?=E5=AD=98=EF=BC=8C=E6=8F=90=E5=8D=87=E6=89=A7=E8=A1=8Cmybatis?=
=?UTF-8?q?=E6=95=88=E7=8E=87?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../mybatis/config/YudaoMybatisAutoConfiguration.java | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java
index d685fd81a4..63600453ea 100644
--- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java
+++ b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java
@@ -7,6 +7,8 @@
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.baomidou.mybatisplus.core.incrementer.IKeyGenerator;
import com.baomidou.mybatisplus.extension.incrementer.*;
+import com.baomidou.mybatisplus.extension.parser.JsqlParserGlobal;
+import com.baomidou.mybatisplus.extension.parser.cache.JdkSerialCaffeineJsqlParseCache;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.apache.ibatis.annotations.Mapper;
@@ -16,6 +18,8 @@
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.ConfigurableEnvironment;
+import java.util.concurrent.TimeUnit;
+
/**
* MyBaits 配置类
*
@@ -61,4 +65,10 @@ public IKeyGenerator keyGenerator(ConfigurableEnvironment environment) {
throw new IllegalArgumentException(StrUtil.format("DbType{} 找不到合适的 IKeyGenerator 实现类", dbType));
}
+ static {
+ JsqlParserGlobal.setJsqlParseCache(new JdkSerialCaffeineJsqlParseCache(
+ (cache) -> cache.maximumSize(1024)
+ .expireAfterWrite(5, TimeUnit.SECONDS))
+ );
+ }
}
From 0431201141eb43cbb80a9640de0b5d1fe1f4e194 Mon Sep 17 00:00:00 2001
From: "1351515658@qq.com" <1351515658@qq.com>
Date: Tue, 30 Jul 2024 11:33:12 +0800
Subject: [PATCH 03/15] =?UTF-8?q?optimize=20=20=E6=A1=86=E6=9E=B6=E7=BB=84?=
=?UTF-8?q?=E4=BB=B6=E7=9A=84api=E5=B0=BD=E9=87=8F=E7=94=A8=E6=9C=AC?=
=?UTF-8?q?=E5=9C=B0=E5=AE=9E=E7=8E=B0=E7=B1=BB=EF=BC=8C=E6=8F=90=E5=8D=87?=
=?UTF-8?q?=E6=89=A7=E8=A1=8C=E6=95=88=E7=8E=87?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../config/YudaoTenantAutoConfiguration.java | 8 ++++++++
.../dict/config/YudaoDictAutoConfiguration.java | 8 ++++++++
.../config/YudaoOperateLogConfiguration.java | 13 +++++++++++--
.../core/service/LogRecordServiceImpl.java | 6 +++---
.../config/YudaoApiLogAutoConfiguration.java | 15 +++++++++++++++
5 files changed, 45 insertions(+), 5 deletions(-)
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java
index cd3b3659e4..8b46784092 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java
+++ b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java
@@ -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);
}
diff --git a/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/dict/config/YudaoDictAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/dict/config/YudaoDictAutoConfiguration.java
index 8a6075efff..b4af27e08d 100644
--- a/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/dict/config/YudaoDictAutoConfiguration.java
+++ b/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/dict/config/YudaoDictAutoConfiguration.java
@@ -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();
}
diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/config/YudaoOperateLogConfiguration.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/config/YudaoOperateLogConfiguration.java
index eda6a14843..e262c85665 100644
--- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/config/YudaoOperateLogConfiguration.java
+++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/config/YudaoOperateLogConfiguration.java
@@ -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);
}
}
diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/LogRecordServiceImpl.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/LogRecordServiceImpl.java
index d6aeb3bf0e..e782e15446 100644
--- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/LogRecordServiceImpl.java
+++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/LogRecordServiceImpl.java
@@ -8,8 +8,8 @@
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 @@
*
* @author HUIHUI
*/
+@RequiredArgsConstructor
@Slf4j
public class LogRecordServiceImpl implements ILogRecordService {
- @Resource
- private OperateLogApi operateLogApi;
+ private final OperateLogApi operateLogApi;
@Override
public void record(LogRecord logRecord) {
diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/config/YudaoApiLogAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/config/YudaoApiLogAutoConfiguration.java
index d1f7453b6c..3caeb12e50 100644
--- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/config/YudaoApiLogAutoConfiguration.java
+++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/config/YudaoApiLogAutoConfiguration.java
@@ -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);
}
From f8a8538b04409a719b55d84960e7da80f06c663c Mon Sep 17 00:00:00 2001
From: "1351515658@qq.com" <1351515658@qq.com>
Date: Tue, 30 Jul 2024 18:01:03 +0800
Subject: [PATCH 04/15] =?UTF-8?q?optimize=20=E6=93=8D=E4=BD=9C=E6=97=A5?=
=?UTF-8?q?=E5=BF=97=E7=BB=84=E4=BB=B6=E5=BC=82=E6=AD=A5=E5=86=99=E5=85=A5?=
=?UTF-8?q?=E6=97=A5=E5=BF=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../config/YudaoOperateLogConfiguration.java | 11 +++++--
.../core/service/LogRecordServiceImpl.java | 11 +++----
.../service/OperateLogFrameworkService.java | 19 +++++++++++
.../OperateLogFrameworkServiceImpl.java | 33 +++++++++++++++++++
4 files changed, 66 insertions(+), 8 deletions(-)
create mode 100644 yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLogFrameworkService.java
create mode 100644 yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLogFrameworkServiceImpl.java
diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/config/YudaoOperateLogConfiguration.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/config/YudaoOperateLogConfiguration.java
index e262c85665..3173263ff4 100644
--- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/config/YudaoOperateLogConfiguration.java
+++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/config/YudaoOperateLogConfiguration.java
@@ -2,6 +2,8 @@
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;
@@ -22,7 +24,12 @@ public class YudaoOperateLogConfiguration {
@Bean
@Primary
- public ILogRecordService iLogRecordServiceImpl(OperateLogApi operateLogApi) {
+ public ILogRecordService iLogRecordServiceImpl() {
+ return new LogRecordServiceImpl();
+ }
+
+ @Bean
+ public OperateLogFrameworkService operateLogFrameworkServiceImpl(OperateLogApi operateLogApi) {
// Cloud 专属逻辑:优先使用本地的 operateLogApi 实现类,而不是 Feign 调用
try {
OperateLogApi operateLogApiImpl = SpringUtil.getBean("operateLogApiImpl", OperateLogApi.class);
@@ -30,7 +37,7 @@ public ILogRecordService iLogRecordServiceImpl(OperateLogApi operateLogApi) {
operateLogApi = operateLogApiImpl;
}
} catch (Exception ignored) {}
- return new LogRecordServiceImpl(operateLogApi);
+ return new OperateLogFrameworkServiceImpl(operateLogApi);
}
}
diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/LogRecordServiceImpl.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/LogRecordServiceImpl.java
index e782e15446..fea853e7c7 100644
--- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/LogRecordServiceImpl.java
+++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/LogRecordServiceImpl.java
@@ -4,12 +4,11 @@
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
-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;
@@ -17,15 +16,15 @@
/**
* 操作日志 ILogRecordService 实现类
*
- * 基于 {@link OperateLogApi} 实现,记录操作日志
+ * 基于 {@link OperateLogFrameworkService}实现, 记录操作日志
*
* @author HUIHUI
*/
-@RequiredArgsConstructor
@Slf4j
public class LogRecordServiceImpl implements ILogRecordService {
- private final OperateLogApi operateLogApi;
+ @Resource
+ OperateLogFrameworkService operateLogFrameworkService;
@Override
public void record(LogRecord logRecord) {
@@ -40,7 +39,7 @@ public void record(LogRecord logRecord) {
fillRequestFields(reqDTO);
// 2. 异步记录日志
- operateLogApi.createOperateLog(reqDTO);
+ operateLogFrameworkService.createOperateLog(reqDTO);
}
private static void fillUserFields(OperateLogCreateReqDTO reqDTO) {
diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLogFrameworkService.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLogFrameworkService.java
new file mode 100644
index 0000000000..cf2cf5b005
--- /dev/null
+++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLogFrameworkService.java
@@ -0,0 +1,19 @@
+package cn.iocoder.yudao.framework.operatelog.core.service;
+
+import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogCreateReqDTO;
+
+/**
+ * API 操作日志 Framework Service 接口
+ *
+ * @author 陈晨成
+ */
+public interface OperateLogFrameworkService {
+
+ /**
+ * 创建 操作日志
+ *
+ * @param reqDTO API 操作日志
+ */
+ void createOperateLog(OperateLogCreateReqDTO reqDTO);
+
+}
diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLogFrameworkServiceImpl.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLogFrameworkServiceImpl.java
new file mode 100644
index 0000000000..aa97689ac6
--- /dev/null
+++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLogFrameworkServiceImpl.java
@@ -0,0 +1,33 @@
+package cn.iocoder.yudao.framework.operatelog.core.service;
+
+import cn.iocoder.yudao.module.system.api.logger.OperateLogApi;
+import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogCreateReqDTO;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.scheduling.annotation.Async;
+
+/**
+ * API 操作日志 Framework Service 实现类
+ *
+ * 基于 {@link OperateLogApi} 服务,记录操作日志
+ *
+ * @author 陈晨成
+ */
+@RequiredArgsConstructor
+@Slf4j
+public class OperateLogFrameworkServiceImpl implements OperateLogFrameworkService {
+
+ private final OperateLogApi operateLogApi;
+
+ @Override
+ @Async
+ public void createOperateLog(OperateLogCreateReqDTO reqDTO) {
+ try {
+ operateLogApi.createOperateLog(reqDTO);
+ } catch (Throwable ex) {
+ // 由于 @Async 异步调用,这里打印下日志,更容易跟进
+ log.error("[createOperateLog][url({}) log({}) 发生异常]", reqDTO.getRequestUrl(), reqDTO, ex);
+ }
+ }
+
+}
From 9194e094e6297de7746f03dddc9199e4163c079c Mon Sep 17 00:00:00 2001
From: "1351515658@qq.com" <1351515658@qq.com>
Date: Tue, 30 Jul 2024 18:01:57 +0800
Subject: [PATCH 05/15] =?UTF-8?q?fix=20api=E8=AE=BF=E9=97=AE/=E5=BC=82?=
=?UTF-8?q?=E5=B8=B8=E6=97=A5=E5=BF=97=E5=92=8C=E6=93=8D=E4=BD=9C=E6=97=A5?=
=?UTF-8?q?=E5=BF=97=E5=86=99=E5=85=A5=E6=95=B0=E6=8D=AE=E8=A1=A8=EF=BC=8C?=
=?UTF-8?q?=E5=88=9B=E5=BB=BA=E4=BA=BA=E5=92=8C=E4=BF=AE=E6=94=B9=E4=BA=BA?=
=?UTF-8?q?=E7=9A=84=E4=BF=A1=E6=81=AF=E4=B8=BA=E7=A9=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../module/infra/service/logger/ApiAccessLogServiceImpl.java | 5 +++++
.../module/infra/service/logger/ApiErrorLogServiceImpl.java | 5 +++++
.../module/system/service/logger/OperateLogServiceImpl.java | 5 +++++
3 files changed, 15 insertions(+)
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImpl.java
index 9483e8f738..f2fc714b28 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImpl.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImpl.java
@@ -37,6 +37,11 @@ public void createApiAccessLog(ApiAccessLogCreateReqDTO createDTO) {
ApiAccessLogDO apiAccessLog = BeanUtils.toBean(createDTO, ApiAccessLogDO.class);
apiAccessLog.setRequestParams(StrUtil.maxLength(apiAccessLog.getRequestParams(), REQUEST_PARAMS_MAX_LENGTH));
apiAccessLog.setResultMsg(StrUtil.maxLength(apiAccessLog.getResultMsg(), RESULT_MSG_MAX_LENGTH));
+ if(apiAccessLog.getUserId() != null){
+ String userIdStr = apiAccessLog.getUserId().toString();
+ apiAccessLog.setCreator(userIdStr);
+ apiAccessLog.setUpdater(userIdStr);
+ }
if (TenantContextHolder.getTenantId() != null) {
apiAccessLogMapper.insert(apiAccessLog);
} else {
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImpl.java
index 747b220b5c..0e117b50e5 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImpl.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImpl.java
@@ -40,6 +40,11 @@ public void createApiErrorLog(ApiErrorLogCreateReqDTO createDTO) {
ApiErrorLogDO apiErrorLog = BeanUtils.toBean(createDTO, ApiErrorLogDO.class)
.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus());
apiErrorLog.setRequestParams(StrUtil.maxLength(apiErrorLog.getRequestParams(), REQUEST_PARAMS_MAX_LENGTH));
+ if(apiErrorLog.getUserId() != null){
+ String userIdStr = apiErrorLog.getUserId().toString();
+ apiErrorLog.setCreator(userIdStr);
+ apiErrorLog.setUpdater(userIdStr);
+ }
if (TenantContextHolder.getTenantId() != null) {
apiErrorLogMapper.insert(apiErrorLog);
} else {
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImpl.java
index 6c341d5a11..60067cf135 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImpl.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImpl.java
@@ -28,6 +28,11 @@ public class OperateLogServiceImpl implements OperateLogService {
@Override
public void createOperateLog(OperateLogCreateReqDTO createReqDTO) {
OperateLogDO log = BeanUtils.toBean(createReqDTO, OperateLogDO.class);
+ if(log.getUserId() != null){
+ String userIdStr = log.getUserId().toString();
+ log.setCreator(userIdStr);
+ log.setUpdater(userIdStr);
+ }
operateLogMapper.insert(log);
}
From 99bef36c9038cc410929b51e7f28961ce080f208 Mon Sep 17 00:00:00 2001
From: "1351515658@qq.com" <1351515658@qq.com>
Date: Wed, 31 Jul 2024 11:35:07 +0800
Subject: [PATCH 06/15] =?UTF-8?q?optimize=20HTTP=E6=8E=A5=E5=8F=A3?=
=?UTF-8?q?=E7=AD=BE=E5=90=8D=E5=8A=9F=E8=83=BD=20=E9=98=B2=E9=87=8D?=
=?UTF-8?q?=E6=94=BE=E6=94=BB=E5=87=BB=E4=BB=8Enonce=20->=20appId+nonce?=
=?UTF-8?q?=E7=BB=B4=E5=BA=A6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../signature/core/aop/ApiSignatureAspect.java | 4 ++--
.../signature/core/redis/ApiSignatureRedisDAO.java | 14 +++++++-------
.../framework/signature/core/ApiSignatureTest.java | 2 +-
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/signature/core/aop/ApiSignatureAspect.java b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/signature/core/aop/ApiSignatureAspect.java
index 3259dac116..0af3adba22 100644
--- a/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/signature/core/aop/ApiSignatureAspect.java
+++ b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/signature/core/aop/ApiSignatureAspect.java
@@ -69,7 +69,7 @@ public boolean verifySignature(ApiSignature signature, HttpServletRequest reques
// 3. 将 nonce 记入缓存,防止重复使用(重点二:此处需要将 ttl 设定为允许 timestamp 时间差的值 x 2 )
String nonce = request.getHeader(signature.nonce());
- signatureRedisDAO.setNonce(nonce, signature.timeout() * 2, signature.timeUnit());
+ signatureRedisDAO.setNonce(appId, nonce, signature.timeout() * 2, signature.timeUnit());
return true;
}
@@ -113,7 +113,7 @@ private boolean verifyHeaders(ApiSignature signature, HttpServletRequest request
}
// 3. 检查 nonce 是否存在,有且仅能使用一次
- return signatureRedisDAO.getNonce(nonce) == null;
+ return signatureRedisDAO.getNonce(appId, nonce) == null;
}
/**
diff --git a/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/signature/core/redis/ApiSignatureRedisDAO.java b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/signature/core/redis/ApiSignatureRedisDAO.java
index f4aa84910d..11fe384dac 100644
--- a/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/signature/core/redis/ApiSignatureRedisDAO.java
+++ b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/signature/core/redis/ApiSignatureRedisDAO.java
@@ -22,7 +22,7 @@ public class ApiSignatureRedisDAO {
* VALUE 格式:String
* 过期时间:不固定
*/
- private static final String SIGNATURE_NONCE = "api_signature_nonce:%s";
+ private static final String SIGNATURE_NONCE = "api_signature_nonce:%s:%s";
/**
* 签名密钥
@@ -36,16 +36,16 @@ public class ApiSignatureRedisDAO {
// ========== 验签随机数 ==========
- public String getNonce(String nonce) {
- return stringRedisTemplate.opsForValue().get(formatNonceKey(nonce));
+ public String getNonce(String appId, String nonce) {
+ return stringRedisTemplate.opsForValue().get(formatNonceKey(appId, nonce));
}
- public void setNonce(String nonce, int time, TimeUnit timeUnit) {
- stringRedisTemplate.opsForValue().set(formatNonceKey(nonce), "", time, timeUnit);
+ public void setNonce(String appId, String nonce, int time, TimeUnit timeUnit) {
+ stringRedisTemplate.opsForValue().set(formatNonceKey(appId, nonce), "", time, timeUnit);
}
- private static String formatNonceKey(String key) {
- return String.format(SIGNATURE_NONCE, key);
+ private static String formatNonceKey(String appId, String nonce) {
+ return String.format(SIGNATURE_NONCE, appId, nonce);
}
// ========== 签名密钥 ==========
diff --git a/yudao-framework/yudao-spring-boot-starter-protection/src/test/java/cn/iocoder/yudao/framework/signature/core/ApiSignatureTest.java b/yudao-framework/yudao-spring-boot-starter-protection/src/test/java/cn/iocoder/yudao/framework/signature/core/ApiSignatureTest.java
index c9a3dfff40..481fb5d016 100644
--- a/yudao-framework/yudao-spring-boot-starter-protection/src/test/java/cn/iocoder/yudao/framework/signature/core/ApiSignatureTest.java
+++ b/yudao-framework/yudao-spring-boot-starter-protection/src/test/java/cn/iocoder/yudao/framework/signature/core/ApiSignatureTest.java
@@ -69,7 +69,7 @@ public void testSignatureGet() throws IOException {
// 断言结果
assertTrue(result);
// 断言调用
- verify(signatureRedisDAO).setNonce(eq(nonce), eq(120), eq(TimeUnit.SECONDS));
+ verify(signatureRedisDAO).setNonce(eq(appId),eq(nonce), eq(120), eq(TimeUnit.SECONDS));
}
}
From bd706ecfd8ad0112d3bd95f8d4b2c4c0116ca542 Mon Sep 17 00:00:00 2001
From: "1351515658@qq.com" <1351515658@qq.com>
Date: Thu, 8 Aug 2024 15:42:43 +0800
Subject: [PATCH 07/15] =?UTF-8?q?optimize=20oauth2TokenApi\permissionApi?=
=?UTF-8?q?=E5=B0=BD=E9=87=8F=E7=94=A8=E6=9C=AC=E5=9C=B0=E5=AE=9E=E7=8E=B0?=
=?UTF-8?q?=E7=B1=BB=EF=BC=8C=E6=8F=90=E5=8D=87=E6=89=A7=E8=A1=8C=E6=95=88?=
=?UTF-8?q?=E7=8E=87?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../YudaoSecurityAutoConfiguration.java | 22 ++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoSecurityAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoSecurityAutoConfiguration.java
index a249991765..c3d44a278b 100644
--- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoSecurityAutoConfiguration.java
+++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoSecurityAutoConfiguration.java
@@ -1,5 +1,6 @@
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;
@@ -10,6 +11,7 @@
import cn.iocoder.yudao.framework.web.core.handler.GlobalExceptionHandler;
import cn.iocoder.yudao.module.system.api.oauth2.OAuth2TokenApi;
import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
+import jakarta.annotation.Resource;
import org.springframework.beans.factory.config.MethodInvokingFactoryBean;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
@@ -21,11 +23,9 @@
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.security.web.access.AccessDeniedHandler;
-import jakarta.annotation.Resource;
-
/**
* Spring Security 自动配置类,主要用于相关组件的配置
- *
+ *
* 注意,不能和 {@link YudaoWebSecurityConfigurerAdapter} 用一个,原因是会导致初始化报错。
* 参见 https://stackoverflow.com/questions/53847050/spring-boot-delegatebuilder-cannot-be-null-on-autowiring-authenticationmanager 文档。
*
@@ -80,11 +80,27 @@ public PasswordEncoder passwordEncoder() {
@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);
}
From 464fd606370e04f45f5ea967b7f725fd500c859a Mon Sep 17 00:00:00 2001
From: "1351515658@qq.com" <1351515658@qq.com>
Date: Sun, 18 Aug 2024 18:24:06 +0800
Subject: [PATCH 08/15] =?UTF-8?q?fallback=20Api=E6=8E=A5=E5=8F=A3=E8=BF=98?=
=?UTF-8?q?=E6=98=AF=E4=BD=BF=E7=94=A8=E9=BB=98=E8=AE=A4=E7=9A=84=E6=8E=A5?=
=?UTF-8?q?=E5=8F=A3=E5=AE=9E=E7=8E=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../config/YudaoTenantAutoConfiguration.java | 8 --------
.../config/YudaoDictAutoConfiguration.java | 8 --------
.../config/YudaoMybatisAutoConfiguration.java | 19 +++++++++++--------
.../config/YudaoOperateLogConfiguration.java | 16 ----------------
.../YudaoSecurityAutoConfiguration.java | 17 -----------------
.../config/YudaoApiLogAutoConfiguration.java | 15 ---------------
6 files changed, 11 insertions(+), 72 deletions(-)
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java
index 8b46784092..cd3b3659e4 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java
+++ b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java
@@ -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);
}
diff --git a/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/dict/config/YudaoDictAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/dict/config/YudaoDictAutoConfiguration.java
index b4af27e08d..8a6075efff 100644
--- a/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/dict/config/YudaoDictAutoConfiguration.java
+++ b/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/dict/config/YudaoDictAutoConfiguration.java
@@ -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();
}
diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java
index 63600453ea..b4faa4645a 100644
--- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java
+++ b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java
@@ -25,11 +25,19 @@
*
* @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 MybatisPlusInterceptor mybatisPlusInterceptor() {
}
@Bean
- public MetaObjectHandler defaultMetaObjectHandler(){
+ public MetaObjectHandler defaultMetaObjectHandler() {
return new DefaultDBFieldHandler(); // 自动填充参数类
}
@@ -65,10 +73,5 @@ public IKeyGenerator keyGenerator(ConfigurableEnvironment environment) {
throw new IllegalArgumentException(StrUtil.format("DbType{} 找不到合适的 IKeyGenerator 实现类", dbType));
}
- static {
- JsqlParserGlobal.setJsqlParseCache(new JdkSerialCaffeineJsqlParseCache(
- (cache) -> cache.maximumSize(1024)
- .expireAfterWrite(5, TimeUnit.SECONDS))
- );
- }
+
}
diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/config/YudaoOperateLogConfiguration.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/config/YudaoOperateLogConfiguration.java
index 3173263ff4..eda6a14843 100644
--- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/config/YudaoOperateLogConfiguration.java
+++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/config/YudaoOperateLogConfiguration.java
@@ -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 ILogRecordService iLogRecordServiceImpl() {
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);
- }
-
}
diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoSecurityAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoSecurityAutoConfiguration.java
index c3d44a278b..a94fb878e7 100644
--- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoSecurityAutoConfiguration.java
+++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoSecurityAutoConfiguration.java
@@ -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 PasswordEncoder passwordEncoder() {
@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);
}
diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/config/YudaoApiLogAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/config/YudaoApiLogAutoConfiguration.java
index 3caeb12e50..d1f7453b6c 100644
--- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/config/YudaoApiLogAutoConfiguration.java
+++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/config/YudaoApiLogAutoConfiguration.java
@@ -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);
}
From 131fe3a69fec2171d0aa1cda83101d4129cd1155 Mon Sep 17 00:00:00 2001
From: "1351515658@qq.com" <1351515658@qq.com>
Date: Sun, 18 Aug 2024 18:24:59 +0800
Subject: [PATCH 09/15] =?UTF-8?q?fallback=20=E5=AE=B9=E5=99=A8=E4=BD=BF?=
=?UTF-8?q?=E7=94=A8=E9=BB=98=E8=AE=A4=E7=9A=84tomcat?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../yudao-spring-boot-starter-web/pom.xml | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/yudao-framework/yudao-spring-boot-starter-web/pom.xml b/yudao-framework/yudao-spring-boot-starter-web/pom.xml
index 0b2a9f4ede..56c28d5a77 100644
--- a/yudao-framework/yudao-spring-boot-starter-web/pom.xml
+++ b/yudao-framework/yudao-spring-boot-starter-web/pom.xml
@@ -32,18 +32,6 @@
org.springframework.boot
spring-boot-starter-web
-
-
- org.springframework.boot
- spring-boot-starter-tomcat
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-starter-undertow
From be38af728b1b6ff9c0fde6fa22f9b6a17e1bf9c3 Mon Sep 17 00:00:00 2001
From: "1351515658@qq.com" <1351515658@qq.com>
Date: Sun, 18 Aug 2024 18:25:37 +0800
Subject: [PATCH 10/15] =?UTF-8?q?add=20ApiSignatureTest=E4=BB=A3=E7=A0=81?=
=?UTF-8?q?=E8=A7=84=E8=8C=83=E6=95=B4=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../yudao/framework/signature/core/ApiSignatureTest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/yudao-framework/yudao-spring-boot-starter-protection/src/test/java/cn/iocoder/yudao/framework/signature/core/ApiSignatureTest.java b/yudao-framework/yudao-spring-boot-starter-protection/src/test/java/cn/iocoder/yudao/framework/signature/core/ApiSignatureTest.java
index 481fb5d016..2b467c51d9 100644
--- a/yudao-framework/yudao-spring-boot-starter-protection/src/test/java/cn/iocoder/yudao/framework/signature/core/ApiSignatureTest.java
+++ b/yudao-framework/yudao-spring-boot-starter-protection/src/test/java/cn/iocoder/yudao/framework/signature/core/ApiSignatureTest.java
@@ -69,7 +69,7 @@ public void testSignatureGet() throws IOException {
// 断言结果
assertTrue(result);
// 断言调用
- verify(signatureRedisDAO).setNonce(eq(appId),eq(nonce), eq(120), eq(TimeUnit.SECONDS));
+ verify(signatureRedisDAO).setNonce(eq(appId), eq(nonce), eq(120), eq(TimeUnit.SECONDS));
}
}
From 00ba2d6da957233de986680cc98ae9c43b71f6bf Mon Sep 17 00:00:00 2001
From: "1351515658@qq.com" <1351515658@qq.com>
Date: Sun, 18 Aug 2024 18:42:50 +0800
Subject: [PATCH 11/15] =?UTF-8?q?add=20=E5=A1=AB=E5=85=85=E6=97=A5?=
=?UTF-8?q?=E5=BF=97=E7=9A=84=E5=88=9B=E5=BB=BA=E4=BA=BA=E5=92=8C=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9=E4=BA=BA=20=E4=BB=A3=E7=A0=81=E8=A7=84=E8=8C=83?=
=?UTF-8?q?=E6=95=B4=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../module/infra/service/logger/ApiAccessLogServiceImpl.java | 2 +-
.../module/infra/service/logger/ApiErrorLogServiceImpl.java | 2 +-
.../module/system/service/logger/OperateLogServiceImpl.java | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImpl.java
index f2fc714b28..8c8055463a 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImpl.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImpl.java
@@ -37,7 +37,7 @@ public void createApiAccessLog(ApiAccessLogCreateReqDTO createDTO) {
ApiAccessLogDO apiAccessLog = BeanUtils.toBean(createDTO, ApiAccessLogDO.class);
apiAccessLog.setRequestParams(StrUtil.maxLength(apiAccessLog.getRequestParams(), REQUEST_PARAMS_MAX_LENGTH));
apiAccessLog.setResultMsg(StrUtil.maxLength(apiAccessLog.getResultMsg(), RESULT_MSG_MAX_LENGTH));
- if(apiAccessLog.getUserId() != null){
+ if (apiAccessLog.getUserId() != null) {
String userIdStr = apiAccessLog.getUserId().toString();
apiAccessLog.setCreator(userIdStr);
apiAccessLog.setUpdater(userIdStr);
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImpl.java
index 0e117b50e5..03566d44ac 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImpl.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImpl.java
@@ -40,7 +40,7 @@ public void createApiErrorLog(ApiErrorLogCreateReqDTO createDTO) {
ApiErrorLogDO apiErrorLog = BeanUtils.toBean(createDTO, ApiErrorLogDO.class)
.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus());
apiErrorLog.setRequestParams(StrUtil.maxLength(apiErrorLog.getRequestParams(), REQUEST_PARAMS_MAX_LENGTH));
- if(apiErrorLog.getUserId() != null){
+ if (apiErrorLog.getUserId() != null) {
String userIdStr = apiErrorLog.getUserId().toString();
apiErrorLog.setCreator(userIdStr);
apiErrorLog.setUpdater(userIdStr);
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImpl.java
index 60067cf135..26b7094fff 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImpl.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImpl.java
@@ -28,7 +28,7 @@ public class OperateLogServiceImpl implements OperateLogService {
@Override
public void createOperateLog(OperateLogCreateReqDTO createReqDTO) {
OperateLogDO log = BeanUtils.toBean(createReqDTO, OperateLogDO.class);
- if(log.getUserId() != null){
+ if (log.getUserId() != null) {
String userIdStr = log.getUserId().toString();
log.setCreator(userIdStr);
log.setUpdater(userIdStr);
From b63886ad6c0045f6cb7300d01c379a7f55420938 Mon Sep 17 00:00:00 2001
From: "1351515658@qq.com" <1351515658@qq.com>
Date: Sat, 24 Aug 2024 11:48:24 +0800
Subject: [PATCH 12/15] =?UTF-8?q?revert=20=E6=93=8D=E4=BD=9C=E6=97=A5?=
=?UTF-8?q?=E5=BF=97=E3=80=81=E8=AE=BF=E9=97=AE=E6=97=A5=E5=BF=97=E3=80=81?=
=?UTF-8?q?=E9=94=99=E8=AF=AF=E6=97=A5=E5=BF=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../module/infra/service/logger/ApiAccessLogServiceImpl.java | 5 -----
.../module/infra/service/logger/ApiErrorLogServiceImpl.java | 5 -----
.../module/system/service/logger/OperateLogServiceImpl.java | 5 -----
3 files changed, 15 deletions(-)
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImpl.java
index 8c8055463a..9483e8f738 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImpl.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImpl.java
@@ -37,11 +37,6 @@ public void createApiAccessLog(ApiAccessLogCreateReqDTO createDTO) {
ApiAccessLogDO apiAccessLog = BeanUtils.toBean(createDTO, ApiAccessLogDO.class);
apiAccessLog.setRequestParams(StrUtil.maxLength(apiAccessLog.getRequestParams(), REQUEST_PARAMS_MAX_LENGTH));
apiAccessLog.setResultMsg(StrUtil.maxLength(apiAccessLog.getResultMsg(), RESULT_MSG_MAX_LENGTH));
- if (apiAccessLog.getUserId() != null) {
- String userIdStr = apiAccessLog.getUserId().toString();
- apiAccessLog.setCreator(userIdStr);
- apiAccessLog.setUpdater(userIdStr);
- }
if (TenantContextHolder.getTenantId() != null) {
apiAccessLogMapper.insert(apiAccessLog);
} else {
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImpl.java
index 03566d44ac..747b220b5c 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImpl.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImpl.java
@@ -40,11 +40,6 @@ public void createApiErrorLog(ApiErrorLogCreateReqDTO createDTO) {
ApiErrorLogDO apiErrorLog = BeanUtils.toBean(createDTO, ApiErrorLogDO.class)
.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus());
apiErrorLog.setRequestParams(StrUtil.maxLength(apiErrorLog.getRequestParams(), REQUEST_PARAMS_MAX_LENGTH));
- if (apiErrorLog.getUserId() != null) {
- String userIdStr = apiErrorLog.getUserId().toString();
- apiErrorLog.setCreator(userIdStr);
- apiErrorLog.setUpdater(userIdStr);
- }
if (TenantContextHolder.getTenantId() != null) {
apiErrorLogMapper.insert(apiErrorLog);
} else {
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImpl.java
index 26b7094fff..6c341d5a11 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImpl.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImpl.java
@@ -28,11 +28,6 @@ public class OperateLogServiceImpl implements OperateLogService {
@Override
public void createOperateLog(OperateLogCreateReqDTO createReqDTO) {
OperateLogDO log = BeanUtils.toBean(createReqDTO, OperateLogDO.class);
- if (log.getUserId() != null) {
- String userIdStr = log.getUserId().toString();
- log.setCreator(userIdStr);
- log.setUpdater(userIdStr);
- }
operateLogMapper.insert(log);
}
From f1412c032c7874621a189cd0da6490b075fe4d1c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=BB=8A=E6=99=9A=E6=89=93=E8=80=81=E8=99=8E?=
Date: Mon, 26 Aug 2024 07:29:14 +0000
Subject: [PATCH 13/15] =?UTF-8?q?=E3=80=90=E5=B7=A5=E4=BD=9C=E6=B5=81?=
=?UTF-8?q?=E3=80=91=EF=BC=9A=E6=B5=81=E7=A8=8B=E6=A8=A1=E5=9E=8B=E5=88=86?=
=?UTF-8?q?=E9=A1=B5=E6=95=B0=E9=87=8F=E6=9F=A5=E8=AF=A2=E4=B8=8D=E6=AD=A3?=
=?UTF-8?q?=E7=A1=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: 今晚打老虎
---
.../module/bpm/service/definition/BpmModelServiceImpl.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java
index 7c4dae618e..3770e7ca70 100644
--- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java
@@ -63,6 +63,7 @@ public class BpmModelServiceImpl implements BpmModelService {
@Override
public PageResult getModelPage(BpmModelPageReqVO pageVO) {
ModelQuery modelQuery = repositoryService.createModelQuery();
+ modelQuery.modelTenantId(FlowableUtils.getTenantId());
if (StrUtil.isNotBlank(pageVO.getKey())) {
modelQuery.modelKey(pageVO.getKey());
}
@@ -78,7 +79,6 @@ public PageResult getModelPage(BpmModelPageReqVO pageVO) {
return PageResult.empty(count);
}
List models = modelQuery
- .modelTenantId(FlowableUtils.getTenantId())
.orderByCreateTime().desc()
.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize());
return new PageResult<>(models, count);
From d39681e98c9b6a082b1982781ce85ca4fd3d4191 Mon Sep 17 00:00:00 2001
From: YunaiV
Date: Sat, 31 Aug 2024 10:15:04 +0800
Subject: [PATCH 14/15] =?UTF-8?q?=E3=80=90=E4=BB=A3=E7=A0=81=E4=BF=AE?=
=?UTF-8?q?=E5=A4=8D=E3=80=91SYSTEM=EF=BC=9A=E8=A7=92=E8=89=B2=E6=A0=87?=
=?UTF-8?q?=E8=AF=86=E7=9A=84=E6=8F=90=E7=A4=BA=E4=B8=8D=E6=AD=A3=E7=A1=AE?=
=?UTF-8?q?=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../yudao/module/system/enums/DictTypeConstants.java | 2 --
.../module/system/service/permission/RoleServiceImpl.java | 3 ++-
.../system/service/permission/RoleServiceImplTest.java | 7 ++++---
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/DictTypeConstants.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/DictTypeConstants.java
index e91aea886f..d7592c34c9 100644
--- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/DictTypeConstants.java
+++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/DictTypeConstants.java
@@ -18,8 +18,6 @@ public interface DictTypeConstants {
String LOGIN_TYPE = "system_login_type"; // 登录日志的类型
String LOGIN_RESULT = "system_login_result"; // 登录结果
- String ERROR_CODE_TYPE = "system_error_code_type"; // 错误码的类型枚举
-
String SMS_CHANNEL_CODE = "system_sms_channel_code"; // 短信渠道编码
String SMS_TEMPLATE_TYPE = "system_sms_template_type"; // 短信模板类型
String SMS_SEND_STATUS = "system_sms_send_status"; // 短信发送状态
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImpl.java
index 35db067069..53d6b7e72e 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImpl.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImpl.java
@@ -2,6 +2,7 @@
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.extra.spring.SpringUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
@@ -61,7 +62,7 @@ public Long createRole(RoleSaveReqVO createReqVO, Integer type) {
// 2. 插入到数据库
RoleDO role = BeanUtils.toBean(createReqVO, RoleDO.class)
.setType(ObjectUtil.defaultIfNull(type, RoleTypeEnum.CUSTOM.getType()))
- .setStatus(CommonStatusEnum.ENABLE.getStatus())
+ .setStatus(ObjUtil.defaultIfNull(createReqVO.getStatus(), CommonStatusEnum.ENABLE.getStatus()))
.setDataScope(DataScopeEnum.ALL.getScope()); // 默认可查看所有数据。原因是,可能一些项目不需要项目权限
roleMapper.insert(role);
diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImplTest.java
index 941b7bca19..fc87193c44 100644
--- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImplTest.java
+++ b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImplTest.java
@@ -51,7 +51,8 @@ public class RoleServiceImplTest extends BaseDbUnitTest {
public void testCreateRole() {
// 准备参数
RoleSaveReqVO reqVO = randomPojo(RoleSaveReqVO.class)
- .setId(null); // 防止 id 被赋值
+ .setId(null) // 防止 id 被赋值
+ .setStatus(randomCommonStatus());
// 调用
Long roleId = roleService.createRole(reqVO, null);
@@ -59,7 +60,6 @@ public void testCreateRole() {
RoleDO roleDO = roleMapper.selectById(roleId);
assertPojoEquals(reqVO, roleDO, "id");
assertEquals(RoleTypeEnum.CUSTOM.getType(), roleDO.getType());
- assertEquals(CommonStatusEnum.ENABLE.getStatus(), roleDO.getStatus());
assertEquals(DataScopeEnum.ALL.getScope(), roleDO.getDataScope());
}
@@ -70,7 +70,8 @@ public void testUpdateRole() {
roleMapper.insert(roleDO);
// 准备参数
Long id = roleDO.getId();
- RoleSaveReqVO reqVO = randomPojo(RoleSaveReqVO.class, o -> o.setId(id));
+ RoleSaveReqVO reqVO = randomPojo(RoleSaveReqVO.class, o -> o.setId(id)
+ .setStatus(randomCommonStatus()));
// 调用
roleService.updateRole(reqVO);
From 047252d4fc12119a64dfb1598715453566cb9165 Mon Sep 17 00:00:00 2001
From: YunaiV
Date: Sat, 31 Aug 2024 13:29:34 +0800
Subject: [PATCH 15/15] =?UTF-8?q?=E3=80=90=E4=BB=A3=E7=A0=81=E4=BF=AE?=
=?UTF-8?q?=E5=A4=8D=E3=80=91SYSTEM=EF=BC=9A=E8=A7=92=E8=89=B2=E6=A0=87?=
=?UTF-8?q?=E8=AF=86=E7=9A=84=E6=8F=90=E7=A4=BA=E4=B8=8D=E6=AD=A3=E7=A1=AE?=
=?UTF-8?q?=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../config/YudaoMybatisAutoConfiguration.java | 5 ++-
.../core/aop/ApiSignatureAspect.java | 3 +-
.../core/service/LogRecordServiceImpl.java | 31 ++++++++++-------
.../service/OperateLogFrameworkService.java | 19 -----------
.../OperateLogFrameworkServiceImpl.java | 33 -------------------
.../YudaoSecurityAutoConfiguration.java | 2 +-
.../bpm/service/task/BpmTaskServiceImpl.java | 6 ++--
7 files changed, 26 insertions(+), 73 deletions(-)
delete mode 100644 yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLogFrameworkService.java
delete mode 100644 yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLogFrameworkServiceImpl.java
diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java
index b4faa4645a..ab2992184f 100644
--- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java
+++ b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java
@@ -25,13 +25,13 @@
*
* @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 {
+ // 动态 SQL 智能优化支持本地缓存加速解析,更完善的租户复杂 XML 动态 SQL 支持,静态注入缓存
JsqlParserGlobal.setJsqlParseCache(new JdkSerialCaffeineJsqlParseCache(
(cache) -> cache.maximumSize(1024)
.expireAfterWrite(5, TimeUnit.SECONDS))
@@ -73,5 +73,4 @@ public IKeyGenerator keyGenerator(ConfigurableEnvironment environment) {
throw new IllegalArgumentException(StrUtil.format("DbType{} 找不到合适的 IKeyGenerator 实现类", dbType));
}
-
}
diff --git a/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/signature/core/aop/ApiSignatureAspect.java b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/signature/core/aop/ApiSignatureAspect.java
index 0af3adba22..c1c78ac57b 100644
--- a/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/signature/core/aop/ApiSignatureAspect.java
+++ b/yudao-framework/yudao-spring-boot-starter-protection/src/main/java/cn/iocoder/yudao/framework/signature/core/aop/ApiSignatureAspect.java
@@ -165,5 +165,4 @@ private static SortedMap getRequestParameterMap(HttpServletReque
return sortedMap;
}
-}
-
+}
\ No newline at end of file
diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/LogRecordServiceImpl.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/LogRecordServiceImpl.java
index fea853e7c7..35e0975cb6 100644
--- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/LogRecordServiceImpl.java
+++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/LogRecordServiceImpl.java
@@ -4,19 +4,21 @@
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
+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.extern.slf4j.Slf4j;
+import org.springframework.scheduling.annotation.Async;
import java.util.List;
/**
* 操作日志 ILogRecordService 实现类
*
- * 基于 {@link OperateLogFrameworkService}实现, 记录操作日志
+ * 基于 {@link OperateLogApi} 实现,记录操作日志
*
* @author HUIHUI
*/
@@ -24,22 +26,27 @@
public class LogRecordServiceImpl implements ILogRecordService {
@Resource
- OperateLogFrameworkService operateLogFrameworkService;
+ private OperateLogApi operateLogApi;
@Override
+ @Async
public void record(LogRecord logRecord) {
- // 1. 补全通用字段
OperateLogCreateReqDTO reqDTO = new OperateLogCreateReqDTO();
- reqDTO.setTraceId(TracerUtils.getTraceId());
- // 补充用户信息
- fillUserFields(reqDTO);
- // 补全模块信息
- fillModuleFields(reqDTO, logRecord);
- // 补全请求信息
- fillRequestFields(reqDTO);
+ try {
+ reqDTO.setTraceId(TracerUtils.getTraceId());
+ // 补充用户信息
+ fillUserFields(reqDTO);
+ // 补全模块信息
+ fillModuleFields(reqDTO, logRecord);
+ // 补全请求信息
+ fillRequestFields(reqDTO);
- // 2. 异步记录日志
- operateLogFrameworkService.createOperateLog(reqDTO);
+ // 2. 异步记录日志
+ operateLogApi.createOperateLog(reqDTO).getCheckedData();
+ } catch (Throwable ex) {
+ // 由于 @Async 异步调用,这里打印下日志,更容易跟进
+ log.error("[record][url({}) log({}) 发生异常]", reqDTO.getRequestUrl(), reqDTO, ex);
+ }
}
private static void fillUserFields(OperateLogCreateReqDTO reqDTO) {
diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLogFrameworkService.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLogFrameworkService.java
deleted file mode 100644
index cf2cf5b005..0000000000
--- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLogFrameworkService.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package cn.iocoder.yudao.framework.operatelog.core.service;
-
-import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogCreateReqDTO;
-
-/**
- * API 操作日志 Framework Service 接口
- *
- * @author 陈晨成
- */
-public interface OperateLogFrameworkService {
-
- /**
- * 创建 操作日志
- *
- * @param reqDTO API 操作日志
- */
- void createOperateLog(OperateLogCreateReqDTO reqDTO);
-
-}
diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLogFrameworkServiceImpl.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLogFrameworkServiceImpl.java
deleted file mode 100644
index aa97689ac6..0000000000
--- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLogFrameworkServiceImpl.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package cn.iocoder.yudao.framework.operatelog.core.service;
-
-import cn.iocoder.yudao.module.system.api.logger.OperateLogApi;
-import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogCreateReqDTO;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.scheduling.annotation.Async;
-
-/**
- * API 操作日志 Framework Service 实现类
- *
- * 基于 {@link OperateLogApi} 服务,记录操作日志
- *
- * @author 陈晨成
- */
-@RequiredArgsConstructor
-@Slf4j
-public class OperateLogFrameworkServiceImpl implements OperateLogFrameworkService {
-
- private final OperateLogApi operateLogApi;
-
- @Override
- @Async
- public void createOperateLog(OperateLogCreateReqDTO reqDTO) {
- try {
- operateLogApi.createOperateLog(reqDTO);
- } catch (Throwable ex) {
- // 由于 @Async 异步调用,这里打印下日志,更容易跟进
- log.error("[createOperateLog][url({}) log({}) 发生异常]", reqDTO.getRequestUrl(), reqDTO, ex);
- }
- }
-
-}
diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoSecurityAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoSecurityAutoConfiguration.java
index a94fb878e7..f23aeed542 100644
--- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoSecurityAutoConfiguration.java
+++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoSecurityAutoConfiguration.java
@@ -24,7 +24,7 @@
/**
* Spring Security 自动配置类,主要用于相关组件的配置
- *
+ *
* 注意,不能和 {@link YudaoWebSecurityConfigurerAdapter} 用一个,原因是会导致初始化报错。
* 参见 https://stackoverflow.com/questions/53847050/spring-boot-delegatebuilder-cannot-be-null-on-autowiring-authenticationmanager 文档。
*
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
index 035cd4693b..dedfc5eecd 100644
--- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
@@ -97,7 +97,7 @@ public PageResult getTaskTodoPage(Long userId, BpmTaskPageReqVO pageVO) {
}
if (ArrayUtil.isNotEmpty(pageVO.getCreateTime())) {
taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[0]));
- taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[1]));
+ taskQuery.taskCreatedBefore(DateUtils.of(pageVO.getCreateTime()[1]));
}
long count = taskQuery.count();
if (count == 0) {
@@ -119,7 +119,7 @@ public PageResult getTaskDonePage(Long userId, BpmTaskPage
}
if (ArrayUtil.isNotEmpty(pageVO.getCreateTime())) {
taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[0]));
- taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[1]));
+ taskQuery.taskCreatedBefore(DateUtils.of(pageVO.getCreateTime()[1]));
}
// 执行查询
long count = taskQuery.count();
@@ -141,7 +141,7 @@ public PageResult getTaskPage(Long userId, BpmTaskPageReqV
}
if (ArrayUtil.isNotEmpty(pageVO.getCreateTime())) {
taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[0]));
- taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[1]));
+ taskQuery.taskCreatedBefore(DateUtils.of(pageVO.getCreateTime()[1]));
}
// 执行查询
long count = taskQuery.count();