From 461cfaa18ed0542e70795a65d0fa62c32fc61b79 Mon Sep 17 00:00:00 2001 From: hupeng Date: Tue, 24 Sep 2019 18:31:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E8=AF=A6=E6=83=85=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-api/pom.xml | 30 +++++++++++++++++++ .../app/common/config/MybatisPlusConfig.java | 2 +- .../shop/controller/MallController.java | 5 +++- .../shop/service/impl/GoodsServiceImpl.java | 18 ++++++++--- .../service/impl/StoreGoodsServiceImpl.java | 1 - 5 files changed, 49 insertions(+), 7 deletions(-) diff --git a/ruoyi-api/pom.xml b/ruoyi-api/pom.xml index 84f8312..0911520 100644 --- a/ruoyi-api/pom.xml +++ b/ruoyi-api/pom.xml @@ -158,5 +158,35 @@ + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + + repackage + + + + + + org.apache.maven.plugins + maven-war-plugin + 3.0.0 + + false + ${artifactId} + + + + ${artifactId} + + + \ No newline at end of file diff --git a/ruoyi-api/src/main/java/com/ruoyi/app/common/config/MybatisPlusConfig.java b/ruoyi-api/src/main/java/com/ruoyi/app/common/config/MybatisPlusConfig.java index f5dd42e..67a0a37 100644 --- a/ruoyi-api/src/main/java/com/ruoyi/app/common/config/MybatisPlusConfig.java +++ b/ruoyi-api/src/main/java/com/ruoyi/app/common/config/MybatisPlusConfig.java @@ -11,7 +11,7 @@ import org.springframework.context.annotation.Configuration; * */ @Configuration -@MapperScan(basePackages = {"com.ruoyi.app.common.persistence.dao"}) +//@MapperScan(basePackages = {"com.ruoyi.app.common.persistence.dao"}) public class MybatisPlusConfig { /** diff --git a/ruoyi-api/src/main/java/com/ruoyi/app/modular/shop/controller/MallController.java b/ruoyi-api/src/main/java/com/ruoyi/app/modular/shop/controller/MallController.java index b2a5b62..644b05e 100644 --- a/ruoyi-api/src/main/java/com/ruoyi/app/modular/shop/controller/MallController.java +++ b/ruoyi-api/src/main/java/com/ruoyi/app/modular/shop/controller/MallController.java @@ -81,14 +81,17 @@ public class MallController { @GetMapping("/shop/mall-goods-detail") @ApiOperation(value = "商品详情",notes = "商品详情") public R goodsDetail(@RequestParam(value = "goods_id",defaultValue = "0") int goodsId){ + int userId = userOperator.getUser().getId(); Map specPrice = goodsService.goodsSpecPrice(goodsId); GoodsDTO goodsDetail = goodsMapper.toDto(goodsService.getById(goodsId)); - Map specs = goodsService.goodsSpec(goodsId); + Map> specs = goodsService.goodsSpec(goodsId); + boolean isCollect = goodsService.isCollect(goodsId,userId); Map map = new HashMap<>(); map.put("detail",goodsDetail); map.put("spec_price",specPrice); map.put("specs",specs); + map.put("isCollect",isCollect); return R.success(map); } diff --git a/ruoyi-api/src/main/java/com/ruoyi/app/modular/shop/service/impl/GoodsServiceImpl.java b/ruoyi-api/src/main/java/com/ruoyi/app/modular/shop/service/impl/GoodsServiceImpl.java index 3a0b48d..c10d78d 100644 --- a/ruoyi-api/src/main/java/com/ruoyi/app/modular/shop/service/impl/GoodsServiceImpl.java +++ b/ruoyi-api/src/main/java/com/ruoyi/app/modular/shop/service/impl/GoodsServiceImpl.java @@ -133,18 +133,28 @@ public class GoodsServiceImpl extends ServiceImpl return listMap; } - public Map goodsSpec(int goodsId){ + public Map> goodsSpec(int goodsId){ String keys = storeSpecGoodsPriceMapper.goodsSpecKey(goodsId); String[] strArr = keys.split("_"); - Map itemMap = new HashMap<>(); - List items = storeSpecGoodsPriceMapper.goodsSpec(Arrays.asList(strArr)); + Map> itemMap = new HashMap<>(); + List items = storeSpecGoodsPriceMapper + .goodsSpec(Arrays.asList(strArr)); + + List listItem = null; for (ItemDTO itemDTO : items) { SpecItemDTO specItemDTO = new SpecItemDTO(); specItemDTO.setItemId(itemDTO.getId()); specItemDTO.setItem(itemDTO.getItem()); - itemMap.put(itemDTO.getName(),specItemDTO); + + if(!itemMap.containsKey(itemDTO.getName())){ + listItem = new ArrayList<>(); + } + listItem.add(specItemDTO); + + itemMap.put(itemDTO.getName(),listItem); } + System.out.println(itemMap); return itemMap; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/shop/service/impl/StoreGoodsServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/shop/service/impl/StoreGoodsServiceImpl.java index 10b6e48..07b9d9a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/shop/service/impl/StoreGoodsServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/shop/service/impl/StoreGoodsServiceImpl.java @@ -55,7 +55,6 @@ public class StoreGoodsServiceImpl implements IStoreGoodsService for(Map.Entry> entry : specDataMap.entrySet()){ String mapKey = entry.getKey(); Map map = entry.getValue(); - //System.out.println(mapKey+":"+map); storeSpecGoodsPrice.setKey(mapKey); // List storeSpecGoodsPrices = storeSpecGoodsPriceService // .selectStoreSpecGoodsPriceList(storeSpecGoodsPrice);