Commit 9c7bc12b authored by 刘基明's avatar 刘基明

主题推荐算法重设计

parent fa48c452
......@@ -180,7 +180,6 @@ public class ThemeManager {
List<String> recommendThemeIds = recommendService.getRecommendThemes(req.getLastId(), req.getPageSize(), userId);
themeEntities = themeService.queryByThemeIds(recommendThemeIds);
themeEntities = RankUtils.sortThemeEntityByIds(themeEntities, recommendThemeIds);
} else if (ThemeListTypeEnum.FOLLOW.getCode().equals(req.getType())) {
//关注
if (StringUtils.isEmpty(req.getLastId())) {
......@@ -197,6 +196,7 @@ public class ThemeManager {
themeEntities = themeService.queryByThemeIdsExcludeUser(rankThemeIds, null, req.getLastId(), req.getPageSize());
themeEntities = RankUtils.sortThemeEntityByIds(themeEntities, rankThemeIds);
} else if (ThemeListTypeEnum.TOPIC_LATEST.getCode().equals(req.getType())) {
//根据话题查询最新
if (StringUtils.isEmpty(req.getTopicId())) throw new BizException("TopicId为空");
......
......@@ -66,9 +66,17 @@ public class RecommendService {
Set<String> returnedIds = (StringUtils.isEmpty(lastId)) ? new HashSet<>() : returnedIdsMap.get(userId);
List<String> result = new ArrayList<>();
getResultList(hotThemeIds, 0, newThemeIds, 0, recThemeIds, 0, returnedIds, result, pageSize);
returnedIdsMap.put(userId,returnedIds);
return result.stream().limit(pageSize).collect(Collectors.toList());
result = result.stream().limit(pageSize).collect(Collectors.toList());
//记录已返回主题id
if(StringUtils.isEmpty(lastId)){
returnedIdsMap.put(userId,new HashSet<>(result));
}else {
HashSet<String> newSet = new HashSet<>();
newSet.addAll(returnedIdsMap.get(userId));
newSet.addAll(result);
returnedIdsMap.put(userId,newSet);
}
return result;
}
public List<ThemeAnalysDO> getRecentThemeList() {
......
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