Commit 2ff9e636 authored by 刘基明's avatar 刘基明

关注列表fix

parent 145cccc1
......@@ -519,10 +519,10 @@ public class ThemeManager {
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()) {
// 说明是从头开始刷,则直接把最新的lastId放到redis中,保留一个月
......
......@@ -223,15 +223,15 @@ public class ThemeService {
* @param userIds
* @param pageStart
* @param pageSize
* @param userPermitTopics
* @param userFollowTopics
* @return
*/
public List<ThemeEntity> queryByUserIdsCreateDesc(List<String> userIds, Integer pageStart, Integer pageSize, Set<String> userPermitTopics) {
if (CollectionUtils.isEmpty(userIds) && CollectionUtils.isEmpty(userPermitTopics)) {
public List<ThemeEntity> queryByUserIdsCreateDesc(List<String> userIds, Integer pageStart, Integer pageSize, Set<String> userFollowTopics) {
if (CollectionUtils.isEmpty(userIds) && CollectionUtils.isEmpty(userFollowTopics)) {
return Collections.emptyList();
}
userPermitTopics.remove("");
return themeMapper.queryFollowList(userIds, userPermitTopics, pageStart, pageSize);
userFollowTopics.remove("");
return themeMapper.queryFollowList(userIds, userFollowTopics, pageStart, pageSize);
}
......
......@@ -165,6 +165,11 @@ public class TopicService {
}
}
/**
* 逐个校验是否有权限
* @param content
* @param userId
*/
public void batchCheckPermission(List<TopicRankQo> content, String userId) {
Set<String> userPermitTopics = getUserPermitTopics(userId);
content.forEach(o -> {
......@@ -339,6 +344,11 @@ public class TopicService {
}
/**
* 获取用户有权限的话题(专属的+所有的公开话题)
* @param userId
* @return
*/
public Set<String> getUserPermitTopics(String userId) {
// 公开权限的话题
List<TopicEntity> openTopics = topicMapper.selectList(new LambdaQueryWrapper<TopicEntity>()
......@@ -360,4 +370,19 @@ public class TopicService {
res.addAll(openTopicIds);
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