11package com .back .domain .post .comment .controller ;
22
33import com .back .domain .post .comment .dto .request .CommentCreateRequestDto ;
4+ import com .back .domain .post .comment .dto .request .CommentUpdateRequestDto ;
45import com .back .domain .post .comment .dto .response .CommentResponseDto ;
56import com .back .domain .post .comment .service .CommentService ;
7+ import com .back .domain .post .post .dto .request .PostUpdateRequestDto ;
68import com .back .domain .post .post .dto .response .PostResponseDto ;
79import com .back .global .rsData .RsData ;
810import io .swagger .v3 .oas .annotations .Operation ;
1113import java .util .List ;
1214import lombok .RequiredArgsConstructor ;
1315import org .springframework .web .bind .annotation .GetMapping ;
16+ import org .springframework .web .bind .annotation .PatchMapping ;
1417import org .springframework .web .bind .annotation .PathVariable ;
1518import org .springframework .web .bind .annotation .PostMapping ;
1619import org .springframework .web .bind .annotation .RequestBody ;
@@ -41,6 +44,12 @@ public RsData<CommentResponseDto> createComment(
4144 return RsData .successOf (commentService .createComment (postId , reqBody )); // code=200, message="success"
4245 }
4346
47+ /**
48+ * 댓글 다건 조회 API
49+ * @param postId 댓글이 작성된 게시글 ID
50+ * @param lastId 마지막으로 조회한 댓글 ID (페이징 처리용, optional)
51+ * @return 댓글 목록
52+ */
4453 @ GetMapping
4554 @ Operation (summary = "댓글 다건 조회" )
4655 public RsData <List <CommentResponseDto >> getComments (
@@ -50,6 +59,12 @@ public RsData<List<CommentResponseDto>> getComments(
5059 return RsData .successOf (commentService .getComments (postId , lastId )); // code=200, message="success"
5160 }
5261
62+ /**
63+ * 댓글 단건 조회 API
64+ * @param postId 댓글이 작성된 게시글 ID
65+ * @param commentId 조회할 댓글 ID
66+ * @return 해당 ID의 댓글 정보
67+ */
5368 @ GetMapping ("/{commentId}" )
5469 @ Operation (summary = "댓글 단건 조회" )
5570 public RsData <CommentResponseDto > getComment (
@@ -58,4 +73,21 @@ public RsData<CommentResponseDto> getComment(
5873 ) {
5974 return RsData .successOf (commentService .getComment (postId , commentId )); // code=200, message="success"
6075 }
76+
77+ /**
78+ * 댓글 수정 API
79+ * @param postId 댓글이 작성된 게시글 ID
80+ * @param commentId 수정할 댓글 ID
81+ * @param reqBody 댓글 수정 요청 DTO
82+ * @return 수정된 댓글 정보
83+ */
84+ @ PatchMapping ("/{commentId}" )
85+ @ Operation (summary = "댓글 수정" )
86+ public RsData <CommentResponseDto > updateComment (
87+ @ PathVariable Long postId ,
88+ @ PathVariable Long commentId ,
89+ @ Valid @ RequestBody CommentUpdateRequestDto reqBody
90+ ) {
91+ return RsData .successOf (commentService .updateComment (postId , commentId , reqBody )); // code=200, message="success"
92+ }
6193}
0 commit comments