diff --git a/backend/src/main/java/kr/momo/controller/meeting/MeetingController.java b/backend/src/main/java/kr/momo/controller/meeting/MeetingController.java index e24fa4f7..55df8ce7 100644 --- a/backend/src/main/java/kr/momo/controller/meeting/MeetingController.java +++ b/backend/src/main/java/kr/momo/controller/meeting/MeetingController.java @@ -8,6 +8,7 @@ import kr.momo.service.meeting.MeetingConfirmService; import kr.momo.service.meeting.MeetingService; import kr.momo.service.meeting.dto.ConfirmedMeetingResponse; +import kr.momo.service.meeting.dto.MeetingHomeResponse; import kr.momo.service.meeting.dto.MeetingConfirmRequest; import kr.momo.service.meeting.dto.MeetingConfirmResponse; import kr.momo.service.meeting.dto.MeetingCreateRequest; @@ -73,6 +74,12 @@ public MomoApiResponse findConfirmedMeeting(@PathVaria return new MomoApiResponse<>(response); } + @GetMapping("/api/v1/meetings/{uuid}/home") + public MomoApiResponse findMeetingHome(@PathVariable String uuid) { + MeetingHomeResponse response = meetingService.findMeetingHome(uuid); + return new MomoApiResponse<>(response); + } + @PatchMapping("/api/v1/meetings/{uuid}/lock") public void lock(@PathVariable String uuid, @AuthAttendee long id) { meetingService.lock(uuid, id); diff --git a/backend/src/main/java/kr/momo/controller/meeting/MeetingControllerDocs.java b/backend/src/main/java/kr/momo/controller/meeting/MeetingControllerDocs.java index 498eaa96..deee06b6 100644 --- a/backend/src/main/java/kr/momo/controller/meeting/MeetingControllerDocs.java +++ b/backend/src/main/java/kr/momo/controller/meeting/MeetingControllerDocs.java @@ -15,6 +15,7 @@ import kr.momo.service.meeting.dto.MeetingConfirmResponse; import kr.momo.service.meeting.dto.MeetingCreateRequest; import kr.momo.service.meeting.dto.MeetingCreateResponse; +import kr.momo.service.meeting.dto.MeetingHomeResponse; import kr.momo.service.meeting.dto.MeetingResponse; import kr.momo.service.meeting.dto.MeetingSharingResponse; import org.springframework.http.ResponseEntity; @@ -147,4 +148,11 @@ ResponseEntity cancelConfirmedMeeting( @PathVariable @Schema(description = "약속 UUID") String uuid, @AuthAttendee @Schema(hidden = true) long id ); + + @Operation(summary = "약속 입장 정보 조회", description = "약속 입장에 필요한 정보를 조회하는 API 입니다.") + @ApiSuccessResponse.NoContent("약속 입장 정보 조회 성공") + @ApiErrorResponse.BadRequest(ERROR_CODE_TABLE_HEADER + """ + | NOT_FOUND_MEETING | 존재하지 않는 약속 정보 입니다. | + """) + MomoApiResponse findMeetingHome(@PathVariable @Schema(description = "약속 UUID") String uuid); } diff --git a/backend/src/main/java/kr/momo/service/meeting/MeetingService.java b/backend/src/main/java/kr/momo/service/meeting/MeetingService.java index 4878ce14..25ca8f02 100644 --- a/backend/src/main/java/kr/momo/service/meeting/MeetingService.java +++ b/backend/src/main/java/kr/momo/service/meeting/MeetingService.java @@ -19,6 +19,7 @@ import kr.momo.exception.code.AttendeeErrorCode; import kr.momo.exception.code.MeetingErrorCode; import kr.momo.service.auth.JwtManager; +import kr.momo.service.meeting.dto.MeetingHomeResponse; import kr.momo.service.meeting.dto.MeetingCreateRequest; import kr.momo.service.meeting.dto.MeetingCreateResponse; import kr.momo.service.meeting.dto.MeetingResponse; @@ -110,6 +111,13 @@ public MeetingSharingResponse findMeetingSharing(String uuid) { return MeetingSharingResponse.from(meeting); } + @Transactional(readOnly = true) + public MeetingHomeResponse findMeetingHome(String uuid) { + Meeting meeting = meetingRepository.findByUuid(uuid) + .orElseThrow(() -> new MomoException(MeetingErrorCode.NOT_FOUND_MEETING)); + return MeetingHomeResponse.from(meeting); + } + @Transactional public void lock(String uuid, long id) { Meeting meeting = meetingRepository.findByUuid(uuid) diff --git a/backend/src/main/java/kr/momo/service/meeting/dto/MeetingHomeResponse.java b/backend/src/main/java/kr/momo/service/meeting/dto/MeetingHomeResponse.java new file mode 100644 index 00000000..2a6a9834 --- /dev/null +++ b/backend/src/main/java/kr/momo/service/meeting/dto/MeetingHomeResponse.java @@ -0,0 +1,18 @@ +package kr.momo.service.meeting.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import kr.momo.domain.meeting.Meeting; + +@Schema(description = "약속 입장 응답") +public record MeetingHomeResponse( + + @Schema(description = "약속 이름") + String meetingName, + + @Schema(description = "약속 유형") + String type +) { + public static MeetingHomeResponse from(Meeting meeting) { + return new MeetingHomeResponse(meeting.getName(), meeting.getType().name()); + } +} diff --git a/backend/src/test/java/kr/momo/controller/meeting/MeetingControllerTest.java b/backend/src/test/java/kr/momo/controller/meeting/MeetingControllerTest.java index 81b377ba..8819b8d4 100644 --- a/backend/src/test/java/kr/momo/controller/meeting/MeetingControllerTest.java +++ b/backend/src/test/java/kr/momo/controller/meeting/MeetingControllerTest.java @@ -689,4 +689,18 @@ private MeetingConfirmRequest getValidFindRequest(AvailableDate tomorrow) { Timeslot.TIME_0600.startTime() ); } + + @DisplayName("약속 입장 정보를 조회하면 200 상태 코드를 응답한다.") + @Test + void findMeetingHome() { + Meeting meeting = MeetingFixture.MOVIE.create(); + meeting = meetingRepository.save(meeting); + + RestAssured.given().log().all() + .pathParam("uuid", meeting.getUuid()) + .contentType(ContentType.JSON) + .when().get("/api/v1/meetings/{uuid}/home") + .then().log().all() + .statusCode(HttpStatus.OK.value()); + } } diff --git a/backend/src/test/java/kr/momo/service/meeting/MeetingServiceTest.java b/backend/src/test/java/kr/momo/service/meeting/MeetingServiceTest.java index 6480acdd..9a4d853d 100644 --- a/backend/src/test/java/kr/momo/service/meeting/MeetingServiceTest.java +++ b/backend/src/test/java/kr/momo/service/meeting/MeetingServiceTest.java @@ -10,6 +10,7 @@ import java.time.LocalTime; import java.time.ZoneId; import java.util.List; +import java.util.UUID; import kr.momo.domain.attendee.Attendee; import kr.momo.domain.attendee.AttendeeRepository; import kr.momo.domain.availabledate.AvailableDate; @@ -24,6 +25,7 @@ import kr.momo.exception.code.MeetingErrorCode; import kr.momo.fixture.AttendeeFixture; import kr.momo.fixture.MeetingFixture; +import kr.momo.service.meeting.dto.MeetingHomeResponse; import kr.momo.service.meeting.dto.MeetingCreateRequest; import kr.momo.service.meeting.dto.MeetingResponse; import kr.momo.service.meeting.dto.MeetingSharingResponse; @@ -258,4 +260,28 @@ void throwsExceptionWhenUnlockAttendeeGuest() { .isInstanceOf(MomoException.class) .hasMessage(AttendeeErrorCode.ACCESS_DENIED.message()); } + + @DisplayName("UUID로 약속 입장 정보를 조회한다.") + @Test + void findMeetingHome() { + Meeting meeting = meetingRepository.save(MeetingFixture.GAME.create()); + String uuid = meeting.getUuid(); + + MeetingHomeResponse result = meetingService.findMeetingHome(uuid); + + assertAll( + () -> assertThat(result.meetingName()).isEqualTo(meeting.getName()), + () -> assertThat(result.type()).isEqualTo(meeting.getType().name()) + ); + } + + @DisplayName("약속 입장 정보를 조회시 UUID가 존재하지 않으면 예외가 발생한다.") + @Test + void throwsExceptionWhenFindHomeNoMeeting() { + String uuid = UUID.randomUUID().toString(); + + assertThatThrownBy(() -> meetingService.findMeetingHome(uuid)) + .isInstanceOf(MomoException.class) + .hasMessage(MeetingErrorCode.NOT_FOUND_MEETING.message()); + } }