mall + product:

1、完善商品评论列表的 mock
This commit is contained in:
YunaiV 2023-06-28 00:25:44 +08:00
parent 846405d8b1
commit 5ffea93731
4 changed files with 6 additions and 9 deletions

View File

@ -85,7 +85,7 @@ public class AppProductCommentController {
} }
// TODO 芋艿需要搞下 // TODO 芋艿需要搞下
@GetMapping("/getCommentStatistics") @GetMapping("/statistics")
@Operation(summary = "获得商品的评价统计") @Operation(summary = "获得商品的评价统计")
public CommonResult<AppCommentStatisticsRespVO> getCommentStatistics(@Valid @RequestParam("spuId") Long spuId) { public CommonResult<AppCommentStatisticsRespVO> getCommentStatistics(@Valid @RequestParam("spuId") Long spuId) {
return success(productCommentService.getCommentStatistics(spuId, Boolean.TRUE)); return success(productCommentService.getCommentStatistics(spuId, Boolean.TRUE));

View File

@ -9,9 +9,6 @@ import lombok.ToString;
@ToString(callSuper = true) @ToString(callSuper = true)
public class AppCommentStatisticsRespVO { public class AppCommentStatisticsRespVO {
@Schema(description = "所有评论数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721")
private Long allCount;
@Schema(description = "好评数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721") @Schema(description = "好评数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721")
private Long goodCount; private Long goodCount;
@ -21,4 +18,7 @@ public class AppCommentStatisticsRespVO {
@Schema(description = "差评数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721") @Schema(description = "差评数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721")
private Long negativeCount; private Long negativeCount;
@Schema(description = "总平均分", requiredMode = Schema.RequiredMode.REQUIRED, example = "3.55")
private Double scores;
} }

View File

@ -33,11 +33,10 @@ public interface ProductCommentConvert {
ProductCommentRespVO convert(ProductCommentDO bean); ProductCommentRespVO convert(ProductCommentDO bean);
// TODO @puhui999这里貌似字段对上就不用 mapping 可以测试下看看哈 // TODO @puhui999这里貌似字段对上就不用 mapping 可以测试下看看哈
@Mapping(target = "allCount", source = "allCount")
@Mapping(target = "goodCount", source = "goodCount") @Mapping(target = "goodCount", source = "goodCount")
@Mapping(target = "mediocreCount", source = "mediocreCount") @Mapping(target = "mediocreCount", source = "mediocreCount")
@Mapping(target = "negativeCount", source = "negativeCount") @Mapping(target = "negativeCount", source = "negativeCount")
AppCommentStatisticsRespVO convert(Long allCount, Long goodCount, Long mediocreCount, Long negativeCount); AppCommentStatisticsRespVO convert(Long goodCount, Long mediocreCount, Long negativeCount);
List<ProductCommentRespVO> convertList(List<ProductCommentDO> list); List<ProductCommentRespVO> convertList(List<ProductCommentDO> list);

View File

@ -135,15 +135,13 @@ public class ProductCommentServiceImpl implements ProductCommentService {
@Override @Override
public AppCommentStatisticsRespVO getCommentStatistics(Long spuId, Boolean visible) { public AppCommentStatisticsRespVO getCommentStatistics(Long spuId, Boolean visible) {
return ProductCommentConvert.INSTANCE.convert( return ProductCommentConvert.INSTANCE.convert(
// 查询商品 id = spuId 的所有评论数量
productCommentMapper.selectCountBySpuId(spuId, visible, null),
// 查询商品 id = spuId 的所有好评数量 // 查询商品 id = spuId 的所有好评数量
productCommentMapper.selectCountBySpuId(spuId, visible, AppCommentPageReqVO.GOOD_COMMENT), productCommentMapper.selectCountBySpuId(spuId, visible, AppCommentPageReqVO.GOOD_COMMENT),
// 查询商品 id = spuId 的所有中评数量 // 查询商品 id = spuId 的所有中评数量
productCommentMapper.selectCountBySpuId(spuId, visible, AppCommentPageReqVO.MEDIOCRE_COMMENT), productCommentMapper.selectCountBySpuId(spuId, visible, AppCommentPageReqVO.MEDIOCRE_COMMENT),
// 查询商品 id = spuId 的所有差评数量 // 查询商品 id = spuId 的所有差评数量
productCommentMapper.selectCountBySpuId(spuId, visible, AppCommentPageReqVO.NEGATIVE_COMMENT) productCommentMapper.selectCountBySpuId(spuId, visible, AppCommentPageReqVO.NEGATIVE_COMMENT)
); ).setScores(3.0); // TODO @puhui999这里要实现下
} }
@Override @Override