说明:
(1)本篇博客的内容:开发【前台:订单详情】接口;
(2)本篇博客的整体逻辑比较简单;需要注意的地方有两点:
● 要做好权限校验;
● 需要根据接口对返回数据的格式要求,去组织数据;
目录
1.在OrderController中,创建处理【前台:订单详情】接口请求的方法:detail()方法;
2.在OrderServiceImpl中,编写获取订单详情的逻辑方法:detail()方法;
一:【前台:订单详情】接口介绍;
1.【前台:订单详情】接口,接口文档;
可以看到,接口要求的返回数据的格式,使用以前创建的Order和OrderItem去包装数据,都不能满足要求;
所以,为了能够更好的组织数据,以满足接口对返回数据格式的要求,我们创建了OrderVO实体类和OrderItemVO实体类:
OrderItemVO:
package com.imooc.mall.model.vo; import java.util.Date; public class OrderItemVO { private String orderNo; private String productName; private String productImg; private Integer unitPrice; private Integer quantity; private Integer totalPrice; public String getOrderNo() { return orderNo; } public void setOrderNo(String orderNo) { this.orderNo = orderNo; } public String getProductName() { return productName; } public void setProductName(String productName) { this.productName = productName; } public String getProductImg() { return productImg; } public void setProductImg(String productImg) { this.productImg = productImg; } public Integer getUnitPrice() { return unitPrice; } public void setUnitPrice(Integer unitPrice) { this.unitPrice = unitPrice; } public Integer getQuantity() { return quantity; } public void setQuantity(Integer quantity) { this.quantity = quantity; } public Integer getTotalPrice() { return totalPrice; } public void setTotalPrice(Integer totalPrice) { this.totalPrice = totalPrice; } }
OrderVO:
package com.imooc.mall.model.vo; import com.imooc.mall.model.pojo.OrderItem; import java.util.Date; import java.util.List; public class OrderVO { //很显然,我不能返回order表的id字段,否则会暴露我们商城的业务量这种秘密信息; //当然,接口中业没有要求返回order表的id信息; // private Integer id; private String orderNo; private Integer userId; private Integer totalPrice; private String receiverName; private String receiverMobile; private String receiverAddress; private Integer orderStatus; private Integer postage; private Integer paymentType; private Date deliveryTime; private Date payTime; private Date endTime; private Date createTime; private Date updateTime; private String orderStatusName; private List<OrderItemVO> orderItemVOList; public String getOrderNo() { return orderNo; } public void setOrderNo(String orderNo) { this.