mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-18 21:10:57 +08:00
Enhance user timeline post metadata and grouping
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.openisle.dto;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
/** Lightweight post metadata used in user profile lists. */
|
||||
@@ -11,6 +12,8 @@ public class PostMetaDto {
|
||||
private String title;
|
||||
private String snippet;
|
||||
private LocalDateTime createdAt;
|
||||
private String category;
|
||||
private CategoryDto category;
|
||||
private List<TagDto> tags;
|
||||
private long views;
|
||||
private long commentCount;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.openisle.model.Comment;
|
||||
import com.openisle.model.Post;
|
||||
import com.openisle.model.User;
|
||||
import com.openisle.service.*;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.security.core.Authentication;
|
||||
@@ -23,6 +24,8 @@ public class UserMapper {
|
||||
private final PostReadService postReadService;
|
||||
private final LevelService levelService;
|
||||
private final MedalService medalService;
|
||||
private final CategoryMapper categoryMapper;
|
||||
private final TagMapper tagMapper;
|
||||
|
||||
@Value("${app.snippet-length}")
|
||||
private int snippetLength;
|
||||
@@ -88,8 +91,10 @@ public class UserMapper {
|
||||
dto.setSnippet(content);
|
||||
}
|
||||
dto.setCreatedAt(post.getCreatedAt());
|
||||
dto.setCategory(post.getCategory().getName());
|
||||
dto.setCategory(categoryMapper.toDto(post.getCategory()));
|
||||
dto.setTags(post.getTags().stream().map(tagMapper::toDto).collect(Collectors.toList()));
|
||||
dto.setViews(post.getViews());
|
||||
dto.setCommentCount(post.getCommentCount());
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user