fix(service): 修复聊天消息排序逻辑
在分页查询消息时,先按时间升序再按ID升序,确保顺序稳定一致
This commit is contained in:
@@ -46,7 +46,8 @@ public class KeyboardAiChatMessageServiceImpl extends ServiceImpl<KeyboardAiChat
|
||||
queryWrapper.eq(KeyboardAiChatMessage::getUserId, userId)
|
||||
.eq(KeyboardAiChatMessage::getCompanionId, companionId)
|
||||
.eq(KeyboardAiChatMessage::getSessionId, activeSession.getId())
|
||||
.orderByDesc(KeyboardAiChatMessage::getCreatedAt);
|
||||
.orderByAsc(KeyboardAiChatMessage::getCreatedAt)
|
||||
.orderByAsc(KeyboardAiChatMessage::getId);
|
||||
IPage<KeyboardAiChatMessage> entityPage = this.page(page, queryWrapper);
|
||||
return entityPage.convert(entity -> BeanUtil.copyProperties(entity, ChatMessageHistoryVO.class));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user