mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 15:13:55 +08:00
Update AgentChatHistoryServiceImpl.java
添加降序排序, 1.改用id的原因:数据形式,id越大的创建时间就越晚,所以使用id的结果和创建时间降序排列结果一样 2.id作为降序排列的优势,性能高,有主键索引,不用在排序的时候重新进行排除扫描比较
This commit is contained in:
+4
-1
@@ -104,7 +104,10 @@ public class AgentChatHistoryServiceImpl extends ServiceImpl<AiAgentChatHistoryD
|
||||
.eq(AgentChatHistoryEntity::getAgentId, agentId)
|
||||
.eq(AgentChatHistoryEntity::getChatType, AgentChatHistoryType.USER.getValue())
|
||||
.isNotNull(AgentChatHistoryEntity::getAudioId)
|
||||
.orderByDesc(AgentChatHistoryEntity::getCreatedAt); // 添加此行,确保查询结果按照创建时间降序排列
|
||||
// 添加此行,确保查询结果按照创建时间降序排列
|
||||
// 使用id的原因:数据形式,id越大的创建时间就越晚,所以使用id的结果和创建时间降序排列结果一样
|
||||
// id作为降序排列的优势,性能高,有主键索引,不用在排序的时候重新进行排除扫描比较
|
||||
.orderByDesc(AgentChatHistoryEntity::getId);
|
||||
|
||||
// 构建分页查询,查询前50页数据
|
||||
Page<AgentChatHistoryEntity> pageParam = new Page<>(0, 50);
|
||||
|
||||
Reference in New Issue
Block a user