1

我有一个以 pageable 作为参数的查询。我将方向定义为 DESC,但这不起作用。这是我的要求。您能否帮助我以结果按降序排序的方式制定请求?我已经在下面的图片中发布了我的请求。它可以工作,但不会对结果进行排序

谢谢 在此处输入图像描述

这是控制器代码:

@GetMapping
fun listMessages(@RequestParam conversationRef: String,
                 @RequestParam fromDate: Instant, @RequestParam toDate: Instant, 
                 pageable: Pageable): PaginatedCollection<MessageVO> {
                     return messageService.listAll(fromDate, toDate, pageable, 
                              conversationRef).data ?: PaginatedCollection(listOf(), 
                              PaginationVO.build(), SortVO.build())
}
4

1 回答 1

1

您需要发送要按降序排序的排序字段。(参考)例如:

http://localhost:8080/people?sort=id,desc

id是排序字段,desc是排序方向,用逗号分隔。

因此,您需要在 PostMan 中发送id,desc参数sort以按id降序排序。

于 2020-08-20T13:56:03.500 回答