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

关注话题排序

parent 8577e00c
...@@ -45,6 +45,9 @@ public class TopicFollowQo { ...@@ -45,6 +45,9 @@ public class TopicFollowQo {
@ApiModelProperty(value = "最近一条讨论") @ApiModelProperty(value = "最近一条讨论")
public String lastTheme; public String lastTheme;
@ApiModelProperty(value = "最近一条讨论发表时间")
public long lastThemeSecond;
@ApiModelProperty(value = "最近一条讨论发表时间-格式化") @ApiModelProperty(value = "最近一条讨论发表时间-格式化")
public String lastThemeTime; public String lastThemeTime;
......
...@@ -111,7 +111,7 @@ public class TopicManager { ...@@ -111,7 +111,7 @@ public class TopicManager {
// 排序 // 排序
List<TopicFollowQo> res = topicFollowQos.stream().filter(o -> o.checkTopicName(keyword)).sorted(Comparator.comparing(TopicFollowQo::getSpecialPermission, Comparator.reverseOrder()). List<TopicFollowQo> res = topicFollowQos.stream().filter(o -> o.checkTopicName(keyword)).sorted(Comparator.comparing(TopicFollowQo::getSpecialPermission, Comparator.reverseOrder()).
thenComparing(TopicFollowQo::getLastThemeTime, Comparator.nullsFirst(String::compareTo).reversed())) thenComparing(TopicFollowQo::getLastThemeSecond, Comparator.nullsFirst(Long::compareTo).reversed()))
.collect(Collectors.toList()); .collect(Collectors.toList());
return res; return res;
......
...@@ -31,6 +31,7 @@ import org.springframework.stereotype.Service; ...@@ -31,6 +31,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.ZoneOffset;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
...@@ -361,6 +362,7 @@ public class ThemeService { ...@@ -361,6 +362,7 @@ public class ThemeService {
topic.setLastTheme(getUserName(themeQo.getAuthorId()) + ":" + themeQo.content.get(0).getValue()); topic.setLastTheme(getUserName(themeQo.getAuthorId()) + ":" + themeQo.content.get(0).getValue());
topic.setLastThemeTime(TimeUtils.formatTopicListTime(themeEntity.getUpdateTime())); topic.setLastThemeTime(TimeUtils.formatTopicListTime(themeEntity.getUpdateTime()));
topic.setLastThemeSecond(themeEntity.getUpdateTime().toEpochSecond(ZoneOffset.of("+8")));
} }
......
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