要求最终返回的结果类型为:
@TableName("tb_order") @Data @Accessors(chain=true) public class Order extends BasePojo{ @TableField(exist=false) //入库操作忽略该字段 private OrderShipping orderShipping;//订单物流信息 一对一 @TableField(exist=false) //入库操作忽略该字段 private List<OrderItem> orderItems; //封装订单商品信息 一对多 /** * orderId不是主键自增,使用uuid */ @TableId private String orderId; private String payment; private Integer paymentType; private String postFee; private Integer status; //状态:1、未付款2、已付款3、未发货4、已发货5、交易成功6、交易关闭 private Date paymentTime; private Date consignTime; private Date endTime; private Date closeTime; private String shippingName; private String shippingCode; private Long userId; private String buyerMessage; private String buyerNick; private Integer buyerRate; }
其中OrderShipping 为:
@TableName("tb_order_shipping") @Data @Accessors(chain=true) public class OrderShipping extends BasePojo{ @TableId private String orderId; private String receiverName; private String receiverPhone; private String receiverMobile; private String receiverState; private String receiverCity; private String receiverDistrict; private String receiverAddress; private String receiverZip; }
OrderItem为:
@TableName("tb_order_item") @Data @Accessors(chain=true) public class OrderItem extends BasePojo{ @TableId private String itemId; @TableId private String orderId; private Integer num; private String title; private Long price; private Long totalFee; private String picPath; }
Mapper.xml