Implement profile page and related backend APIs

This commit is contained in:
Tim
2025-07-09 13:40:54 +08:00
parent d9322307fe
commit 37d1f2ab70
8 changed files with 198 additions and 106 deletions

View File

@@ -101,4 +101,8 @@ public class CommentService {
Pageable pageable = PageRequest.of(0, limit);
return commentRepository.findByAuthorOrderByCreatedAtDesc(user, pageable);
}
public java.util.List<Comment> getCommentsByIds(java.util.List<Long> ids) {
return commentRepository.findAllById(ids);
}
}

View File

@@ -136,6 +136,15 @@ public class PostService {
return postRepository.findByAuthorAndStatusOrderByCreatedAtDesc(user, PostStatus.PUBLISHED, pageable);
}
public java.time.LocalDateTime getLastPostTime(String username) {
return postRepository.findLastPostTime(username);
}
public long getTotalViews(String username) {
Long v = postRepository.sumViews(username);
return v != null ? v : 0;
}
public List<Post> listPostsByTags(java.util.List<Long> tagIds,
Integer page,
Integer pageSize) {
@@ -180,4 +189,8 @@ public class PostService {
notificationService.createNotification(post.getAuthor(), NotificationType.POST_REVIEWED, post, null, false);
return post;
}
public java.util.List<Post> getPostsByIds(java.util.List<Long> ids) {
return postRepository.findAllById(ids);
}
}

View File

@@ -69,4 +69,12 @@ public class ReactionService {
.orElseThrow(() -> new IllegalArgumentException("Comment not found"));
return reactionRepository.findByComment(comment);
}
public java.util.List<Long> topPostIds(String username, int limit) {
return reactionRepository.findTopPostIds(username, org.springframework.data.domain.PageRequest.of(0, limit));
}
public java.util.List<Long> topCommentIds(String username, int limit) {
return reactionRepository.findTopCommentIds(username, org.springframework.data.domain.PageRequest.of(0, limit));
}
}