Commit 89bd0b57 by 段启岩

话题贡献者列表重新排序

parent 48adc132
...@@ -35,6 +35,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; ...@@ -35,6 +35,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.elasticsearch.common.recycler.Recycler;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -555,6 +556,12 @@ public class TopicServiceImpl extends ServiceImpl<TopicMapper, Topic> implements ...@@ -555,6 +556,12 @@ public class TopicServiceImpl extends ServiceImpl<TopicMapper, Topic> implements
IPage<String> userIdPage = topicMapper.selectTopicContributeIdPage(new Page<>(pageNumber, pageSize), topicId); IPage<String> userIdPage = topicMapper.selectTopicContributeIdPage(new Page<>(pageNumber, pageSize), topicId);
List<String> userIds = userIdPage.getRecords(); List<String> userIds = userIdPage.getRecords();
int index = 0;
Map<String, Integer> userIdSortMap = new HashMap<>(userIds.size());
for (int i = 0; i < userIds.size(); i++) {
userIdSortMap.put(userIds.get(i), i);
}
PageDTO<UserFollowDTO> userFollowDTOPage = new PageDTO<>(); PageDTO<UserFollowDTO> userFollowDTOPage = new PageDTO<>();
PageUtils.copyMeta(userIdPage, userFollowDTOPage); PageUtils.copyMeta(userIdPage, userFollowDTOPage);
if (!CollectionUtils.isEmpty(userIds)) { if (!CollectionUtils.isEmpty(userIds)) {
...@@ -569,6 +576,15 @@ public class TopicServiceImpl extends ServiceImpl<TopicMapper, Topic> implements ...@@ -569,6 +576,15 @@ public class TopicServiceImpl extends ServiceImpl<TopicMapper, Topic> implements
userFollowDTO.setFollowedUser(false); userFollowDTO.setFollowedUser(false);
}); });
} }
// 对列表进行重新排序
Collections.sort(userInfoDTOList, new Comparator<UserFollowDTO>() {
@Override
public int compare(UserFollowDTO o1, UserFollowDTO o2) {
return userIdSortMap.get(o1.getUserId()) - userIdSortMap.get(o2.getUserId());
}
});
userFollowDTOPage.setDataList(userInfoDTOList); userFollowDTOPage.setDataList(userInfoDTOList);
} else { } else {
userFollowDTOPage.setDataList(List.of()); userFollowDTOPage.setDataList(List.of());
......
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