From 646caaa926e2d4d7af9ca8ee11dbc0dc2f474765 Mon Sep 17 00:00:00 2001 From: winter <2436197699@qq.com> Date: Wed, 20 Dec 2023 15:12:00 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E8=B0=83=E6=95=B4=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E4=BC=9A=E8=AF=9D=E7=9A=84=E6=8E=A5=E5=8F=A3,?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=88=9B=E5=BB=BA=E7=9A=84=E4=BC=9A=E8=AF=9D?= =?UTF-8?q?ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/teammodel/controller/frontend/AiController.java | 4 ++-- src/main/java/cn/teammodel/service/ChatSessionService.java | 2 +- .../cn/teammodel/service/impl/ChatSessionServiceImpl.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/cn/teammodel/controller/frontend/AiController.java b/src/main/java/cn/teammodel/controller/frontend/AiController.java index d58a2fa..18501cc 100644 --- a/src/main/java/cn/teammodel/controller/frontend/AiController.java +++ b/src/main/java/cn/teammodel/controller/frontend/AiController.java @@ -38,8 +38,8 @@ public class AiController { @PostMapping("session/create") @ApiOperation("创建聊天会话") public R createSession() { - chatSessionService.createSession(); - return R.success("创建会话成功"); + String sessionId = chatSessionService.createSession(); + return R.success(sessionId); } @PostMapping("session/remove") diff --git a/src/main/java/cn/teammodel/service/ChatSessionService.java b/src/main/java/cn/teammodel/service/ChatSessionService.java index 17ea615..861e9e7 100644 --- a/src/main/java/cn/teammodel/service/ChatSessionService.java +++ b/src/main/java/cn/teammodel/service/ChatSessionService.java @@ -11,7 +11,7 @@ import java.util.List; */ public interface ChatSessionService { - void createSession(); + String createSession(); List listMySession(); diff --git a/src/main/java/cn/teammodel/service/impl/ChatSessionServiceImpl.java b/src/main/java/cn/teammodel/service/impl/ChatSessionServiceImpl.java index 80c1d4e..dfd4489 100644 --- a/src/main/java/cn/teammodel/service/impl/ChatSessionServiceImpl.java +++ b/src/main/java/cn/teammodel/service/impl/ChatSessionServiceImpl.java @@ -35,7 +35,7 @@ public class ChatSessionServiceImpl implements ChatSessionService { private ChatSessionRepository chatSessionRepository; @Override - public void createSession() { + public String createSession() { User user = SecurityUtil.getLoginUser(); String userId = user.getId(); // 初始化欢迎语 @@ -49,7 +49,7 @@ public class ChatSessionServiceImpl implements ChatSessionService { chatSession.setCreateTime(Instant.now().toEpochMilli()); chatSession.setUpdateTime(Instant.now().toEpochMilli()); chatSession.setHistory(history); - chatSessionRepository.save(chatSession); + return chatSessionRepository.save(chatSession).getId(); } @Override