文章目录
概要
查询订单详情是一个常见的业务需求,尤其在电子商务、物流、零售等行业中。这项功能允许客户、客服代表以及后台管理人员查看订单的具体信息,以便于跟踪订单状态、处理售后问题、进行数据分析等.
需求分析以及接口设计
技术细节
1.Controller层:
/**
* 查询订单详情
* @param id
* @return
*/
@ApiOperation("查询订单详情")
@GetMapping("/details/{id}")
public Result<OrderVO> details(@PathVariable Long id){
log.info("查询订单详情,订单id:{}",id);
OrderVO orderVO = orderService.details(id);
return Result.success(orderVO);
}
2.Service层:
@Override
public OrderVO details(Long id) {
//查询到这个订单明细
List<OrderDetail> orderDetailList = orderDetailMapper.selectByOrderId(id);
//封装到OrderVO中
OrderVO orderVO = new OrderVO();
orderVO.setOrderDetailList(orderDetailList);
//查询到这个订单
Orders order = orderMapper.getById(id);
BeanUtils.copyProperties(order,orderVO);
return orderVO;
}
3.Mapper层:
@Select("select * from `sky-take-out`.order_detail where order_id = #{orderId}")
List<OrderDetail> selectByOrderId(Long orderId);
@Select("select * from `sky-take-out`.orders where id = #{id}")
Orders getById(Long id);