From 91e357e59d3058217872c9ca9f2ad122ffaa7fef Mon Sep 17 00:00:00 2001 From: puhui999 Date: Thu, 8 Jun 2023 17:15:37 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E7=A7=BB=E5=8A=A8=20app=20?= =?UTF-8?q?=E5=95=86=E5=93=81=E8=AF=84=E8=AE=BA=E5=88=86=E9=A1=B5=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E5=B8=B8=E9=87=8F=E5=88=B0=20AppCommentPageReqVO=20?= =?UTF-8?q?=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/comment/vo/AppCommentPageReqVO.java | 45 +++++++++++++++++++ .../dataobject/comment/ProductCommentDO.java | 45 ------------------- .../mysql/comment/ProductCommentMapper.java | 6 +-- .../comment/ProductCommentServiceImpl.java | 10 ++--- .../ProductCommentServiceImplTest.java | 12 ++--- 5 files changed, 59 insertions(+), 59 deletions(-) diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentPageReqVO.java index fba8766243..8dbff09c38 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentPageReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentPageReqVO.java @@ -14,6 +14,51 @@ import javax.validation.constraints.NotNull; @ToString(callSuper = true) public class AppCommentPageReqVO extends PageParam { + /** + * 所有 + */ + public static final Integer ALL = 0; + + /** + * 所有数量 key + */ + public static final String ALL_COUNT = "allCount"; + + /** + * 好评 + */ + public static final Integer FAVOURABLE_COMMENT = 1; + + /** + * 好评数量 key + */ + public static final String FAVOURABLE_COMMENT_COUNT = "favourableCommentCount"; + + /** + * 中评 + */ + public static final Integer MEDIOCRE_COMMENT = 2; + + /** + * 中评数量 key + */ + public static final String MEDIOCRE_COMMENT_COUNT = "mediocreCommentCount"; + + /** + * 差评 + */ + public static final Integer NEGATIVE_COMMENT = 3; + + /** + * 差评数量 key + */ + public static final String NEGATIVE_COMMENT_COUNT = "negativeCommentCount"; + + /** + * 默认匿名昵称 + */ + public static final String ANONYMOUS_NICKNAME = "匿名用户"; + @Schema(description = "商品SPU编号", example = "29502") @NotNull(message = "商品SPU编号不能为空") private Long spuId; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java index d867b21287..6e0bd04fa3 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java @@ -28,51 +28,6 @@ import java.util.List; @AllArgsConstructor public class ProductCommentDO extends BaseDO { - /** - * 所有 - */ - public static final Integer ALL = 0; - - /** - * 所有数量 key - */ - public static final String ALL_COUNT = "allCount"; - - /** - * 好评 - */ - public static final Integer FAVOURABLE_COMMENT = 1; - - /** - * 好评数量 key - */ - public static final String FAVOURABLE_COMMENT_COUNT = "favourableCommentCount"; - - /** - * 中评 - */ - public static final Integer MEDIOCRE_COMMENT = 2; - - /** - * 中评数量 key - */ - public static final String MEDIOCRE_COMMENT_COUNT = "mediocreCommentCount"; - - /** - * 差评 - */ - public static final Integer NEGATIVE_COMMENT = 3; - - /** - * 差评数量 key - */ - public static final String NEGATIVE_COMMENT_COUNT = "negativeCommentCount"; - - /** - * 默认匿名昵称 - */ - public static final String ANONYMOUS_NICKNAME = "匿名用户"; - /** * 评论编号,主键自增 */ diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/comment/ProductCommentMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/comment/ProductCommentMapper.java index d836d0758b..b010167ccd 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/comment/ProductCommentMapper.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/comment/ProductCommentMapper.java @@ -37,17 +37,17 @@ public interface ProductCommentMapper extends BaseMapperX { static void appendTabQuery(LambdaQueryWrapperX queryWrapper, Integer type) { // 构建好评查询语句 - if (ObjectUtil.equal(type, ProductCommentDO.FAVOURABLE_COMMENT)) { + if (ObjectUtil.equal(type, AppCommentPageReqVO.FAVOURABLE_COMMENT)) { // 好评计算 (商品评分星级+服务评分星级) >= 8 queryWrapper.apply("(scores + benefit_scores) >= 8"); } // 构建中评查询语句 - if (ObjectUtil.equal(type, ProductCommentDO.MEDIOCRE_COMMENT)) { + if (ObjectUtil.equal(type, AppCommentPageReqVO.MEDIOCRE_COMMENT)) { // 中评计算 (商品评分星级+服务评分星级) > 4 且 (商品评分星级+服务评分星级) < 8 queryWrapper.apply("(scores + benefit_scores) > 4 and (scores + benefit_scores) < 8"); } // 构建差评查询语句 - if (ObjectUtil.equal(type, ProductCommentDO.NEGATIVE_COMMENT)) { + if (ObjectUtil.equal(type, AppCommentPageReqVO.NEGATIVE_COMMENT)) { // 差评计算 (商品评分星级+服务评分星级) <= 4 queryWrapper.apply("(scores + benefit_scores) <= 4"); } 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 0ec70a4e64..edec1c6517 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 @@ -73,13 +73,13 @@ public class ProductCommentServiceImpl implements ProductCommentService { public Map getCommentPageTabsCount(Long spuId, Boolean visible) { Map countMap = new HashMap<>(4); // 查询商品 id = spuId 的所有评论数量 - countMap.put(ProductCommentDO.ALL_COUNT, productCommentMapper.selectTabCount(spuId, visible, ProductCommentDO.ALL)); + countMap.put(AppCommentPageReqVO.ALL_COUNT, productCommentMapper.selectTabCount(spuId, visible, AppCommentPageReqVO.ALL)); // 查询商品 id = spuId 的所有好评数量 - countMap.put(ProductCommentDO.FAVOURABLE_COMMENT_COUNT, productCommentMapper.selectTabCount(spuId, visible, ProductCommentDO.FAVOURABLE_COMMENT)); + countMap.put(AppCommentPageReqVO.FAVOURABLE_COMMENT_COUNT, productCommentMapper.selectTabCount(spuId, visible, AppCommentPageReqVO.FAVOURABLE_COMMENT)); // 查询商品 id = spuId 的所有中评数量 - countMap.put(ProductCommentDO.MEDIOCRE_COMMENT_COUNT, productCommentMapper.selectTabCount(spuId, visible, ProductCommentDO.MEDIOCRE_COMMENT)); + countMap.put(AppCommentPageReqVO.MEDIOCRE_COMMENT_COUNT, productCommentMapper.selectTabCount(spuId, visible, AppCommentPageReqVO.MEDIOCRE_COMMENT)); // 查询商品 id = spuId 的所有差评数量 - countMap.put(ProductCommentDO.NEGATIVE_COMMENT_COUNT, productCommentMapper.selectTabCount(spuId, visible, ProductCommentDO.NEGATIVE_COMMENT)); + countMap.put(AppCommentPageReqVO.NEGATIVE_COMMENT_COUNT, productCommentMapper.selectTabCount(spuId, visible, AppCommentPageReqVO.NEGATIVE_COMMENT)); return countMap; } @@ -89,7 +89,7 @@ public class ProductCommentServiceImpl implements ProductCommentService { result.getList().forEach(item -> { // 判断用户是否选择匿名 if (ObjectUtil.equal(item.getAnonymous(), true)) { - item.setUserNickname(ProductCommentDO.ANONYMOUS_NICKNAME); + item.setUserNickname(AppCommentPageReqVO.ANONYMOUS_NICKNAME); } // 计算评价最终综合评分 最终星数 = (商品评星 + 服务评星) / 2 BigDecimal sumScore = new BigDecimal(item.getScores() + item.getBenefitScores()); diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImplTest.java b/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImplTest.java index 2b51f81d37..24d9120252 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImplTest.java +++ b/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImplTest.java @@ -142,19 +142,19 @@ public class ProductCommentServiceImplTest extends BaseDbUnitTest { assertEquals(7, result1.getTotal()); // 测试获取所有商品分页中评数据 - PageResult result2 = productCommentService.getCommentPage(new AppCommentPageReqVO().setType(ProductCommentDO.MEDIOCRE_COMMENT), Boolean.TRUE); + PageResult result2 = productCommentService.getCommentPage(new AppCommentPageReqVO().setType(AppCommentPageReqVO.MEDIOCRE_COMMENT), Boolean.TRUE); assertEquals(2, result2.getTotal()); // 测试获取指定 spuId 商品分页中评数据 - PageResult result3 = productCommentService.getCommentPage(new AppCommentPageReqVO().setSpuId(spuId).setType(ProductCommentDO.MEDIOCRE_COMMENT), Boolean.TRUE); + PageResult result3 = productCommentService.getCommentPage(new AppCommentPageReqVO().setSpuId(spuId).setType(AppCommentPageReqVO.MEDIOCRE_COMMENT), Boolean.TRUE); assertEquals(2, result3.getTotal()); // 测试分页 tab count Map tabsCount = productCommentService.getCommentPageTabsCount(spuId, Boolean.TRUE); - assertEquals(6, tabsCount.get(ProductCommentDO.ALL_COUNT)); - assertEquals(4, tabsCount.get(ProductCommentDO.FAVOURABLE_COMMENT_COUNT)); - assertEquals(2, tabsCount.get(ProductCommentDO.MEDIOCRE_COMMENT_COUNT)); - assertEquals(0, tabsCount.get(ProductCommentDO.NEGATIVE_COMMENT_COUNT)); + assertEquals(6, tabsCount.get(AppCommentPageReqVO.ALL_COUNT)); + assertEquals(4, tabsCount.get(AppCommentPageReqVO.FAVOURABLE_COMMENT_COUNT)); + assertEquals(2, tabsCount.get(AppCommentPageReqVO.MEDIOCRE_COMMENT_COUNT)); + assertEquals(0, tabsCount.get(AppCommentPageReqVO.NEGATIVE_COMMENT_COUNT)); }