diff --git a/servers/boe-server-all/src/main/java/com/xboe/module/boecase/service/impl/CaseAiChatServiceImpl.java b/servers/boe-server-all/src/main/java/com/xboe/module/boecase/service/impl/CaseAiChatServiceImpl.java index 143a2f56..0722f4a7 100644 --- a/servers/boe-server-all/src/main/java/com/xboe/module/boecase/service/impl/CaseAiChatServiceImpl.java +++ b/servers/boe-server-all/src/main/java/com/xboe/module/boecase/service/impl/CaseAiChatServiceImpl.java @@ -45,6 +45,7 @@ import org.jetbrains.annotations.Nullable; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StringUtils; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; @@ -83,6 +84,7 @@ public class CaseAiChatServiceImpl implements ICaseAiChatService { private CasesDao casesDao; @Override + @Transactional public SseEmitter chat(CaseAiChatDto caseAiChatDto, CurrentUser currentUser) { // 1. 获取conversationId String conversationId = getOrCreateConversationId(caseAiChatDto, currentUser); @@ -96,7 +98,7 @@ public class CaseAiChatServiceImpl implements ICaseAiChatService { conversation.setAiConversationId(conversationId); conversation.setConversationName("AI案例咨询-" + LocalDateTime.now()); conversation.setConversationUser(currentUser.getAccountId()); - // 由于编译问题,这里先注释,实际部署时需要取消注释 + // 保存会话到数据库 caseAiConversationsDao.save(conversation); } @@ -242,6 +244,7 @@ public class CaseAiChatServiceImpl implements ICaseAiChatService { } @Override + @Transactional public CaseAiConversations createNewConversation(String userId, String conversationName) { try (CloseableHttpClient httpClient = HttpClients.createDefault()) { String url = caseAiProperties.getBaseUrl() + "/apigateway/knowledge/v1/conversation";