diff --git a/src/main/java/com/wok/supportbot/entity/ChatMessage.java b/src/main/java/com/wok/supportbot/entity/ChatMessage.java index bfb5308..5f4675e 100644 --- a/src/main/java/com/wok/supportbot/entity/ChatMessage.java +++ b/src/main/java/com/wok/supportbot/entity/ChatMessage.java @@ -27,6 +27,7 @@ public class ChatMessage implements Serializable { private static final long serialVersionUID = 1L; @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonSerialize(using = ToStringSerializer.class) private Long id; /** diff --git a/src/main/java/com/wok/supportbot/service/AiModelConfigService.java b/src/main/java/com/wok/supportbot/service/AiModelConfigService.java index 038aed1..7ea5bf0 100644 --- a/src/main/java/com/wok/supportbot/service/AiModelConfigService.java +++ b/src/main/java/com/wok/supportbot/service/AiModelConfigService.java @@ -66,7 +66,8 @@ public class AiModelConfigService { List> formattedRecords = new ArrayList<>(); for (AiModelConfig record : records) { Map formatted = new LinkedHashMap<>(); - formatted.put("id", record.getId()); + // 雪花 ID 必须转为字符串,避免 JS 精度丢失(超过 Number.MAX_SAFE_INTEGER) + formatted.put("id", record.getId().toString()); formatted.put("name", record.getName()); formatted.put("app_type", record.getAppType()); formatted.put("provider", record.getProvider()); diff --git a/src/main/java/com/wok/supportbot/service/ConversationService.java b/src/main/java/com/wok/supportbot/service/ConversationService.java index 5f97863..f51a164 100644 --- a/src/main/java/com/wok/supportbot/service/ConversationService.java +++ b/src/main/java/com/wok/supportbot/service/ConversationService.java @@ -278,7 +278,8 @@ public class ConversationService { List> result = new ArrayList<>(); for (ChatMessage msg : messages) { Map item = new LinkedHashMap<>(); - item.put("id", msg.getId()); + // 雪花 ID 必须转为字符串,避免 JS 精度丢失 + item.put("id", msg.getId().toString()); item.put("conversationId", msg.getConversationId()); item.put("messageType", msg.getMessageType()); item.put("content", msg.getContent()); diff --git a/src/main/java/com/wok/supportbot/service/DocumentService.java b/src/main/java/com/wok/supportbot/service/DocumentService.java index 74b555e..aa0eb1b 100644 --- a/src/main/java/com/wok/supportbot/service/DocumentService.java +++ b/src/main/java/com/wok/supportbot/service/DocumentService.java @@ -396,10 +396,10 @@ public class DocumentService { try { int vectorCount = deleteDocument(id); successCount++; - details.add(Map.of("id", id, "success", true, "deletedVectors", vectorCount)); + details.add(Map.of("id", id.toString(), "success", true, "deletedVectors", vectorCount)); } catch (Exception e) { failCount++; - details.add(Map.of("id", id, "success", false, "message", e.getMessage())); + details.add(Map.of("id", id.toString(), "success", false, "message", e.getMessage())); log.warn("批量删除文档失败: id={}", id, e); } } @@ -426,10 +426,10 @@ public class DocumentService { try { reprocessDocument(id); successCount++; - details.add(Map.of("id", id, "success", true)); + details.add(Map.of("id", id.toString(), "success", true)); } catch (Exception e) { failCount++; - details.add(Map.of("id", id, "success", false, "message", e.getMessage())); + details.add(Map.of("id", id.toString(), "success", false, "message", e.getMessage())); log.warn("批量重新处理文档失败: id={}", id, e); } }