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/ApiErrorLogServiceImpl.java | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/iailab-module-infra/iailab-module-infra-biz/src/main/java/com/iailab/module/infra/service/logger/ApiErrorLogServiceImpl.java b/iailab-module-infra/iailab-module-infra-biz/src/main/java/com/iailab/module/infra/service/logger/ApiErrorLogServiceImpl.java index 807d142..5a28ef4 100644 --- a/iailab-module-infra/iailab-module-infra-biz/src/main/java/com/iailab/module/infra/service/logger/ApiErrorLogServiceImpl.java +++ b/iailab-module-infra/iailab-module-infra-biz/src/main/java/com/iailab/module/infra/service/logger/ApiErrorLogServiceImpl.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.ApiErrorLogCreateReqDTO; import com.iailab.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO; import com.iailab.module.infra.dal.dataobject.logger.ApiErrorLogDO; @@ -25,9 +27,9 @@ * * @author iailab */ -@Slf4j @Service @Validated +@Slf4j public class ApiErrorLogServiceImpl implements ApiErrorLogService { @Resource @@ -38,7 +40,12 @@ ApiErrorLogDO apiErrorLog = BeanUtils.toBean(createDTO, ApiErrorLogDO.class) .setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus()); apiErrorLog.setRequestParams(StrUtil.maxLength(apiErrorLog.getRequestParams(), REQUEST_PARAMS_MAX_LENGTH)); - apiErrorLogMapper.insert(apiErrorLog); + if (TenantContextHolder.getTenantId() != null) { + apiErrorLogMapper.insert(apiErrorLog); + } else { + // 极端情况下,上下文中没有租户时,此时忽略租户上下文,避免插入失败! + TenantUtils.executeIgnore(() -> apiErrorLogMapper.insert(apiErrorLog)); + } } @Override -- Gitblit v1.9.3