From 5728732f45cc45f3c5cbde0abe7a7c5efee605b9 Mon Sep 17 00:00:00 2001
From: luodangjia <luodangjia>
Date: 星期一, 09 十二月 2024 15:31:05 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java
index a299b54..7176262 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java
@@ -19,6 +19,7 @@
 import com.ruoyi.other.vo.GoodsVO;
 import com.ruoyi.system.api.model.LoginUser;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
@@ -103,19 +104,22 @@
         }
 
         Goods goods = this.getById(goodsId);
-
-        List<GoodsShop> goodsShopList = goodsShopMapper.selectList(new LambdaQueryWrapper<GoodsShop>()
-                .eq(GoodsShop::getGoodsId, goodsId));
-        List<Integer> shopIds = goodsShopList.stream().map(GoodsShop::getShopId).collect(Collectors.toList());
-        List<Shop> shopList = shopMapper.selectList(new LambdaQueryWrapper<Shop>()
-                .in(Shop::getId, shopIds));
         GoodsVO goodsVO = new GoodsVO();
-        goodsVO.setShopList(shopList);
         BeanUtils.copyBeanProp(goodsVO, goods);
         goodsVO.setGoodsId(goods.getId());
         goodsVO.setGoodsName(goods.getName());
         goodsVO.setSellingPrice(sellingPrice);
         goodsVO.setIntegral(integral);
+
+        List<GoodsShop> goodsShopList = goodsShopMapper.selectList(new LambdaQueryWrapper<GoodsShop>()
+                .eq(GoodsShop::getGoodsId, goodsId));
+        if (!CollectionUtils.isEmpty(goodsShopList)){
+            List<Integer> shopIds = goodsShopList.stream().map(GoodsShop::getShopId).collect(Collectors.toList());
+            List<Shop> shopList = shopMapper.selectList(new LambdaQueryWrapper<Shop>()
+                    .in(Shop::getId, shopIds));
+
+            goodsVO.setShopList(shopList);
+        }
         return goodsVO;
     }
 

--
Gitblit v1.7.1