From 325d2fbc3d907dcf3f574d8e1f30d0269ddc1937 Mon Sep 17 00:00:00 2001
From: houzhongjian <houzhongyi@126.com>
Date: 星期三, 24 七月 2024 08:28:47 +0800
Subject: [PATCH] 1、请求租户不存在时,记录访问日志、操作日志异常的问题 2、LoginUser 新增过期时间,方便判断 token 过期 3、增加 ConfigApi,支持参数配置的读取

---
 iailab-module-infra/iailab-module-infra-biz/src/main/java/com/iailab/module/infra/service/logger/ApiAccessLogServiceImpl.java |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/iailab-module-infra/iailab-module-infra-biz/src/main/java/com/iailab/module/infra/service/logger/ApiAccessLogServiceImpl.java b/iailab-module-infra/iailab-module-infra-biz/src/main/java/com/iailab/module/infra/service/logger/ApiAccessLogServiceImpl.java
index 513c84d..6fd58ff 100644
--- a/iailab-module-infra/iailab-module-infra-biz/src/main/java/com/iailab/module/infra/service/logger/ApiAccessLogServiceImpl.java
+++ b/iailab-module-infra/iailab-module-infra-biz/src/main/java/com/iailab/module/infra/service/logger/ApiAccessLogServiceImpl.java
@@ -3,6 +3,8 @@
 import cn.hutool.core.util.StrUtil;
 import com.iailab.framework.common.pojo.PageResult;
 import com.iailab.framework.common.util.object.BeanUtils;
+import com.iailab.framework.tenant.core.context.TenantContextHolder;
+import com.iailab.framework.tenant.core.util.TenantUtils;
 import com.iailab.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO;
 import com.iailab.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO;
 import com.iailab.module.infra.dal.dataobject.logger.ApiAccessLogDO;
@@ -35,7 +37,12 @@
         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));
-        apiAccessLogMapper.insert(apiAccessLog);
+        if (TenantContextHolder.getTenantId() != null) {
+            apiAccessLogMapper.insert(apiAccessLog);
+        } else {
+            // 极端情况下,上下文中没有租户时,此时忽略租户上下文,避免插入失败!
+            TenantUtils.executeIgnore(() -> apiAccessLogMapper.insert(apiAccessLog));
+        }
     }
 
     @Override

--
Gitblit v1.9.3