use of com.whoiszxl.entity.vo.OrderVO in project shopzz by whoiszxl.
the class OrderController method orderList.
@SaCheckLogin
@PostMapping("/list")
@ApiOperation(value = "获取当前用户的订单列表", notes = "获取当前用户的订单列表", response = String.class)
public ResponseResult<IPage<OrderVO>> orderList(@RequestBody OrderListQuery query) {
long memberId = StpUtil.getLoginIdAsLong();
LambdaQueryWrapper<Order> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Order::getMemberId, memberId);
if (query.getOrderStatus() != 0) {
queryWrapper.eq(Order::getOrderStatus, query.getOrderStatus());
}
IPage<Order> orderList = orderService.page(new Page<>(query.getPage(), query.getSize()), queryWrapper);
IPage<OrderVO> orderVOList = orderList.convert(order -> {
OrderVO orderVO = dozerUtils.map(order, OrderVO.class);
// 获取orderItem
List<OrderItem> orderItemList = orderItemService.list(new LambdaQueryWrapper<OrderItem>().eq(OrderItem::getOrderId, orderVO.getId()));
List<OrderItemVO> orderItemVOS = dozerUtils.mapList(orderItemList, OrderItemVO.class);
orderVO.setOrderItemVOList(orderItemVOS);
return orderVO;
});
return ResponseResult.buildSuccess(orderVOList);
}
Aggregations