2121import org .springframework .web .bind .annotation .RequestParam ;
2222import org .springframework .web .bind .annotation .RestController ;
2323
24+ import io .swagger .v3 .oas .annotations .Operation ;
25+ import io .swagger .v3 .oas .annotations .Parameter ;
26+ import io .swagger .v3 .oas .annotations .responses .ApiResponse ;
27+ import io .swagger .v3 .oas .annotations .tags .Tag ;
2428import jakarta .validation .Valid ;
2529import lombok .RequiredArgsConstructor ;
2630
2731@ RestController
2832@ RequestMapping ("/api/problems/{problemId}/discussions" )
33+ @ Tag (name = "Discussions" , description = "문제별 토론글 관리 API" )
2934@ RequiredArgsConstructor
3035public class DiscussionController {
3136
3237 private final DiscussionService discussionService ;
3338
39+ @ Operation (
40+ summary = "토론 생성" ,
41+ description = "주어진 문제 ID에 새로운 Discussion을 생성합니다." ,
42+ parameters = {
43+ @ Parameter (name = "problemId" , description = "문제 ID" , required = true )
44+ }
45+ )
46+ @ ApiResponse (responseCode = "201" , description = "생성된 DiscussionResponse 반환" )
3447 @ PostMapping
3548 public ResponseEntity <DiscussionResponse > createDiscussion (
3649 @ PathVariable Long problemId ,
@@ -42,6 +55,15 @@ public ResponseEntity<DiscussionResponse> createDiscussion(
4255 .body (discussionService .createDiscussion (problemId , request , authUser .getId ()));
4356 }
4457
58+ @ Operation (
59+ summary = "토론 목록 조회" ,
60+ description = "문제별 Discussion 목록을 정렬(sortBy) 및 페이징(pageable)하여 조회합니다. 로그인하지 않은 상태로도 조회할 수 있습니다." ,
61+ parameters = {
62+ @ Parameter (name = "problemId" , description = "문제 ID" , required = true ),
63+ @ Parameter (name = "sortBy" , description = "정렬 기준 (best, upvote, latest), best: upvote-downvote 순으로 정렬" , example = "best" , required = false )
64+ }
65+ )
66+ @ ApiResponse (responseCode = "200" , description = "토론 목록 조회 성공" )
4567 @ GetMapping
4668 public ResponseEntity <Page <DiscussionResponse >> getDiscussions (
4769 @ PathVariable Long problemId ,
@@ -57,6 +79,15 @@ public ResponseEntity<Page<DiscussionResponse>> getDiscussions(
5779 .body (discussionService .getDiscussions (problemId , sortBy , currentUserId , pageable ));
5880 }
5981
82+ @ Operation (
83+ summary = "토론 수정" ,
84+ description = "특정 Discussion을 수정합니다." ,
85+ parameters = {
86+ @ Parameter (name = "problemId" , description = "문제 ID" , required = true ),
87+ @ Parameter (name = "discussionId" , description = "토론 ID" , required = true )
88+ }
89+ )
90+ @ ApiResponse (responseCode = "200" , description = "수정된 DiscussionResponse 반환" )
6091 @ PutMapping ("/{discussionId}" )
6192 public ResponseEntity <DiscussionResponse > modifyDiscussion (
6293 @ PathVariable Long problemId ,
@@ -69,6 +100,15 @@ public ResponseEntity<DiscussionResponse> modifyDiscussion(
69100 .body (discussionService .modifyDiscussion (problemId , discussionId , request , authUser .getId ()));
70101 }
71102
103+ @ Operation (
104+ summary = "토론 삭제" ,
105+ description = "특정 Discussion을 삭제합니다." ,
106+ parameters = {
107+ @ Parameter (name = "problemId" , description = "문제 ID" , required = true ),
108+ @ Parameter (name = "discussionId" , description = "토론 ID" , required = true )
109+ }
110+ )
111+ @ ApiResponse (responseCode = "200" , description = "삭제 성공" )
72112 @ DeleteMapping ("/{discussionId}" )
73113 public ResponseEntity <Void > removeDiscussion (
74114 @ PathVariable Long problemId ,
0 commit comments