Expand post details with comments and reactions

This commit is contained in:
Tim
2025-06-30 20:43:48 +08:00
parent 25a9239cc7
commit eabae2eb5a
3 changed files with 94 additions and 0 deletions

View File

@@ -46,4 +46,16 @@ public class ReactionService {
reaction.setType(type);
return reactionRepository.save(reaction);
}
public java.util.List<Reaction> getReactionsForPost(Long postId) {
Post post = postRepository.findById(postId)
.orElseThrow(() -> new IllegalArgumentException("Post not found"));
return reactionRepository.findByPost(post);
}
public java.util.List<Reaction> getReactionsForComment(Long commentId) {
Comment comment = commentRepository.findById(commentId)
.orElseThrow(() -> new IllegalArgumentException("Comment not found"));
return reactionRepository.findByComment(comment);
}
}