Skip to content

Commit

Permalink
[SAMBAD-221]-feat: 릴레이질문 코멘트 없을 시 204
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeHanEum committed Aug 3, 2024
1 parent 4cf4e48 commit 1b851ca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public ResponseEntity<Object> 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")
Expand All @@ -57,9 +58,9 @@ public ResponseEntity<MeetingCommentListResponse> 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 = "모임의 릴레이 질문 코멘트를 삭제합니다.")
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -19,4 +20,10 @@ public record MeetingCommentListResponse(
public static MeetingCommentListResponse from(List<MeetingQuestionComment> comments) {
return new MeetingCommentListResponse(MeetingCommentListResponseDetail.from(comments));
}

public ResponseEntity<MeetingCommentListResponse> toResponseEntity() {
return contents.isEmpty()
? ResponseEntity.noContent().build()
: ResponseEntity.ok(this);
}
}

0 comments on commit 1b851ca

Please sign in to comment.