From db68b13cad30b5c3849484f26e27152c38d39824 Mon Sep 17 00:00:00 2001 From: wanghanlin <1533525126@qq.com> Date: Thu, 2 Jul 2026 17:27:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=85=8D=E7=BD=AE=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E7=BC=96=E8=BE=91=E4=BF=9D=E5=AD=98=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/wok/supportbot/entity/ChatMessage.java | 1 + .../com/wok/supportbot/service/AiModelConfigService.java | 3 ++- .../com/wok/supportbot/service/ConversationService.java | 3 ++- .../java/com/wok/supportbot/service/DocumentService.java | 8 ++++---- 4 files changed, 9 insertions(+), 6 deletions(-) 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); } }