List<RoomTicketEntity> list = roomTicketService.list(new LambdaQueryWrapper<RoomTicketEntity>().eq(RoomTicketEntity::getStatus, StatusEnum.DID.type) .eq(RoomTicketEntity::getArea, ticketDemand.getArea()) .orderByAsc(BaseEntity::getCreateDate) 帮改一下,先按照status等于1排序,然后按照createDate从近到远排序
时间: 2024-02-27 10:57:35 浏览: 73
list排序
可以将代码改为:
```
List<RoomTicketEntity> list = roomTicketService.list(new LambdaQueryWrapper<RoomTicketEntity>()
.eq(RoomTicketEntity::getArea, ticketDemand.getArea())
.eq(RoomTicketEntity::getStatus, StatusEnum.DID.type)
.orderByDesc(BaseEntity::getCreateDate)
.orderByAsc(RoomTicketEntity::getStatus));
```
这样就可以先按照状态从小到大排序(1在前面),再按照创建时间从近到远排序。注意,orderBy方法可以连续调用多次,表示多个排序条件,调用顺序即为排序的优先级。
阅读全文