首先查看,数据库字段:
书写映射实体类对象VO:
- @Data
- public class OrderListVO implements Serializable {
- private Integer orderId;
- private String memberName;
- private String orderNumber;
- private BigDecimal orderPrice;
- private String logisticsNo;
- private String status;
- private LocalDateTime createTime;
- private LocalDateTime sendTime;
- }
编写sql语句:
-
- SELECT sod.order_id orderId, sm.username memberName,
- sod.order_number orderNumber,
- sod.order_price orderPrice,
- sod.is_send isSend,
- sod.logistics_no logisticsNo,
- sod.`status`,
- sod.create_time createTime,
- sod.send_time sendTime
- FROM `sp_order` sod
- LEFT JOIN sp_member sm on sod.member_id = sm.id
- where sm.is_deleted = 0
- <if test="orderNumber!=null and orderNumber!=''">
- and order_number=#{orderNumber}
- if>
- <if test="username!=null and username!=''">
- and username=#{memberName}
- if>
- <if test="isSend!=null and isSend!=''">
- and is_send=#{isSend}
- if>
- <if test="status!=null">
- and status=#{status}
- if>
- <if test="beginTime!=null and endTime!=null">
- and create_time BETWEEN #{beginTime} AND #{endTime}
- if>
-
编写映射Map:
-
"orderPageList" type="net.wanho.qz112.shop.order.vo.OrderListVO"> -
"orderId" property="orderId"/> -
"memberName" property="memberName"/> -
"orderNumber" property="orderNumber"/> -
"orderPrice" property="orderPrice"/> -
"isSend" property="isSend"/> -
"logisticsNo" property="logisticsNo"/> -
"status" property="status"/> -
"createTime" property="createTime"/> -
"sendTime" property="sendTime"/> -
mapper接口:
List select(OrderListDTO orderListDTO);
service:接口
Map findOrder(Integer pageNum, Integer pageSize, OrderListDTO order);
映射完成后,通过serviceImpl调用:
- public Map
findOrder(Integer pageNum, Integer pageSize, OrderListDTO order) { - PageHelper.startPage(pageNum,pageSize);
- List
list = orderMapper.select(order); - Map
map = new HashMap<>(3); - PageInfo pageInfo = new PageInfo(list);
- map.put("total",pageInfo.getTotal());
- map.put("pageNum", pageInfo.getPageNum());
- map.put("orders", pageInfo.getList());
- return map;
- }
controller:
- @Resource
- private OrderService orderService;
-
- @GetMapping("/orders")
- public AjaxResult findPage(Integer pageNum, Integer pageSize, OrderListDTO order) {
- Map
map = orderService.findOrder(pageNum,pageSize,order); - return AjaxResult.success("获取订单列表成功!",map);
- }
实现图片:
此处有弊端,请移步下一篇……