diff --git a/src/main/java/org/depromeet/sambad/moring/meeting/meeting/application/MeetingService.java b/src/main/java/org/depromeet/sambad/moring/meeting/meeting/application/MeetingService.java index 01814ca7..ff859221 100644 --- a/src/main/java/org/depromeet/sambad/moring/meeting/meeting/application/MeetingService.java +++ b/src/main/java/org/depromeet/sambad/moring/meeting/meeting/application/MeetingService.java @@ -3,9 +3,12 @@ import java.util.List; import org.depromeet.sambad.moring.meeting.meeting.domain.Meeting; +import org.depromeet.sambad.moring.meeting.meeting.domain.MeetingCode; import org.depromeet.sambad.moring.meeting.meeting.domain.TypesPerMeeting; +import org.depromeet.sambad.moring.meeting.meeting.presentation.exception.MeetingNotFoundException; import org.depromeet.sambad.moring.meeting.meeting.presentation.request.MeetingPersistRequest; import org.depromeet.sambad.moring.meeting.meeting.presentation.response.MeetingResponse; +import org.depromeet.sambad.moring.meeting.meeting.presentation.response.MeetingNameResponse; import org.depromeet.sambad.moring.meeting.member.application.MeetingMemberRepository; import org.depromeet.sambad.moring.meeting.member.domain.MeetingMember; import org.depromeet.sambad.moring.meeting.member.domain.MeetingMemberValidator; @@ -47,6 +50,13 @@ public MeetingResponse getMeetingResponse(Long userId) { return MeetingResponse.from(meetings); } + public MeetingNameResponse getMeetingNameByCode(String code) { + Meeting meeting = meetingRepository.findByCode(MeetingCode.from(code)) + .orElseThrow(MeetingNotFoundException::new); + + return MeetingNameResponse.from(meeting); + } + private void addTypesToMeeting(MeetingPersistRequest request, Meeting meeting) { List types = meetingTypeRepository.findByIdIn(request.meetingTypeIds()) .stream() diff --git a/src/main/java/org/depromeet/sambad/moring/meeting/meeting/presentation/MeetingController.java b/src/main/java/org/depromeet/sambad/moring/meeting/meeting/presentation/MeetingController.java index 84be74d8..ba1d310a 100644 --- a/src/main/java/org/depromeet/sambad/moring/meeting/meeting/presentation/MeetingController.java +++ b/src/main/java/org/depromeet/sambad/moring/meeting/meeting/presentation/MeetingController.java @@ -11,6 +11,7 @@ import org.depromeet.sambad.moring.meeting.meeting.presentation.request.MeetingPersistRequest; import org.depromeet.sambad.moring.meeting.meeting.presentation.response.MeetingPersistResponse; import org.depromeet.sambad.moring.meeting.meeting.presentation.response.MeetingResponse; +import org.depromeet.sambad.moring.meeting.meeting.presentation.response.MeetingNameResponse; import org.depromeet.sambad.moring.meeting.meeting.presentation.response.MeetingTypeResponse; import org.depromeet.sambad.moring.user.presentation.resolver.UserId; import org.springframework.http.ResponseEntity; @@ -18,6 +19,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import io.swagger.v3.oas.annotations.Operation; @@ -47,6 +49,18 @@ public ResponseEntity getMeetings(@UserId Long userId) { return ResponseEntity.ok(response); } + @Operation(summary = "초대 코드 기반 모임명 조회", description = "초대 코드를 기반으로 모임명을 조회하며, 모임 존재 여부를 검증합니다.") + @ApiResponses({ + @ApiResponse(responseCode = "200", description = "모임명 조회 성공"), + @ApiResponse(responseCode = "404", description = "MEETING_NOT_FOUND"), + }) + @GetMapping("/name") + public ResponseEntity getMeetingName(@RequestParam String code) { + MeetingNameResponse response = meetingService.getMeetingNameByCode(code); + + return ResponseEntity.ok(response); + } + @Operation(summary = "모임 생성", description = "모임을 생성합니다.") @ApiResponses({ @ApiResponse(responseCode = "201", description = "모임 생성 성공"), diff --git a/src/main/java/org/depromeet/sambad/moring/meeting/meeting/presentation/response/MeetingNameResponse.java b/src/main/java/org/depromeet/sambad/moring/meeting/meeting/presentation/response/MeetingNameResponse.java new file mode 100644 index 00000000..9e15c1f9 --- /dev/null +++ b/src/main/java/org/depromeet/sambad/moring/meeting/meeting/presentation/response/MeetingNameResponse.java @@ -0,0 +1,16 @@ +package org.depromeet.sambad.moring.meeting.meeting.presentation.response; + +import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.*; + +import org.depromeet.sambad.moring.meeting.meeting.domain.Meeting; + +import io.swagger.v3.oas.annotations.media.Schema; + +public record MeetingNameResponse( + @Schema(description = "모임명", example = "삼밧드의 모험", requiredMode = REQUIRED) + String name +) { + public static MeetingNameResponse from(Meeting meeting) { + return new MeetingNameResponse(meeting.getName()); + } +}