fix: 增加时间排序,修复增加声纹注册获取对话记录不是最新对话的问题

https://github.com/xinnan-tech/xiaozhi-esp32-server/issues/1922
This commit is contained in:
xingxinonline
2025-07-28 11:20:39 +08:00
parent 2370936dfd
commit d9062a0bb0
@@ -103,7 +103,8 @@ public class AgentChatHistoryServiceImpl extends ServiceImpl<AiAgentChatHistoryD
wrapper.select(AgentChatHistoryEntity::getContent, AgentChatHistoryEntity::getAudioId)
.eq(AgentChatHistoryEntity::getAgentId, agentId)
.eq(AgentChatHistoryEntity::getChatType, AgentChatHistoryType.USER.getValue())
.isNotNull(AgentChatHistoryEntity::getAudioId);
.isNotNull(AgentChatHistoryEntity::getAudioId)
.orderByDesc(AgentChatHistoryEntity::getCreatedAt); // 添加此行,确保查询结果按照创建时间降序排列
// 构建分页查询,查询前50页数据
Page<AgentChatHistoryEntity> pageParam = new Page<>(0, 50);