Commit a5c966b5 authored by 刘基明's avatar 刘基明

修复话题主题列表

parent 0e210072
...@@ -187,17 +187,24 @@ public class ThemeManager { ...@@ -187,17 +187,24 @@ public class ThemeManager {
public ThemeListResp queryThemes(ThemeListReq req, String userId) { public ThemeListResp queryThemes(ThemeListReq req, String userId) {
Integer pageStart = (req.page.pageNumber - 1) * req.page.pageSize; Integer pageStart = (req.page.pageNumber - 1) * req.page.pageSize;
Integer pageSize = req.page.pageSize; Integer pageSize = req.page.pageSize;
Integer realSize = req.page.pageSize * 2; Integer querySize = pageSize * 2;
List<ThemeEntity> themes = new ArrayList<>(); List<ThemeEntity> themes = new ArrayList<>();
if (ThemeListTypeEnum.RECOMMEND.getCode().equals(req.getType())) { if (ThemeListTypeEnum.RECOMMEND.getCode().equals(req.getType())) {
//推荐 //推荐
List<String> recmdIds = recommendService.getRecommendThemes(pageStart, realSize, userId); List<String> recmdIds = recommendService.getRecommendThemes(pageStart, querySize, userId);
//去重已看过(查看正文) //去重已看过(查看正文)
recmdIds = visitSummaryService.filterUserNotVisited(userId, recmdIds); recmdIds = visitSummaryService.filterUserNotVisited(userId, recmdIds);
themes = themeService.queryByThemeIds(recmdIds); themes = themeService.queryByThemeIds(recmdIds);
themes = RankUtils.sortThemeEntityByIds(themes, recmdIds); themes = RankUtils.sortThemeEntityByIds(themes, recmdIds);
// filter用户自己的
themes = themes.stream().filter(t -> {
return !userId.equals(t.getAuthorId()) && !req.excludeIds.contains(t.getThemeId());
}).collect(Collectors.toList());
// todo pageNo pageSize
themes = BizUtils.subList(themes, 0, req.page.pageSize);
} else if (ThemeListTypeEnum.FOLLOW.getCode().equals(req.getType())) { } else if (ThemeListTypeEnum.FOLLOW.getCode().equals(req.getType())) {
//TODO 临时埋点,接入新埋点后删除 //TODO 临时埋点,接入新埋点后删除
if (CollectionUtils.isEmpty(req.getExcludeIds())) { if (CollectionUtils.isEmpty(req.getExcludeIds())) {
...@@ -224,12 +231,6 @@ public class ThemeManager { ...@@ -224,12 +231,6 @@ public class ThemeManager {
themes = themeService.queryNewestByTopic(req.topicId, req.page.pageNumber, pageSize); themes = themeService.queryNewestByTopic(req.topicId, req.page.pageNumber, pageSize);
} }
// filter用户自己的
themes = themes.stream().filter(t -> {
return !userId.equals(t.getAuthorId()) && !req.excludeIds.contains(t.getThemeId());
}).collect(Collectors.toList());
// todo pageNo pageSize
themes = BizUtils.subList(themes, 0, req.page.pageSize);
ThemeListResp resp = new ThemeListResp(); ThemeListResp resp = new ThemeListResp();
resp.excludeIds = req.excludeIds; resp.excludeIds = req.excludeIds;
...@@ -277,7 +278,7 @@ public class ThemeManager { ...@@ -277,7 +278,7 @@ public class ThemeManager {
private void buildThemeExtraInfoByUser(String userId, ThemeQo themeQo) { private void buildThemeExtraInfoByUser(String userId, ThemeQo themeQo) {
String themeId = themeQo.getThemeId(); String themeId = themeQo.getThemeId();
//是否关注作者 //是否关注作者
themeQo.setFollow(followRelService.checkFollow(themeQo.getAuthorId(),userId)); themeQo.setFollow(followRelService.checkFollow(themeQo.getAuthorId(), userId));
//是否点赞 //是否点赞
CollectionEntity likeEntity = collectionService.getNotDeleteTargetCollection(themeId, userId, CollectionTypeEnum.LIKE_THEME); CollectionEntity likeEntity = collectionService.getNotDeleteTargetCollection(themeId, userId, CollectionTypeEnum.LIKE_THEME);
themeQo.setHasLiked(likeEntity != null); themeQo.setHasLiked(likeEntity != null);
...@@ -466,7 +467,7 @@ public class ThemeManager { ...@@ -466,7 +467,7 @@ public class ThemeManager {
List<CommentEntity> commentEntities = commentService.queryCommentsByUserId(req.getUserId(), req.getLastId(), req.getPageSize()); List<CommentEntity> commentEntities = commentService.queryCommentsByUserId(req.getUserId(), req.getLastId(), req.getPageSize());
//当前用户信息 //当前用户信息
UserInfoNew userInfo = redisCache.getObject(StringUtils.joinWith(CACHE_FEIGN_USER_INFO, req.getUserId()), UserInfoNew userInfo = redisCache.getObject(StringUtils.joinWith(CACHE_FEIGN_USER_INFO, req.getUserId()),
60 * 10, () ->this.getUserInfo(req.getUserId()) , UserInfoNew.class); 60 * 10, () -> this.getUserInfo(req.getUserId()), UserInfoNew.class);
Set<String> replyThemeIds = commentEntities.stream().map(CommentEntity::getThemeId).collect(Collectors.toSet()); Set<String> replyThemeIds = commentEntities.stream().map(CommentEntity::getThemeId).collect(Collectors.toSet());
if (CollectionUtils.isEmpty(replyThemeIds)) { if (CollectionUtils.isEmpty(replyThemeIds)) {
return commentThemeList; return commentThemeList;
...@@ -500,12 +501,12 @@ public class ThemeManager { ...@@ -500,12 +501,12 @@ public class ThemeManager {
.content(Collections.singletonList(commentContent)) .content(Collections.singletonList(commentContent))
.commentId(commentEntity.getCommentId()) .commentId(commentEntity.getCommentId())
.themeType(ThemeTypeEnum.RES_COMMENT.getCode()) .themeType(ThemeTypeEnum.RES_COMMENT.getCode())
.follow(followRelService.checkFollow(userId,userId)) .follow(followRelService.checkFollow(userId, userId))
.build(); .build();
//原主题包装到formerThemeQo中 //原主题包装到formerThemeQo中
ThemeQo themeQo = themeMap.get(themeId); ThemeQo themeQo = themeMap.get(themeId);
if (themeQo!=null){ if (themeQo != null) {
FormerThemeQo f = ConvertUtil.themeQo2FormerThemeQo(themeQo); FormerThemeQo f = ConvertUtil.themeQo2FormerThemeQo(themeQo);
commentThemeQo.setFormerTheme(f); commentThemeQo.setFormerTheme(f);
} }
...@@ -515,7 +516,7 @@ public class ThemeManager { ...@@ -515,7 +516,7 @@ public class ThemeManager {
} }
private UserInfoNew getUserInfo(String authorId){ private UserInfoNew getUserInfo(String authorId) {
CommonResp<UserInfoNew> userInfoNewCommonResp = feignClientForFatools.queryUsersListNew(authorId); CommonResp<UserInfoNew> userInfoNewCommonResp = feignClientForFatools.queryUsersListNew(authorId);
if (userInfoNewCommonResp.isNotSuccess()) { if (userInfoNewCommonResp.isNotSuccess()) {
throw new BizException("内部接口调用失败"); throw new BizException("内部接口调用失败");
......
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