Commit 35e14333 authored by 张辰's avatar 张辰

Merge branch 'v2.3.1' of http://47.100.44.39:10001/tp-backend/tanpu-community into v2.3.1

parents b6111c09 f09ab871
...@@ -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;
......
...@@ -528,10 +528,10 @@ public class ThemeManager { ...@@ -528,10 +528,10 @@ public class ThemeManager {
fansList.add(userId); // 保证fansList不为空 fansList.add(userId); // 保证fansList不为空
// 权限控制,筛选出当前用户关注的话题 // 权限控制,筛选出当前用户关注的话题
Set<String> userPermitTopics = topicService.getUserPermitTopics(userId); Set<String> userFollowTopics = topicService.getUserFollowTopics(userId);
// 查库 // 查库
themes = themeService.queryByUserIdsCreateDesc(fansList, pageStart, pageSize, userPermitTopics); themes = themeService.queryByUserIdsCreateDesc(fansList, pageStart, pageSize, userFollowTopics);
if (CollectionUtils.isEmpty(excludeIds) && !themes.isEmpty()) { if (CollectionUtils.isEmpty(excludeIds) && !themes.isEmpty()) {
// 说明是从头开始刷,则直接把最新的lastId放到redis中,保留一个月 // 说明是从头开始刷,则直接把最新的lastId放到redis中,保留一个月
......
...@@ -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;
...@@ -223,15 +224,15 @@ public class ThemeService { ...@@ -223,15 +224,15 @@ public class ThemeService {
* @param userIds * @param userIds
* @param pageStart * @param pageStart
* @param pageSize * @param pageSize
* @param userPermitTopics * @param userFollowTopics
* @return * @return
*/ */
public List<ThemeEntity> queryByUserIdsCreateDesc(List<String> userIds, Integer pageStart, Integer pageSize, Set<String> userPermitTopics) { public List<ThemeEntity> queryByUserIdsCreateDesc(List<String> userIds, Integer pageStart, Integer pageSize, Set<String> userFollowTopics) {
if (CollectionUtils.isEmpty(userIds) && CollectionUtils.isEmpty(userPermitTopics)) { if (CollectionUtils.isEmpty(userIds) && CollectionUtils.isEmpty(userFollowTopics)) {
return Collections.emptyList(); return Collections.emptyList();
} }
userPermitTopics.remove(""); userFollowTopics.remove("");
return themeMapper.queryFollowList(userIds, userPermitTopics, pageStart, pageSize); return themeMapper.queryFollowList(userIds, userFollowTopics, pageStart, pageSize);
} }
...@@ -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")));
} }
......
...@@ -169,6 +169,11 @@ public class TopicService { ...@@ -169,6 +169,11 @@ public class TopicService {
} }
} }
/**
* 逐个校验是否有权限
* @param content
* @param userId
*/
public void batchCheckPermission(List<TopicRankQo> content, String userId) { public void batchCheckPermission(List<TopicRankQo> content, String userId) {
Set<String> userPermitTopics = getUserPermitTopics(userId); Set<String> userPermitTopics = getUserPermitTopics(userId);
content.forEach(o -> { content.forEach(o -> {
...@@ -343,6 +348,11 @@ public class TopicService { ...@@ -343,6 +348,11 @@ public class TopicService {
} }
/**
* 获取用户有权限的话题(专属的+所有的公开话题)
* @param userId
* @return
*/
public Set<String> getUserPermitTopics(String userId) { public Set<String> getUserPermitTopics(String userId) {
// 公开权限的话题 // 公开权限的话题
List<TopicEntity> openTopics = topicMapper.selectList(new LambdaQueryWrapper<TopicEntity>() List<TopicEntity> openTopics = topicMapper.selectList(new LambdaQueryWrapper<TopicEntity>()
...@@ -364,4 +374,19 @@ public class TopicService { ...@@ -364,4 +374,19 @@ public class TopicService {
res.addAll(openTopicIds); res.addAll(openTopicIds);
return res; return res;
} }
/**
* 获取用户关注的话题(专属的+关注的公开话题)
* @param userId
* @return
*/
public Set<String> getUserFollowTopics(String userId) {
if (StringUtils.isBlank(userId)) {
return new HashSet<>();
}
// 拥有权限的话题
List<String> followTopics = topicFollowRelMapper.selectTopicIdByUserId(userId);
HashSet<String> res = new HashSet<>(followTopics);
return res;
}
} }
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