Commit 5ffea937314d9cb7b5a5a4fdb7f2acb5a6dfa0b8

Authored by YunaiV
1 parent 846405d8

mall + product:

1、完善商品评论列表的 mock
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 { @@ -85,7 +85,7 @@ public class AppProductCommentController {
85 } 85 }
86 86
87 // TODO 芋艿:需要搞下 87 // TODO 芋艿:需要搞下
88 - @GetMapping("/getCommentStatistics") 88 + @GetMapping("/statistics")
89 @Operation(summary = "获得商品的评价统计") 89 @Operation(summary = "获得商品的评价统计")
90 public CommonResult<AppCommentStatisticsRespVO> getCommentStatistics(@Valid @RequestParam("spuId") Long spuId) { 90 public CommonResult<AppCommentStatisticsRespVO> getCommentStatistics(@Valid @RequestParam("spuId") Long spuId) {
91 return success(productCommentService.getCommentStatistics(spuId, Boolean.TRUE)); 91 return success(productCommentService.getCommentStatistics(spuId, Boolean.TRUE));
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; @@ -9,9 +9,6 @@ import lombok.ToString;
9 @ToString(callSuper = true) 9 @ToString(callSuper = true)
10 public class AppCommentStatisticsRespVO { 10 public class AppCommentStatisticsRespVO {
11 11
12 - @Schema(description = "所有评论数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721")  
13 - private Long allCount;  
14 -  
15 @Schema(description = "好评数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721") 12 @Schema(description = "好评数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721")
16 private Long goodCount; 13 private Long goodCount;
17 14
@@ -21,4 +18,7 @@ public class AppCommentStatisticsRespVO { @@ -21,4 +18,7 @@ public class AppCommentStatisticsRespVO {
21 @Schema(description = "差评数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721") 18 @Schema(description = "差评数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721")
22 private Long negativeCount; 19 private Long negativeCount;
23 20
  21 + @Schema(description = "总平均分", requiredMode = Schema.RequiredMode.REQUIRED, example = "3.55")
  22 + private Double scores;
  23 +
24 } 24 }
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 { @@ -33,11 +33,10 @@ public interface ProductCommentConvert {
33 ProductCommentRespVO convert(ProductCommentDO bean); 33 ProductCommentRespVO convert(ProductCommentDO bean);
34 34
35 // TODO @puhui999:这里貌似字段对上,就不用 mapping 了;可以测试下看看哈 35 // TODO @puhui999:这里貌似字段对上,就不用 mapping 了;可以测试下看看哈
36 - @Mapping(target = "allCount", source = "allCount")  
37 @Mapping(target = "goodCount", source = "goodCount") 36 @Mapping(target = "goodCount", source = "goodCount")
38 @Mapping(target = "mediocreCount", source = "mediocreCount") 37 @Mapping(target = "mediocreCount", source = "mediocreCount")
39 @Mapping(target = "negativeCount", source = "negativeCount") 38 @Mapping(target = "negativeCount", source = "negativeCount")
40 - AppCommentStatisticsRespVO convert(Long allCount, Long goodCount, Long mediocreCount, Long negativeCount); 39 + AppCommentStatisticsRespVO convert(Long goodCount, Long mediocreCount, Long negativeCount);
41 40
42 List<ProductCommentRespVO> convertList(List<ProductCommentDO> list); 41 List<ProductCommentRespVO> convertList(List<ProductCommentDO> list);
43 42
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 { @@ -135,15 +135,13 @@ public class ProductCommentServiceImpl implements ProductCommentService {
135 @Override 135 @Override
136 public AppCommentStatisticsRespVO getCommentStatistics(Long spuId, Boolean visible) { 136 public AppCommentStatisticsRespVO getCommentStatistics(Long spuId, Boolean visible) {
137 return ProductCommentConvert.INSTANCE.convert( 137 return ProductCommentConvert.INSTANCE.convert(
138 - // 查询商品 id = spuId 的所有评论数量  
139 - productCommentMapper.selectCountBySpuId(spuId, visible, null),  
140 // 查询商品 id = spuId 的所有好评数量 138 // 查询商品 id = spuId 的所有好评数量
141 productCommentMapper.selectCountBySpuId(spuId, visible, AppCommentPageReqVO.GOOD_COMMENT), 139 productCommentMapper.selectCountBySpuId(spuId, visible, AppCommentPageReqVO.GOOD_COMMENT),
142 // 查询商品 id = spuId 的所有中评数量 140 // 查询商品 id = spuId 的所有中评数量
143 productCommentMapper.selectCountBySpuId(spuId, visible, AppCommentPageReqVO.MEDIOCRE_COMMENT), 141 productCommentMapper.selectCountBySpuId(spuId, visible, AppCommentPageReqVO.MEDIOCRE_COMMENT),
144 // 查询商品 id = spuId 的所有差评数量 142 // 查询商品 id = spuId 的所有差评数量
145 productCommentMapper.selectCountBySpuId(spuId, visible, AppCommentPageReqVO.NEGATIVE_COMMENT) 143 productCommentMapper.selectCountBySpuId(spuId, visible, AppCommentPageReqVO.NEGATIVE_COMMENT)
146 - ); 144 + ).setScores(3.0); // TODO @puhui999:这里要实现下;;
147 } 145 }
148 146
149 @Override 147 @Override