Bläddra i källkod

Fix bug, check idList if empty while find in repo

xuchaolang 6 år sedan
förälder
incheckning
56ef2ae8da

+ 13 - 10
rankin-product-service/src/main/java/cn/rankin/productservice/service/app/ItemService.java

@@ -91,22 +91,25 @@ public class ItemService {
             for (SupportReference supportReference : supportReferenceList) {
                 supportIdList.add(supportReference.getTid());
             }
+
             if (!CollectionUtils.isEmpty(supportIdList)) {
                 List<MerchantProduct> merchantProductList = merchantProductRepository.findByPidsAndMerchantId(supportIdList, merchantId);
                 List<String> idList = new ArrayList<>();
                 merchantProductList.forEach(item -> idList.add(item.getPid()));
-                List<Support> supportList = supportRepository.findByIds(idList, BaseStatusEnum.NORMAL);
-                Map<String, Support> supportMap = ListUtil.convert(supportList, "id", Support.class);
-                List<ItemVo> itemVoList = new ArrayList<>();
-                for (String itemId : supportIdList) {
-                    Support item = supportMap.get(itemId);
-                    if (item == null) {
-                        continue;
+                if (!idList.isEmpty()) {
+                    List<Support> supportList = supportRepository.findByIds(idList, BaseStatusEnum.NORMAL);
+                    Map<String, Support> supportMap = ListUtil.convert(supportList, "id", Support.class);
+                    List<ItemVo> itemVoList = new ArrayList<>();
+                    for (String itemId : supportIdList) {
+                        Support item = supportMap.get(itemId);
+                        if (item == null) {
+                            continue;
+                        }
+                        ItemVo itemVo = convert(item);
+                        itemVoList.add(itemVo);
                     }
-                    ItemVo itemVo = convert(item);
-                    itemVoList.add(itemVo);
+                    supportItemVo.setRelatedSupports(itemVoList);
                 }
-                supportItemVo.setRelatedSupports(itemVoList);
             }
         }