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

主题推荐算法重设计

parent c6722016
...@@ -178,7 +178,7 @@ public class ThemeManager { ...@@ -178,7 +178,7 @@ public class ThemeManager {
if (ThemeListTypeEnum.RECOMMEND.getCode().equals(req.getType())) { if (ThemeListTypeEnum.RECOMMEND.getCode().equals(req.getType())) {
//推荐 //推荐
List<String> recommendThemeIds = recommendService.getRecommendThemes(req.getLastId(), req.getPageSize(), userId); List<String> recommendThemeIds = recommendService.getRecommendThemes(req.getLastId(), req.getPageSize(), userId);
themeEntities = themeService.queryByThemeIdsExcludeUser(recommendThemeIds, null, req.getLastId(), req.getPageSize()); themeEntities = themeService.queryByThemeIds(recommendThemeIds);
themeEntities = RankUtils.sortThemeEntityByIds(themeEntities, recommendThemeIds); themeEntities = RankUtils.sortThemeEntityByIds(themeEntities, recommendThemeIds);
} else if (ThemeListTypeEnum.FOLLOW.getCode().equals(req.getType())) { } else if (ThemeListTypeEnum.FOLLOW.getCode().equals(req.getType())) {
......
...@@ -67,8 +67,8 @@ public class RecommendService { ...@@ -67,8 +67,8 @@ public class RecommendService {
List<String> result = new ArrayList<>(); List<String> result = new ArrayList<>();
getResultList(hotThemeIds, 0, newThemeIds, 0, recThemeIds, 0, returnedIds, result, pageSize); getResultList(hotThemeIds, 0, newThemeIds, 0, recThemeIds, 0, returnedIds, result, pageSize);
returnedIdsMap.put(userId,returnedIds);
return result; return result.stream().limit(pageSize).collect(Collectors.toList());
} }
public List<ThemeAnalysDO> getRecentThemeList() { public List<ThemeAnalysDO> getRecentThemeList() {
......
...@@ -7,7 +7,6 @@ import com.tanpu.common.redis.RedisHelper; ...@@ -7,7 +7,6 @@ import com.tanpu.common.redis.RedisHelper;
import com.tanpu.common.uuid.UuidGenHelper; import com.tanpu.common.uuid.UuidGenHelper;
import com.tanpu.community.api.enums.DeleteTagEnum; import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.api.enums.ReportStatusEnum; import com.tanpu.community.api.enums.ReportStatusEnum;
import com.tanpu.community.cache.RedisCache;
import com.tanpu.community.dao.entity.community.ThemeEntity; import com.tanpu.community.dao.entity.community.ThemeEntity;
import com.tanpu.community.dao.mapper.community.ThemeMapper; import com.tanpu.community.dao.mapper.community.ThemeMapper;
import com.tanpu.community.util.TimeUtils; import com.tanpu.community.util.TimeUtils;
...@@ -19,14 +18,11 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -19,14 +18,11 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.tanpu.community.api.constants.RedisKeyConstant.THEME_APPEAR_IN_SEARCH_LIST;
@Service @Service
public class ThemeService { public class ThemeService {
...@@ -200,6 +196,9 @@ public class ThemeService { ...@@ -200,6 +196,9 @@ public class ThemeService {
return themeMapper.selectList(queryWrapper); return themeMapper.selectList(queryWrapper);
} }
/** /**
* 根据话题查询最新主题(可分页) * 根据话题查询最新主题(可分页)
* *
......
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