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

排序优化

parent aa1ddd34
...@@ -16,6 +16,6 @@ import java.util.List; ...@@ -16,6 +16,6 @@ import java.util.List;
* @since 2021-07-22 * @since 2021-07-22
*/ */
public interface TopicMapper extends BaseMapper<TopicEntity> { public interface TopicMapper extends BaseMapper<TopicEntity> {
@Select("select * from topic where id>#{startId} and delete_tag=0 and is_conceal=0 order by id desc limit #{size}") @Select("select * from topic where id>#{startId} and delete_tag=0 and is_conceal=0 order by id asc limit #{size}")
List<TopicEntity> selectGtIdPageable(@Param("startId") Long startId, @Param("size") Integer size); List<TopicEntity> selectGtIdPageable(@Param("startId") Long startId, @Param("size") Integer size);
} }
...@@ -187,8 +187,7 @@ public class RankService { ...@@ -187,8 +187,7 @@ public class RankService {
} }
// 记录排序前最新的2个话题
List<TopicRankQo> newest2Topic = topicRankQos.stream().filter(TopicRankQo::judgeNewTopic).limit(2).collect(Collectors.toList());
// 排序 // 排序
List<TopicRankQo> rankList = topicRankQos.stream() List<TopicRankQo> rankList = topicRankQos.stream()
...@@ -201,6 +200,9 @@ public class RankService { ...@@ -201,6 +200,9 @@ public class RankService {
this.rankTopicList = rankList; this.rankTopicList = rankList;
// 首页推荐话题 // 首页推荐话题
// 记录排序前最新的2个话题
List<TopicRankQo> newest2Topic = topicRankQos.stream().filter(TopicRankQo::judgeNewTopic)
.sorted(Comparator.comparing(TopicRankQo::getMinutesTillNow)).limit(2).collect(Collectors.toList());
List<TopicRankQo> top4Topic = rankList.stream() List<TopicRankQo> top4Topic = rankList.stream()
.limit(6) .limit(6)
......
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