mirror of
https://github.com/BgaSol/sol-cloud
synced 2026-04-21 17:17:16 +00:00
fix: 修复动态表缓存键并补充请求日志字段映射
This commit is contained in:
parent
47cb1f1d6a
commit
5f0816cdd5
2 changed files with 9 additions and 3 deletions
|
|
@ -2,6 +2,7 @@ package com.bgasol.common.core.base.handler;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.plugins.handler.TableNameHandler;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
@ -10,6 +11,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class DynamicTableNameHandler implements TableNameHandler {
|
||||
public final static String DynamicTableNameUnderscore = "_d_";
|
||||
private final List<BaseTableNameHandler> baseTableNameHandlers;
|
||||
|
|
@ -32,11 +34,12 @@ public class DynamicTableNameHandler implements TableNameHandler {
|
|||
return targetTable;
|
||||
}
|
||||
|
||||
// 建表并缓存表名
|
||||
String createSql = "CREATE TABLE IF NOT EXISTS %s (LIKE %s INCLUDING ALL)".formatted(targetTable, tableName);
|
||||
// 建表
|
||||
String createSql = "CREATE TABLE IF NOT EXISTS %s (LIKE %s INCLUDING ALL)"
|
||||
.formatted(targetTable, tableName);
|
||||
jdbcTemplate.execute(createSql);
|
||||
createdTableNameMap.put(tableName, true);
|
||||
|
||||
createdTableNameMap.put(targetTable, true);
|
||||
return targetTable;
|
||||
} else {
|
||||
// 如果目标表是缓存过的,直接用缓存的结果
|
||||
|
|
|
|||
|
|
@ -28,12 +28,15 @@ public class RequestLogEntity extends BaseTreeEntity<RequestLogEntity> implement
|
|||
private String traceId;
|
||||
|
||||
@Schema(description = "服务名")
|
||||
@TableField("service_name")
|
||||
private String serviceName;
|
||||
|
||||
@Schema(description = "节点名")
|
||||
@TableField("node_name")
|
||||
private String nodeName;
|
||||
|
||||
@Schema(description = "节点IP")
|
||||
@TableField("node_ip")
|
||||
private String nodeIp;
|
||||
|
||||
@Schema(description = "HTTP方法")
|
||||
|
|
|
|||
Loading…
Reference in a new issue