From 0406fa1ef5b55c76030cebb7f7a80b24afe585f5 Mon Sep 17 00:00:00 2001 From: Kijun Kwon <39583312+kkjsw17@users.noreply.github.com> Date: Mon, 29 Jul 2024 16:31:34 +0900 Subject: [PATCH] =?UTF-8?q?[SAMBAD-175]=20meeting=5Fquestion=5Fid=20?= =?UTF-8?q?=EA=B8=B0=EB=B0=98=20=EC=A7=88=EB=AC=B8=20=EC=A0=95=EB=B3=B4=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20API=20=EC=B6=94=EA=B0=80=20(#57)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/MeetingAnswerController.java | 12 ++-- .../response/SelectedAnswerResponse.java | 3 +- .../application/MeetingQuestionService.java | 9 +++ .../MeetingQuestionController.java | 58 ++++++++++++------- 4 files changed, 53 insertions(+), 29 deletions(-) diff --git a/src/main/java/org/depromeet/sambad/moring/meeting/answer/presentation/MeetingAnswerController.java b/src/main/java/org/depromeet/sambad/moring/meeting/answer/presentation/MeetingAnswerController.java index 0c26feba..24654488 100644 --- a/src/main/java/org/depromeet/sambad/moring/meeting/answer/presentation/MeetingAnswerController.java +++ b/src/main/java/org/depromeet/sambad/moring/meeting/answer/presentation/MeetingAnswerController.java @@ -74,11 +74,11 @@ public ResponseEntity findMyList( @ApiResponse(responseCode = "403", description = "USER_NOT_MEMBER_OF_MEETING"), @ApiResponse(responseCode = "404", description = "NOT_FOUND_MEETING_QUESTION") }) - @GetMapping("/meetings/{meetingId}/questions/{questionId}/answers/most-selected") + @GetMapping("/meetings/{meetingId}/questions/{meetingQuestionId}/answers/most-selected") public ResponseEntity getMostSelectedMeetingAnswer( @UserId Long userId, - @Parameter(description = "모임 ID", example = "1", required = true) @PathVariable(name = "meetingId") Long meetingId, - @Parameter(description = "모임 질문 ID", example = "1", required = true) @PathVariable(name = "questionId") Long meetingQuestionId + @Parameter(description = "모임 ID", example = "1", required = true) @PathVariable Long meetingId, + @Parameter(description = "모임 질문 ID", example = "1", required = true) @PathVariable Long meetingQuestionId ) { SelectedAnswerResponse response = meetingAnswerResultService.getMostSelectedAnswer( userId, meetingId, meetingQuestionId); @@ -92,11 +92,11 @@ public ResponseEntity getMostSelectedMeetingAnswer( @ApiResponse(responseCode = "403", description = "USER_NOT_MEMBER_OF_MEETING"), @ApiResponse(responseCode = "404", description = "MEETING_MEMBER_NOT_FOUND") }) - @GetMapping("/meetings/{meetingId}/questions/{questionId}/answers/selected-same") + @GetMapping("/meetings/{meetingId}/questions/{meetingQuestionId}/answers/selected-same") public ResponseEntity getSelectedSameMeetingAnswers( @UserId Long userId, - @Parameter(description = "모임 ID", example = "1", required = true) @PathVariable(name = "meetingId") Long meetingId, - @Parameter(description = "모임 질문 ID", example = "1", required = true) @PathVariable(name = "questionId") Long meetingQuestionId + @Parameter(description = "모임 ID", example = "1", required = true) @PathVariable Long meetingId, + @Parameter(description = "모임 질문 ID", example = "1", required = true) @PathVariable Long meetingQuestionId ) { SelectedAnswerResponse response = meetingAnswerResultService.getSelectedSameAnswer( userId, meetingId, meetingQuestionId); diff --git a/src/main/java/org/depromeet/sambad/moring/meeting/answer/presentation/response/SelectedAnswerResponse.java b/src/main/java/org/depromeet/sambad/moring/meeting/answer/presentation/response/SelectedAnswerResponse.java index 808c8d0f..9321bda3 100644 --- a/src/main/java/org/depromeet/sambad/moring/meeting/answer/presentation/response/SelectedAnswerResponse.java +++ b/src/main/java/org/depromeet/sambad/moring/meeting/answer/presentation/response/SelectedAnswerResponse.java @@ -21,8 +21,7 @@ public record SelectedAnswerResponse( @Schema(description = "선택한 멤버들", requiredMode = REQUIRED) List selectedMembers ) { - public static SelectedAnswerResponse from(List members, - List answers) { + public static SelectedAnswerResponse from(List members, List answers) { return new SelectedAnswerResponse( answers.stream() .map(MeetingAnswer::getAnswerContent) diff --git a/src/main/java/org/depromeet/sambad/moring/meeting/question/application/MeetingQuestionService.java b/src/main/java/org/depromeet/sambad/moring/meeting/question/application/MeetingQuestionService.java index 6f623c29..569ee59f 100644 --- a/src/main/java/org/depromeet/sambad/moring/meeting/question/application/MeetingQuestionService.java +++ b/src/main/java/org/depromeet/sambad/moring/meeting/question/application/MeetingQuestionService.java @@ -17,6 +17,7 @@ import org.depromeet.sambad.moring.meeting.question.presentation.response.MostInactiveMeetingQuestionListResponse; import org.depromeet.sambad.moring.question.application.QuestionService; import org.depromeet.sambad.moring.question.domain.Question; +import org.depromeet.sambad.moring.question.presentation.response.QuestionResponse; import org.springframework.data.domain.PageRequest; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -104,6 +105,14 @@ public MeetingQuestion getById(Long meetingId, Long meetingQuestionId) { .orElseThrow(NotFoundMeetingQuestion::new); } + /* + * 질문 정보의 경우 Public한 데이터이므로, 따로 권한 체크를 하지 않는다. + */ + public QuestionResponse getQuestionResponseById(Long meetingId, Long meetingQuestionId) { + MeetingQuestion meetingQuestion = getById(meetingId, meetingQuestionId); + return QuestionResponse.from(meetingQuestion.getQuestion()); + } + private Optional findActiveMeetingQuestion(Long meetingId) { return meetingQuestionRepository.findActiveOneByMeeting(meetingId); } diff --git a/src/main/java/org/depromeet/sambad/moring/meeting/question/presentation/MeetingQuestionController.java b/src/main/java/org/depromeet/sambad/moring/meeting/question/presentation/MeetingQuestionController.java index fb384d38..5310f4a0 100644 --- a/src/main/java/org/depromeet/sambad/moring/meeting/question/presentation/MeetingQuestionController.java +++ b/src/main/java/org/depromeet/sambad/moring/meeting/question/presentation/MeetingQuestionController.java @@ -6,6 +6,7 @@ import org.depromeet.sambad.moring.meeting.question.presentation.response.FullInactiveMeetingQuestionListResponse; import org.depromeet.sambad.moring.meeting.question.presentation.response.MeetingQuestionAndAnswerListResponse; import org.depromeet.sambad.moring.meeting.question.presentation.response.MostInactiveMeetingQuestionListResponse; +import org.depromeet.sambad.moring.question.presentation.response.QuestionResponse; import org.depromeet.sambad.moring.user.presentation.resolver.UserId; import org.springframework.data.domain.PageRequest; import org.springframework.http.HttpStatus; @@ -31,7 +32,7 @@ @Tag(name = "모임의 릴레이 질문", description = "모임원이 선택한 릴레이 질문 관련 api / 담당자: 김나현") @RestController @RequiredArgsConstructor -@RequestMapping("/v1") +@RequestMapping("/v1/meetings/{meetingId}/questions") public class MeetingQuestionController { private final MeetingQuestionService meetingQuestionService; @@ -42,7 +43,7 @@ public class MeetingQuestionController { @ApiResponse(responseCode = "404", description = "NOT_FOUND_QUESTION"), @ApiResponse(responseCode = "409", description = "DUPLICATE_MEETING_QUESTION / INVALID_MEETING_MEMBER_TARGET") }) - @PostMapping("/meetings/{meetingId}/questions") + @PostMapping public ResponseEntity save( @UserId Long userId, @Parameter(description = "모임 ID", example = "1", required = true) @PathVariable("meetingId") Long meetingId, @@ -52,6 +53,21 @@ public ResponseEntity save( return ResponseEntity.status(HttpStatus.CREATED).body(response); } + @Operation(summary = "모임 질문 상세 조회", description = "모임 질문 상세 정보를 반환합니다.") + @ApiResponses(value = { + @ApiResponse(responseCode = "200"), + @ApiResponse(responseCode = "404", description = "NOT_FOUND_MEETING_QUESTION"), + }) + @GetMapping("/{meetingQuestionId}") + public ResponseEntity getById( + @Parameter(description = "모임 ID", example = "1", required = true) @PathVariable Long meetingId, + @Parameter(description = "질문 ID", example = "1", required = true) @PathVariable Long meetingQuestionId + ) { + QuestionResponse response = meetingQuestionService.getQuestionResponseById(meetingId, meetingQuestionId); + + return ResponseEntity.ok().body(response); + } + @Operation(summary = "현재 진행 중인 릴레이 질문 조회", description = "모임원 참여율과 질문인에 대한 정보들을 함께 반환합니다.") @ApiResponses(value = { @ApiResponse( @@ -64,7 +80,7 @@ public ResponseEntity save( content = @Content(schema = @Schema(implementation = Object.class)) ) }) - @GetMapping("/meetings/{meetingId}/questions/active") + @GetMapping("/active") public ResponseEntity findActiveOne( @UserId Long userId, @Parameter(description = "모임 ID", example = "1", required = true) @PathVariable("meetingId") Long meetingId @@ -76,21 +92,6 @@ public ResponseEntity findActiveOne( return ResponseEntity.ok(activeOne); } - @Operation(summary = "홈 화면 내 종료된 릴레이 질문 2건 조회", description = "- 참여율 순으로 내림차순 정렬한 후 2건 반환합니다.") - @ApiResponses(value = { - @ApiResponse(responseCode = "200"), - @ApiResponse(responseCode = "403", description = "USER_NOT_MEMBER_OF_MEETING") - }) - @GetMapping("/meetings/{meetingId}/questions/inactive/top") - public ResponseEntity findMostInactiveList( - @UserId Long userId, - @Parameter(description = "모임 ID", example = "1", required = true) @PathVariable("meetingId") Long meetingId - ) { - MostInactiveMeetingQuestionListResponse inactiveList = meetingQuestionService.findMostInactiveList(userId, - meetingId); - return ResponseEntity.ok(inactiveList); - } - @Operation(summary = "진행 중인 모임의 릴레이 질문과 답안 옵션 조회", description = "- 질문과 질문의 답변 목록을 함께 반환합니다.\n" + "- 등록된 모임 질문에 모임원이 답변을 할 때 사용하는 API 입니다.") @ApiResponses(value = { @@ -98,8 +99,8 @@ public ResponseEntity findMostInactiveL @ApiResponse(responseCode = "403", description = "USER_NOT_MEMBER_OF_MEETING"), @ApiResponse(responseCode = "404", description = "NOT_FOUND_MEETING_QUESTION") }) - @GetMapping("/meetings/{meetingId}/questions/active/answers") - public ResponseEntity findMeeingQuestionAndAnswerList( + @GetMapping("/active/answers") + public ResponseEntity findMeetingQuestionAndAnswerList( @UserId Long userId, @Parameter(description = "모임 ID", example = "1", required = true) @PathVariable("meetingId") Long meetingId ) { @@ -114,7 +115,7 @@ public ResponseEntity findMeeingQuestionAn @ApiResponse(responseCode = "200"), @ApiResponse(responseCode = "403", description = "USER_NOT_MEMBER_OF_MEETING") }) - @GetMapping("/meetings/{meetingId}/questions/inactive") + @GetMapping("/inactive") public ResponseEntity findFullInactiveList( @UserId Long userId, @Parameter(description = "모임 ID", example = "1", required = true) @PathVariable("meetingId") Long meetingId, @@ -126,4 +127,19 @@ public ResponseEntity findFullInactiveL PageRequest.of(page, size)); return ResponseEntity.ok(inactiveList); } + + @Operation(summary = "홈 화면 내 종료된 릴레이 질문 2건 조회", description = "- 참여율 순으로 내림차순 정렬한 후 2건 반환합니다.") + @ApiResponses(value = { + @ApiResponse(responseCode = "200"), + @ApiResponse(responseCode = "403", description = "USER_NOT_MEMBER_OF_MEETING") + }) + @GetMapping("/inactive/top") + public ResponseEntity findMostInactiveList( + @UserId Long userId, + @Parameter(description = "모임 ID", example = "1", required = true) @PathVariable("meetingId") Long meetingId + ) { + MostInactiveMeetingQuestionListResponse inactiveList = meetingQuestionService.findMostInactiveList(userId, + meetingId); + return ResponseEntity.ok(inactiveList); + } }