Commit 16b5ae0a authored by 刘基明's avatar 刘基明

我的帖子列表按照收藏时间排序

parent eed45154
......@@ -69,7 +69,7 @@ public class CommentManager {
List<CommentEntity> commentEntities = commentService.selectByThemeId(themeId);
List<CommentQo> commentQos = ConvertUtil.commentEntity2Qos(commentEntities);
Set<String> likeCommentList = collectionService.getListByUser(userId, CollectionTypeEnum.LIKE_COMMENT);
Set<String> likeCommentList = collectionService.getSetByUser(userId, CollectionTypeEnum.LIKE_COMMENT);
for (CommentQo commentQo : commentQos) {
//查询用户信息
......
......@@ -313,12 +313,15 @@ public class ThemeManager {
List<ThemeQo> commentThemeList = getCommentThemeQos(req, userId);
return commentThemeList;
case 3://点赞
Set<String> likeThemeIds = collectionService.getListByUser(req.getUserId(), CollectionTypeEnum.LIKE_THEME);
themeEntities = themeService.queryByThemeIds(new ArrayList<>(likeThemeIds), req.getLastId(), req.getPageSize());
List<String> likeThemeIds = collectionService.getListByUser(req.getUserId(), CollectionTypeEnum.LIKE_THEME);
themeEntities = themeService.queryByThemeIds(likeThemeIds, req.getLastId(), req.getPageSize());
themeEntities = RankUtils.sortThemeEntityByIds(themeEntities, likeThemeIds);
break;
case 4://收藏
Set<String> collectThemeIds = collectionService.getListByUser(req.getUserId(), CollectionTypeEnum.COLLECT_THEME);
themeEntities = themeService.queryByThemeIds(new ArrayList<>(collectThemeIds), req.getLastId(), req.getPageSize());
List<String> collectThemeIds = collectionService.getListByUser(req.getUserId(), CollectionTypeEnum.COLLECT_THEME);
themeEntities = themeService.queryByThemeIds(collectThemeIds, req.getLastId(), req.getPageSize());
themeEntities = RankUtils.sortThemeEntityByIds(themeEntities, collectThemeIds);
break;
}
List<ThemeQo> themeQos = convertEntityToQo(themeEntities, userId);
......
......@@ -66,7 +66,7 @@ public class CollectionService {
}
// 根据用户id和行为type获取target_id列表
public Set<String> getListByUser(String userId, CollectionTypeEnum type) {
public Set<String> getSetByUser(String userId, CollectionTypeEnum type) {
return collectionMapper.selectList(new LambdaQueryWrapper<CollectionEntity>()
.eq(CollectionEntity::getUserId, userId)
.eq(CollectionEntity::getCollectionType, type.getCode())
......@@ -74,6 +74,15 @@ public class CollectionService {
.stream().map(CollectionEntity::getTargetId).collect(Collectors.toSet());
}
// 根据用户id和行为type获取target_id列表
public List<String> getListByUser(String userId, CollectionTypeEnum type) {
return collectionMapper.selectList(new LambdaQueryWrapper<CollectionEntity>()
.eq(CollectionEntity::getUserId, userId)
.eq(CollectionEntity::getCollectionType, type.getCode())
.eq(CollectionEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode()))
.stream().map(CollectionEntity::getTargetId).collect(Collectors.toList());
}
// 统计单个对象(主题、评论)的数量(点赞、收藏)
public Integer getCountByTypeAndId(String targetId, CollectionTypeEnum type) {
......
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