Search in sources :

Example 1 with OrderVO

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);
}
Also used : Order(com.whoiszxl.entity.Order) OrderVO(com.whoiszxl.entity.vo.OrderVO) OrderItem(com.whoiszxl.entity.OrderItem) OrderItemVO(com.whoiszxl.entity.vo.OrderItemVO) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) SaCheckLogin(cn.dev33.satoken.annotation.SaCheckLogin) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

SaCheckLogin (cn.dev33.satoken.annotation.SaCheckLogin)1 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)1 Order (com.whoiszxl.entity.Order)1 OrderItem (com.whoiszxl.entity.OrderItem)1 OrderItemVO (com.whoiszxl.entity.vo.OrderItemVO)1 OrderVO (com.whoiszxl.entity.vo.OrderVO)1 ApiOperation (io.swagger.annotations.ApiOperation)1