处理数据库 复杂查询问题

This commit is contained in:
zk
2026-07-09 10:51:26 +08:00
parent b1b29fc6b1
commit 45f4c3d96f
@@ -66,7 +66,7 @@ public class MentorMockChatService {
String aiResponse = aiChatAbility.chat(systemPrompt, userMessage); String aiResponse = aiChatAbility.chat(systemPrompt, userMessage);
String json = AiResponseCleanTool.clean(aiResponse); String json = AiResponseCleanTool.clean(aiResponse);
// 5. 入库(存在则更新,不存在则插入) // 5. 入库(再查一次,防止并发期间已被其他线程插入)
MentorMockChat existRecord = mentorMockChatMapper.selectOne(new LambdaQueryWrapper<MentorMockChat>().eq(MentorMockChat::getMentorId, mentorId)); MentorMockChat existRecord = mentorMockChatMapper.selectOne(new LambdaQueryWrapper<MentorMockChat>().eq(MentorMockChat::getMentorId, mentorId));
if (existRecord != null) { if (existRecord != null) {
existRecord.setMessages(json); existRecord.setMessages(json);