From a38e3356b64aa2b2dcfee207820e2a30b2cbdf26 Mon Sep 17 00:00:00 2001 From: zhengshaodong Date: Sun, 24 Jun 2018 15:09:55 +0800 Subject: [PATCH] support query by user name --- .../akkaha/shop/controllers/ShopOrderController.java | 11 +++++++++++ .../akkaha/shop/controllers/model/QueryShopOrder.java | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/src/main/java/cc/akkaha/shop/controllers/ShopOrderController.java b/src/main/java/cc/akkaha/shop/controllers/ShopOrderController.java index 5f720b4..b92da2a 100644 --- a/src/main/java/cc/akkaha/shop/controllers/ShopOrderController.java +++ b/src/main/java/cc/akkaha/shop/controllers/ShopOrderController.java @@ -59,6 +59,17 @@ public Object query(@RequestBody QueryShopOrder query) { if (null != query.getStatus()) { userOrderWrapper.eq(ShopOrder.STATUS, query.getStatus()); } + if (StringUtils.isNotEmpty(query.getUserName())) { + EntityWrapper userEntityWrapper = new EntityWrapper<>(); + userEntityWrapper.like(ShopUser.NAME, query.getUserName()); + List userIds = shopUserService.selectList(userEntityWrapper) + .stream() + .map(ShopUser::getId) + .collect(Collectors.toList()); + if (null != userIds && !userIds.isEmpty()) { + userOrderWrapper.in(ShopOrder.USER, userIds); + } + } Date start = null; Date end = null; try { diff --git a/src/main/java/cc/akkaha/shop/controllers/model/QueryShopOrder.java b/src/main/java/cc/akkaha/shop/controllers/model/QueryShopOrder.java index 71f28e7..2500ba7 100644 --- a/src/main/java/cc/akkaha/shop/controllers/model/QueryShopOrder.java +++ b/src/main/java/cc/akkaha/shop/controllers/model/QueryShopOrder.java @@ -8,6 +8,7 @@ public class QueryShopOrder extends ShopOrder { private Integer size = 10; private String start; private String end; + private String userName; public Integer getCurrent() { if (null == this.current) { @@ -40,4 +41,12 @@ public String getEnd() { public void setEnd(String end) { this.end = end; } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } }