mirror of
				https://github.com/YunaiV/ruoyi-vue-pro.git
				synced 2025-10-31 10:37:41 +08:00 
			
		
		
		
	fix:移动 app 商品评论分页相关常量到 AppCommentPageReqVO 中
This commit is contained in:
		| @ -14,6 +14,51 @@ import javax.validation.constraints.NotNull; | |||||||
| @ToString(callSuper = true) | @ToString(callSuper = true) | ||||||
| public class AppCommentPageReqVO extends PageParam { | 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") |     @Schema(description = "商品SPU编号", example = "29502") | ||||||
|     @NotNull(message = "商品SPU编号不能为空") |     @NotNull(message = "商品SPU编号不能为空") | ||||||
|     private Long spuId; |     private Long spuId; | ||||||
|  | |||||||
| @ -28,51 +28,6 @@ import java.util.List; | |||||||
| @AllArgsConstructor | @AllArgsConstructor | ||||||
| public class ProductCommentDO extends BaseDO { | 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 = "匿名用户"; |  | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 评论编号,主键自增 |      * 评论编号,主键自增 | ||||||
|      */ |      */ | ||||||
|  | |||||||
| @ -37,17 +37,17 @@ public interface ProductCommentMapper extends BaseMapperX<ProductCommentDO> { | |||||||
|  |  | ||||||
|     static void appendTabQuery(LambdaQueryWrapperX<ProductCommentDO> queryWrapper, Integer type) { |     static void appendTabQuery(LambdaQueryWrapperX<ProductCommentDO> queryWrapper, Integer type) { | ||||||
|         // 构建好评查询语句 |         // 构建好评查询语句 | ||||||
|         if (ObjectUtil.equal(type, ProductCommentDO.FAVOURABLE_COMMENT)) { |         if (ObjectUtil.equal(type, AppCommentPageReqVO.FAVOURABLE_COMMENT)) { | ||||||
|             // 好评计算 (商品评分星级+服务评分星级) >= 8 |             // 好评计算 (商品评分星级+服务评分星级) >= 8 | ||||||
|             queryWrapper.apply("(scores + benefit_scores) >= 8"); |             queryWrapper.apply("(scores + benefit_scores) >= 8"); | ||||||
|         } |         } | ||||||
|         // 构建中评查询语句 |         // 构建中评查询语句 | ||||||
|         if (ObjectUtil.equal(type, ProductCommentDO.MEDIOCRE_COMMENT)) { |         if (ObjectUtil.equal(type, AppCommentPageReqVO.MEDIOCRE_COMMENT)) { | ||||||
|             // 中评计算 (商品评分星级+服务评分星级) > 4 且 (商品评分星级+服务评分星级) < 8 |             // 中评计算 (商品评分星级+服务评分星级) > 4 且 (商品评分星级+服务评分星级) < 8 | ||||||
|             queryWrapper.apply("(scores + benefit_scores) > 4 and (scores + benefit_scores) < 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 |             // 差评计算 (商品评分星级+服务评分星级) <= 4 | ||||||
|             queryWrapper.apply("(scores + benefit_scores) <= 4"); |             queryWrapper.apply("(scores + benefit_scores) <= 4"); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -73,13 +73,13 @@ public class ProductCommentServiceImpl implements ProductCommentService { | |||||||
|     public Map<String, Long> getCommentPageTabsCount(Long spuId, Boolean visible) { |     public Map<String, Long> getCommentPageTabsCount(Long spuId, Boolean visible) { | ||||||
|         Map<String, Long> countMap = new HashMap<>(4); |         Map<String, Long> countMap = new HashMap<>(4); | ||||||
|         // 查询商品 id = spuId 的所有评论数量 |         // 查询商品 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 的所有好评数量 |         // 查询商品 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 的所有中评数量 |         // 查询商品 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 的所有差评数量 |         // 查询商品 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; |         return countMap; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -89,7 +89,7 @@ public class ProductCommentServiceImpl implements ProductCommentService { | |||||||
|         result.getList().forEach(item -> { |         result.getList().forEach(item -> { | ||||||
|             // 判断用户是否选择匿名 |             // 判断用户是否选择匿名 | ||||||
|             if (ObjectUtil.equal(item.getAnonymous(), true)) { |             if (ObjectUtil.equal(item.getAnonymous(), true)) { | ||||||
|                 item.setUserNickname(ProductCommentDO.ANONYMOUS_NICKNAME); |                 item.setUserNickname(AppCommentPageReqVO.ANONYMOUS_NICKNAME); | ||||||
|             } |             } | ||||||
|             // 计算评价最终综合评分 最终星数 = (商品评星 + 服务评星) / 2 |             // 计算评价最终综合评分 最终星数 = (商品评星 + 服务评星) / 2 | ||||||
|             BigDecimal sumScore = new BigDecimal(item.getScores() + item.getBenefitScores()); |             BigDecimal sumScore = new BigDecimal(item.getScores() + item.getBenefitScores()); | ||||||
|  | |||||||
| @ -142,19 +142,19 @@ public class ProductCommentServiceImplTest extends BaseDbUnitTest { | |||||||
|         assertEquals(7, result1.getTotal()); |         assertEquals(7, result1.getTotal()); | ||||||
|  |  | ||||||
|         // 测试获取所有商品分页中评数据 |         // 测试获取所有商品分页中评数据 | ||||||
|         PageResult<AppCommentRespVO> result2 = productCommentService.getCommentPage(new AppCommentPageReqVO().setType(ProductCommentDO.MEDIOCRE_COMMENT), Boolean.TRUE); |         PageResult<AppCommentRespVO> result2 = productCommentService.getCommentPage(new AppCommentPageReqVO().setType(AppCommentPageReqVO.MEDIOCRE_COMMENT), Boolean.TRUE); | ||||||
|         assertEquals(2, result2.getTotal()); |         assertEquals(2, result2.getTotal()); | ||||||
|  |  | ||||||
|         // 测试获取指定 spuId 商品分页中评数据 |         // 测试获取指定 spuId 商品分页中评数据 | ||||||
|         PageResult<AppCommentRespVO> result3 = productCommentService.getCommentPage(new AppCommentPageReqVO().setSpuId(spuId).setType(ProductCommentDO.MEDIOCRE_COMMENT), Boolean.TRUE); |         PageResult<AppCommentRespVO> result3 = productCommentService.getCommentPage(new AppCommentPageReqVO().setSpuId(spuId).setType(AppCommentPageReqVO.MEDIOCRE_COMMENT), Boolean.TRUE); | ||||||
|         assertEquals(2, result3.getTotal()); |         assertEquals(2, result3.getTotal()); | ||||||
|  |  | ||||||
|         // 测试分页 tab count |         // 测试分页 tab count | ||||||
|         Map<String, Long> tabsCount = productCommentService.getCommentPageTabsCount(spuId, Boolean.TRUE); |         Map<String, Long> tabsCount = productCommentService.getCommentPageTabsCount(spuId, Boolean.TRUE); | ||||||
|         assertEquals(6, tabsCount.get(ProductCommentDO.ALL_COUNT)); |         assertEquals(6, tabsCount.get(AppCommentPageReqVO.ALL_COUNT)); | ||||||
|         assertEquals(4, tabsCount.get(ProductCommentDO.FAVOURABLE_COMMENT_COUNT)); |         assertEquals(4, tabsCount.get(AppCommentPageReqVO.FAVOURABLE_COMMENT_COUNT)); | ||||||
|         assertEquals(2, tabsCount.get(ProductCommentDO.MEDIOCRE_COMMENT_COUNT)); |         assertEquals(2, tabsCount.get(AppCommentPageReqVO.MEDIOCRE_COMMENT_COUNT)); | ||||||
|         assertEquals(0, tabsCount.get(ProductCommentDO.NEGATIVE_COMMENT_COUNT)); |         assertEquals(0, tabsCount.get(AppCommentPageReqVO.NEGATIVE_COMMENT_COUNT)); | ||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 puhui999
					puhui999