From 5ffea937314d9cb7b5a5a4fdb7f2acb5a6dfa0b8 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 28 Jun 2023 00:25:44 +0800 Subject: [PATCH] =?UTF-8?q?mall=20+=20product=EF=BC=9A=201=E3=80=81?= =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=95=86=E5=93=81=E8=AF=84=E8=AE=BA=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E7=9A=84=20mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/app/comment/AppProductCommentController.java | 2 +- .../app/comment/vo/AppCommentStatisticsRespVO.java | 6 +++--- .../product/convert/comment/ProductCommentConvert.java | 3 +-- .../product/service/comment/ProductCommentServiceImpl.java | 4 +--- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppProductCommentController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppProductCommentController.java index f13ab1e9e..1bcd4a138 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppProductCommentController.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppProductCommentController.java @@ -85,7 +85,7 @@ public class AppProductCommentController { } // TODO 芋艿:需要搞下 - @GetMapping("/getCommentStatistics") + @GetMapping("/statistics") @Operation(summary = "获得商品的评价统计") public CommonResult getCommentStatistics(@Valid @RequestParam("spuId") Long spuId) { return success(productCommentService.getCommentStatistics(spuId, Boolean.TRUE)); diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentStatisticsRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentStatisticsRespVO.java index 4e2a14a8d..e863ab02c 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentStatisticsRespVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentStatisticsRespVO.java @@ -9,9 +9,6 @@ import lombok.ToString; @ToString(callSuper = true) public class AppCommentStatisticsRespVO { - @Schema(description = "所有评论数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721") - private Long allCount; - @Schema(description = "好评数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721") private Long goodCount; @@ -21,4 +18,7 @@ public class AppCommentStatisticsRespVO { @Schema(description = "差评数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721") private Long negativeCount; + @Schema(description = "总平均分", requiredMode = Schema.RequiredMode.REQUIRED, example = "3.55") + private Double scores; + } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/comment/ProductCommentConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/comment/ProductCommentConvert.java index 14cc34e6a..170a3f0f4 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/comment/ProductCommentConvert.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/comment/ProductCommentConvert.java @@ -33,11 +33,10 @@ public interface ProductCommentConvert { ProductCommentRespVO convert(ProductCommentDO bean); // TODO @puhui999:这里貌似字段对上,就不用 mapping 了;可以测试下看看哈 - @Mapping(target = "allCount", source = "allCount") @Mapping(target = "goodCount", source = "goodCount") @Mapping(target = "mediocreCount", source = "mediocreCount") @Mapping(target = "negativeCount", source = "negativeCount") - AppCommentStatisticsRespVO convert(Long allCount, Long goodCount, Long mediocreCount, Long negativeCount); + AppCommentStatisticsRespVO convert(Long goodCount, Long mediocreCount, Long negativeCount); List convertList(List list); diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImpl.java index d35d7ce20..b0822e96c 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImpl.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImpl.java @@ -135,15 +135,13 @@ public class ProductCommentServiceImpl implements ProductCommentService { @Override public AppCommentStatisticsRespVO getCommentStatistics(Long spuId, Boolean visible) { return ProductCommentConvert.INSTANCE.convert( - // 查询商品 id = spuId 的所有评论数量 - productCommentMapper.selectCountBySpuId(spuId, visible, null), // 查询商品 id = spuId 的所有好评数量 productCommentMapper.selectCountBySpuId(spuId, visible, AppCommentPageReqVO.GOOD_COMMENT), // 查询商品 id = spuId 的所有中评数量 productCommentMapper.selectCountBySpuId(spuId, visible, AppCommentPageReqVO.MEDIOCRE_COMMENT), // 查询商品 id = spuId 的所有差评数量 productCommentMapper.selectCountBySpuId(spuId, visible, AppCommentPageReqVO.NEGATIVE_COMMENT) - ); + ).setScores(3.0); // TODO @puhui999:这里要实现下;; } @Override