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 21:57:35 浏览: 78
可以将代码改为:
```
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方法可以连续调用多次,表示多个排序条件,调用顺序即为排序的优先级。
相关问题
public ApiResult<List<ViewUser>> FindUser(int id) { List<ViewUser> viewuser = DbConfig.Db.Queryable<ViewUser>().Where(it => it.id == id).ToList(); return new ApiResult<ViewUser> { Status = ResultStatus.Success, Data = viewuser }; }帮我查看一下这段代码的问题
这段代码的问题在于返回类型不匹配,应该返回 ApiResult<List<ViewUser>> 而不是 ApiResult<ViewUser>。正确的代码应该是:
public ApiResult<List<ViewUser>> FindUser(int id)
{
List<ViewUser> viewuser = DbConfig.Db.Queryable<ViewUser>().Where(it => it.id == id).ToList();
return new ApiResult<List<ViewUser>> { Status = ResultStatus.Success, Data = viewuser };
}
List<Orders> orderList = orderService.selectOrderByUserId(userId);用LambdaQueryWrapper<Employee> queryWrapper = new LambdaQueryWrapper();实现
LambdaQueryWrapper<Orders> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Orders::getUserId, userId);
List<Orders> orderList = orderService.list(queryWrapper);
阅读全文