From 1b851ca41e30300c792a19583fd57cea6de6e653 Mon Sep 17 00:00:00 2001 From: LeeHanEum Date: Sun, 4 Aug 2024 06:28:00 +0900 Subject: [PATCH] =?UTF-8?q?[SAMBAD-221]-feat:=20=EB=A6=B4=EB=A0=88?= =?UTF-8?q?=EC=9D=B4=EC=A7=88=EB=AC=B8=20=EC=BD=94=EB=A9=98=ED=8A=B8=20?= =?UTF-8?q?=EC=97=86=EC=9D=84=20=EC=8B=9C=20204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../comment/MeetingQuestionCommentController.java | 7 ++++--- .../comment/response/MeetingCommentListResponse.java | 9 ++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/depromeet/sambad/moring/meeting/comment/presentation/comment/MeetingQuestionCommentController.java b/src/main/java/org/depromeet/sambad/moring/meeting/comment/presentation/comment/MeetingQuestionCommentController.java index 60da09c7..8b01fbc0 100644 --- a/src/main/java/org/depromeet/sambad/moring/meeting/comment/presentation/comment/MeetingQuestionCommentController.java +++ b/src/main/java/org/depromeet/sambad/moring/meeting/comment/presentation/comment/MeetingQuestionCommentController.java @@ -48,7 +48,8 @@ public ResponseEntity saveComment( @Operation(summary = "릴레이 질문에 대한 모든 코멘트 조회", description = "모임의 릴레이 질문에 대한 모든 코멘트를 조회합니다.") @ApiResponses(value = { - @ApiResponse(responseCode = "200"), + @ApiResponse(responseCode = "200", description = "릴레이 질문에 대한 코멘트 목록 조회 성공"), + @ApiResponse(responseCode = "204", description = "릴레이 질문에 대한 코멘트 없음"), @ApiResponse(responseCode = "404", description = "NOT_FOUND_QUESTION") }) @GetMapping("/meetings/{meetingId}/questions/{meetingQuestionId}/comments") @@ -57,9 +58,9 @@ public ResponseEntity getComments( @Parameter(description = "모임 ID", example = "1", required = true) @PathVariable("meetingId") @Positive Long meetingId, @Parameter(description = "모임 질문 ID", example = "1", required = true) @PathVariable("meetingQuestionId") @Positive Long meetingQuestionId ) { - MeetingCommentListResponse comments = meetingQuestionCommentService.getAllComments(userId, meetingId, + MeetingCommentListResponse response = meetingQuestionCommentService.getAllComments(userId, meetingId, meetingQuestionId); - return ResponseEntity.ok(comments); + return response.toResponseEntity(); } @Operation(summary = "릴레이 질문 코멘트 삭제", description = "모임의 릴레이 질문 코멘트를 삭제합니다.") diff --git a/src/main/java/org/depromeet/sambad/moring/meeting/comment/presentation/comment/response/MeetingCommentListResponse.java b/src/main/java/org/depromeet/sambad/moring/meeting/comment/presentation/comment/response/MeetingCommentListResponse.java index 030f1f11..985c1928 100644 --- a/src/main/java/org/depromeet/sambad/moring/meeting/comment/presentation/comment/response/MeetingCommentListResponse.java +++ b/src/main/java/org/depromeet/sambad/moring/meeting/comment/presentation/comment/response/MeetingCommentListResponse.java @@ -1,10 +1,11 @@ package org.depromeet.sambad.moring.meeting.comment.presentation.comment.response; -import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.*; +import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; import java.util.List; import org.depromeet.sambad.moring.meeting.comment.domain.comment.MeetingQuestionComment; +import org.springframework.http.ResponseEntity; import io.swagger.v3.oas.annotations.media.Schema; @@ -19,4 +20,10 @@ public record MeetingCommentListResponse( public static MeetingCommentListResponse from(List comments) { return new MeetingCommentListResponse(MeetingCommentListResponseDetail.from(comments)); } + + public ResponseEntity toResponseEntity() { + return contents.isEmpty() + ? ResponseEntity.noContent().build() + : ResponseEntity.ok(this); + } }