debug de la requete GET http://localhost:8080/api/comments/posts/{post-id}
This commit is contained in:
parent
48427e757a
commit
0d59829eaf
@ -58,7 +58,7 @@ public class CommentController {
|
|||||||
@GetMapping("/posts/{post-id}")
|
@GetMapping("/posts/{post-id}")
|
||||||
public List<CommentWithAuthor> listCommentsByPostId(@PathVariable("post-id") Long postId) {
|
public List<CommentWithAuthor> listCommentsByPostId(@PathVariable("post-id") Long postId) {
|
||||||
postService.findById(postId).orElseThrow(() -> new NotFoundException("Post not found"));
|
postService.findById(postId).orElseThrow(() -> new NotFoundException("Post not found"));
|
||||||
return commentService.getCommentsByCommentId(postId);
|
return commentService.getCommentsByPostId(postId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/{id}")
|
@PutMapping("/{id}")
|
||||||
|
@ -28,9 +28,11 @@ public interface CommentRepository extends CrudRepository<Comment, Long> {
|
|||||||
" c.comment_date AS comment_date, " +
|
" c.comment_date AS comment_date, " +
|
||||||
" c.is_updated AS is_updated " +
|
" c.is_updated AS is_updated " +
|
||||||
" FROM comment c" +
|
" FROM comment c" +
|
||||||
"JOIN comment_association ca ON ca.post_fk = :postId " +
|
" JOIN comment_association ca ON ca.comment_fk = c.id" +
|
||||||
"JOIN author a ON ca.author_fk = a.id")
|
" JOIN post p ON p.id = ca.post_fk" +
|
||||||
List<CommentWithAuthor> getCommentsByCommentId(Long postId);
|
" JOIN author a ON ca.author_fk = a.id" +
|
||||||
|
" WHERE p.id = 3")
|
||||||
|
List<CommentWithAuthor> getCommentsByPostId(Long postId);
|
||||||
|
|
||||||
@Modifying
|
@Modifying
|
||||||
@Query("delete from comment_association where comment_fk = :commentId")
|
@Query("delete from comment_association where comment_fk = :commentId")
|
||||||
|
@ -33,8 +33,8 @@ public class CommentService {
|
|||||||
return commentRepository.findAll();
|
return commentRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<CommentWithAuthor> getCommentsByCommentId(Long commentId) {
|
public List<CommentWithAuthor> getCommentsByPostId(Long postId) {
|
||||||
return commentRepository.getCommentsByCommentId(commentId);
|
return commentRepository.getCommentsByPostId(postId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void associateCommentToPostAndAuthor(UUID authorId, Long postId, Long commentId) {
|
public void associateCommentToPostAndAuthor(UUID authorId, Long postId, Long commentId) {
|
||||||
|
Loading…
Reference in New Issue
Block a user