From 1690d4d06b0c20b3606e50e0844ef67e07947a0d Mon Sep 17 00:00:00 2001 From: phpcjl <phpcjl@gmail.com> Date: 星期二, 10 十二月 2024 14:05:59 +0800 Subject: [PATCH] 1. --- 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