From 05e7606755e7956ad8c6ae73cc54785c7c50c37e Mon Sep 17 00:00:00 2001 From: Gadfly Date: Mon, 16 Aug 2021 15:42:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=A0=B9=E6=8D=AEsku=E6=9F=A5=E6=89=BE?= =?UTF-8?q?=E5=95=86=E5=93=81=EF=BC=8C=E7=94=A8=E4=BA=8E=E8=B4=AD=E7=89=A9?= =?UTF-8?q?=E8=BD=A6=E3=80=81=E8=AE=A2=E5=8D=95=E8=B7=B3=E8=BD=AC=E5=95=86?= =?UTF-8?q?=E5=93=81=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mall/pms/controller/app/GoodsController.java | 9 ++++++++- .../com/youlai/mall/pms/serviceapp/IGoodsService.java | 2 ++ .../mall/pms/serviceapp/impl/GoodsServiceImpl.java | 11 +++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/GoodsController.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/GoodsController.java index 24d3c837a..8a1bc14b5 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/GoodsController.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/GoodsController.java @@ -55,7 +55,6 @@ public class GoodsController { return Result.success(list, pageResult.getTotal()); } - @ApiOperation(value = "商品详情") @ApiImplicitParam(name = "id", value = "商品ID", required = true, paramType = "path", dataType = "Long") @GetMapping("/{id}") @@ -63,4 +62,12 @@ public class GoodsController { GoodsDetailVO goodsDetailVO = goodsService.getGoodsById(id); return Result.success(goodsDetailVO); } + + @ApiOperation(value = "商品详情") + @ApiImplicitParam(name = "id", value = "商品SkuID", required = true, paramType = "path", dataType = "Long") + @GetMapping("/sku/{skuId}") + public Result detailBySkuId(@PathVariable Long skuId) { + GoodsDetailVO goodsDetailVO = goodsService.getGoodsBySkuId(skuId); + return Result.success(goodsDetailVO); + } } diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/serviceapp/IGoodsService.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/serviceapp/IGoodsService.java index dfb1a88d8..f3e473f8d 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/serviceapp/IGoodsService.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/serviceapp/IGoodsService.java @@ -10,4 +10,6 @@ import com.youlai.mall.pms.pojo.vo.app.GoodsDetailVO; */ public interface IGoodsService extends IService { GoodsDetailVO getGoodsById(Long id); + + GoodsDetailVO getGoodsBySkuId(Long skuId); } diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/serviceapp/impl/GoodsServiceImpl.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/serviceapp/impl/GoodsServiceImpl.java index b35b1cd77..0d9897f8c 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/serviceapp/impl/GoodsServiceImpl.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/serviceapp/impl/GoodsServiceImpl.java @@ -7,6 +7,7 @@ import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.youlai.common.web.exception.BizException; import com.youlai.mall.pms.common.enums.AttributeTypeEnum; import com.youlai.mall.pms.mapper.PmsSpuMapper; import com.youlai.mall.pms.pojo.entity.PmsSku; @@ -112,4 +113,14 @@ public class GoodsServiceImpl extends ServiceImpl implemen } return goodsDetailVO; } + + @Override + public GoodsDetailVO getGoodsBySkuId(Long skuId) { + PmsSku skuInfo = skuService.getById(skuId); + if (null == skuInfo) { + throw new BizException("商品不存在"); + } + Long spuId = skuInfo.getSpuId(); + return getGoodsById(spuId); + } }