| | |
| | | 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; |
| | |
| | | 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 |