Browse Source

fix 修改数据权限问题

chenchen 4 months ago
parent
commit
e3ab010761

+ 26 - 22
application-webadmin/src/main/java/com/tourism/webadmin/app/wechat/controller/WechatDeliveryOrderController.java

@@ -29,10 +29,7 @@ import org.junit.Ignore;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Tag(name = "外卖订单接口")
@@ -86,24 +83,31 @@ public class WechatDeliveryOrderController {
         deliveryOrderService.maskFieldDataList(deliveryOrderList, null);
 
         //查询订单详情
-        Set<String> orderIds = deliveryOrderList.stream().map(e -> e.getId()).collect(Collectors.toSet());
-        List<DeliveryOrderItems> items = deliveryOrderItemsService.getDeliveryOrderItemsVoList(orderIds);
-        List<DeliveryOrderItemsVo> deliveryOrderItemsVos = MyModelUtil.copyCollectionTo(items, DeliveryOrderItemsVo.class);
-        //做成map,方便匹配
-        Map<String, List<DeliveryOrderItemsVo>> collect1 = deliveryOrderItemsVos.stream().collect(Collectors.groupingBy(DeliveryOrderItemsVo::getOrderId));
-        MyPageData<DeliveryOrderVo> pageData = MyPageUtil.makeResponseData(deliveryOrderList, DeliveryOrderVo.class);
-        pageData.getDataList().forEach(e->{
-            e.setItemList(collect1.get(e.getId()));
-        });
-        List<DeliveryOrderVo> dataList = pageData.getDataList();
-        dataList.sort(new Comparator<DeliveryOrderVo>() {
-            @Override
-            public int compare(DeliveryOrderVo o1, DeliveryOrderVo o2) {
-                int compareTo = o2.getCreateTime().compareTo(o1.getCreateTime());
-                return compareTo;
-            }
-        });
-        pageData.setDataList(dataList);
+        if (!deliveryOrderList.isEmpty()) {
+            Set<String> orderIds = deliveryOrderList.stream().map(e -> e.getId()).collect(Collectors.toSet());
+            List<DeliveryOrderItems> items = deliveryOrderItemsService.getDeliveryOrderItemsVoList(orderIds);
+            List<DeliveryOrderItemsVo> deliveryOrderItemsVos = MyModelUtil.copyCollectionTo(items, DeliveryOrderItemsVo.class);
+            //做成map,方便匹配
+            Map<String, List<DeliveryOrderItemsVo>> collect1 = deliveryOrderItemsVos.stream().collect(Collectors.groupingBy(DeliveryOrderItemsVo::getOrderId));
+            MyPageData<DeliveryOrderVo> pageData = MyPageUtil.makeResponseData(deliveryOrderList, DeliveryOrderVo.class);
+            pageData.getDataList().forEach(e -> {
+                e.setItemList(collect1.get(e.getId()));
+            });
+            List<DeliveryOrderVo> dataList = pageData.getDataList();
+            dataList.sort(new Comparator<DeliveryOrderVo>() {
+                @Override
+                public int compare(DeliveryOrderVo o1, DeliveryOrderVo o2) {
+                    int compareTo = o2.getCreateTime().compareTo(o1.getCreateTime());
+                    return compareTo;
+                }
+            });
+            pageData.setDataList(dataList);
+            return ResponseResult.success(pageData);
+
+        }
+        MyPageData<DeliveryOrderVo> pageData = new MyPageData<>();
+        pageData.setDataList(new ArrayList<>());
+        pageData.setTotalCount(0l);
         return ResponseResult.success(pageData);
     }