苍穹外卖 查询订单明细
OrderController
/*** 查询订单详情** @param id* @return*/@GetMapping("/orderDetail/{id}")@ApiOperation("查询订单详情")public Result<OrderVO> selectDetails(@PathVariable Long id) {OrderVO orderVO = orderService.selectDetails(id);return Result.success(orderVO);}
OrderService
/*** 查询订单详情** @param id* @return*/@Overridepublic OrderVO selectDetails(Long id) {// 根据id查询订单Orders order = new Orders();// 根据该订单的id查询对应的明细List<OrderDetail> orderDetailList = orderDetailMapper.getByOrderId(order.getId());// 将订单明细封装为OrderVO返回OrderVO orderVO = new OrderVO();BeanUtils.copyProperties(order, orderVO);orderVO.setOrderDetailList(orderDetailList);return orderVO;}
OrderMapper
/*** 根据订单id查询订单明细** @param orderId* @return*/@Select("select * from order_detail where order_id = #{order_id}")List<OrderDetail> getByOrderId(Long orderId);