Commit 5609bb9d authored by 刘基明's avatar 刘基明

转赞评批量查询

parent 4a3fa523
...@@ -49,4 +49,7 @@ public class CourseSimpleResp { ...@@ -49,4 +49,7 @@ public class CourseSimpleResp {
@ApiModelProperty("状态 0:待上架 1:上架 2:下架") @ApiModelProperty("状态 0:待上架 1:上架 2:下架")
private Integer status; private Integer status;
@ApiModelProperty("付费模式 1:免费 2:积分 3:现金")
private Integer modal;
} }
...@@ -11,6 +11,6 @@ public class TimesCountEntity { ...@@ -11,6 +11,6 @@ public class TimesCountEntity {
@ApiModelProperty(value = "次数") @ApiModelProperty(value = "次数")
private Integer times; private Integer times;
@ApiModelProperty(value = "目标id") @ApiModelProperty(value = "统计对象id")
private String id; private String id;
} }
...@@ -555,11 +555,12 @@ public class ThemeManager { ...@@ -555,11 +555,12 @@ public class ThemeManager {
List<ThemeQo> themeQos = ConvertUtil.themeEntitiesToDTOs(themeEntities); List<ThemeQo> themeQos = ConvertUtil.themeEntitiesToDTOs(themeEntities);
// 批量查询附件detail // 批量查询附件detail
batchFeignCallService.getAttachDetailByBatch(themeQos); batchFeignCallService.getAttachDetailByBatch(themeQos);
//其他信息 // 转赞评
for (ThemeQo themeQO : themeQos) { batchBuildThemeCountInfo(themeQos);
// 通用信息
buildThemeQoExtraInfo(themeQO);
// 转发对象
for (ThemeQo themeQO : themeQos) {
buildThemeForwardObj(themeQO);
} }
// 和用户相关信息 // 和用户相关信息
if (StringUtils.isNotEmpty(userId)) { if (StringUtils.isNotEmpty(userId)) {
...@@ -568,15 +569,19 @@ public class ThemeManager { ...@@ -568,15 +569,19 @@ public class ThemeManager {
return themeQos; return themeQos;
} }
// 转发对象、点赞、收藏、转发数 // 转发对象
private void buildThemeQoExtraInfo(ThemeQo themeQo) { private void buildThemeForwardObj(ThemeQo themeQo) {
String themeId = themeQo.getThemeId(); String themeId = themeQo.getThemeId();
// 封装转发对象 // 封装转发对象
FormerThemeQo former = redisCache.getObject(StringUtils.joinWith("_", CACHE_FORWARD_THEME_ID, themeQo.getFormerThemeId()), 60, FormerThemeQo former = redisCache.getObject(StringUtils.joinWith("_", CACHE_FORWARD_THEME_ID, themeQo.getFormerThemeId()), 60,
() -> this.getFormerTheme(themeQo.getFormerThemeId()), FormerThemeQo.class); () -> this.getFormerTheme(themeQo.getFormerThemeId()), FormerThemeQo.class);
themeQo.setFormerTheme(former); themeQo.setFormerTheme(former);
}
// 单个查询 点赞、收藏、转发数
private void buildThemeCountInfo(ThemeQo themeQo) {
String themeId = themeQo.getThemeId();
// 点赞,收藏,转发 // 点赞,收藏,转发
Integer likeCount = redisCache.getObject(StringUtils.joinWith("_", THEME_LIKE_COUNT, themeId), 60, Integer likeCount = redisCache.getObject(StringUtils.joinWith("_", THEME_LIKE_COUNT, themeId), 60,
() -> collectionService.getCountByTypeAndId(themeId, CollectionTypeEnum.LIKE_THEME), Integer.class); () -> collectionService.getCountByTypeAndId(themeId, CollectionTypeEnum.LIKE_THEME), Integer.class);
...@@ -586,11 +591,28 @@ public class ThemeManager { ...@@ -586,11 +591,28 @@ public class ThemeManager {
Integer forwardCount = redisCache.getObject(StringUtils.joinWith("_", THEME_FORWARD_COUNT, themeId), 60, Integer forwardCount = redisCache.getObject(StringUtils.joinWith("_", THEME_FORWARD_COUNT, themeId), 60,
() -> themeService.getForwardCountById(themeId), Integer.class); () -> themeService.getForwardCountById(themeId), Integer.class);
themeQo.setCommentCount(commentCount); themeQo.setCommentCount(commentCount);
themeQo.setLikeCount(likeCount); themeQo.setLikeCount(likeCount);
themeQo.setForwardCount(forwardCount); themeQo.setForwardCount(forwardCount);
} }
// 批量-点赞、收藏、转发数
private void batchBuildThemeCountInfo(List<ThemeQo> themeQos) {
List<String> themeIds = themeQos.stream().map(ThemeQo::getThemeId).collect(Collectors.toList());
// 点赞,收藏,转发
Map<String, Integer> likeCountMap = collectionService.getCountMapByType(themeIds, CollectionTypeEnum.LIKE_THEME);
Map<String, Integer> commentCountMap = commentService.getCountMapByThemeIds(themeIds);
Map<String, Integer> forwardCountMap = themeService.getForwardCountMap(themeIds);
themeQos.stream().forEach(o->{
o.setCommentCount(commentCountMap.getOrDefault(o.getThemeId(),0));
o.setLikeCount(likeCountMap.getOrDefault(o.getThemeId(),0));
o.setForwardCount(forwardCountMap.getOrDefault(o.getThemeId(),0));
});
}
// 组装和当前用户相关信息(单个查询) // 组装和当前用户相关信息(单个查询)
private void buildThemeExtraInfoByUser(String userId, ThemeQo themeQo) { private void buildThemeExtraInfoByUser(String userId, ThemeQo themeQo) {
String themeId = themeQo.getThemeId(); String themeId = themeQo.getThemeId();
...@@ -688,7 +710,8 @@ public class ThemeManager { ...@@ -688,7 +710,8 @@ public class ThemeManager {
batchFeignCallService.getAttachDetail(themeQo); batchFeignCallService.getAttachDetail(themeQo);
//转发、收藏、点赞 //转发、收藏、点赞
buildThemeQoExtraInfo(themeQo); buildThemeForwardObj(themeQo);
buildThemeCountInfo(themeQo);
// 添加用户相关信息 // 添加用户相关信息
if (StringUtils.isNotEmpty(userId)) { if (StringUtils.isNotEmpty(userId)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment