diff --git a/doorip-api/src/main/java/org/doorip/common/Constants.java b/doorip-api/src/main/java/org/doorip/common/Constants.java index cb50cbc..3123a06 100644 --- a/doorip-api/src/main/java/org/doorip/common/Constants.java +++ b/doorip-api/src/main/java/org/doorip/common/Constants.java @@ -16,4 +16,5 @@ public abstract class Constants { public static final int MIN_STYLE_RATE = 0; public static final int MAX_STYLE_RATE = 100; public static final int PROPENSITY_WEIGHT = 25; + public static final int MAX_PARTICIPANT_COUNT = 6; } diff --git a/doorip-api/src/main/java/org/doorip/trip/api/TripApi.java b/doorip-api/src/main/java/org/doorip/trip/api/TripApi.java index ea7465c..b8b0aac 100644 --- a/doorip-api/src/main/java/org/doorip/trip/api/TripApi.java +++ b/doorip-api/src/main/java/org/doorip/trip/api/TripApi.java @@ -105,7 +105,7 @@ ResponseEntity> getTrips(@Parameter(hidden = true) @RequestParam final String progress); @Operation( - summary = "초대 코드 검증 API", + summary = "초대코드 검증 API", responses = { @ApiResponse( responseCode = "200", @@ -114,6 +114,10 @@ ResponseEntity> getTrips(@Parameter(hidden = true) responseCode = "400", description = "잘못된 요청입니다.", content = @Content), + @ApiResponse( + responseCode = "400", + description = "여행에 입장할 수 있는 최대 인원은 6명입니다.", + content = @Content), @ApiResponse( responseCode = "401", description = "액세스 토큰의 형식이 올바르지 않습니다. Bearer 타입을 확인해 주세요.", diff --git a/doorip-api/src/main/java/org/doorip/trip/service/TripService.java b/doorip-api/src/main/java/org/doorip/trip/service/TripService.java index f54e25d..a4108b9 100644 --- a/doorip-api/src/main/java/org/doorip/trip/service/TripService.java +++ b/doorip-api/src/main/java/org/doorip/trip/service/TripService.java @@ -43,7 +43,6 @@ public TripCreateResponse createTripAndParticipant(Long userId, TripCreateReques Trip trip = createTrip(request, code); createParticipant(request, findUser, trip); tripRepository.save(trip); - return TripCreateResponse.of(trip); } @@ -53,7 +52,6 @@ public TripEntryResponse entryTrip(Long userId, Long tripId, TripEntryRequest re Trip findTrip = getTrip(tripId); validateDuplicateParticipant(findUser, findTrip); createAndSaveParticipant(request, findUser, findTrip); - return TripEntryResponse.of(findTrip); } @@ -65,9 +63,17 @@ public TripGetResponse getTrips(Long userId, String progress) { public TripResponse verifyCode(TripVerifyRequest request) { Trip trip = getTrip(request.code()); + List participants = trip.getParticipants(); + validateParticipantCount(participants); return TripResponse.of(trip); } + private void validateParticipantCount(List participants) { + if (participants.size() == Constants.MAX_PARTICIPANT_COUNT) { + throw new InvalidValueException(ErrorMessage.INVALID_PARTICIPANT_COUNT); + } + } + private void validateDate(LocalDate startDate, LocalDate endDate) { if (endDate.isBefore(LocalDate.now()) || endDate.isBefore(startDate)) { throw new InvalidValueException(ErrorMessage.INVALID_DATE_TYPE); @@ -80,7 +86,6 @@ private String createCode() { String uuid = UUID.randomUUID().toString(); code = uuid.substring(0, 6); } while (isDuplicateCode(code)); - return code; } diff --git a/doorip-common/src/main/java/org/doorip/message/ErrorMessage.java b/doorip-common/src/main/java/org/doorip/message/ErrorMessage.java index fc10503..5ceb06b 100644 --- a/doorip-common/src/main/java/org/doorip/message/ErrorMessage.java +++ b/doorip-common/src/main/java/org/doorip/message/ErrorMessage.java @@ -17,6 +17,7 @@ public enum ErrorMessage { INVALID_ALLOCATOR_COUNT(HttpStatus.BAD_REQUEST, "e4003", "여행 TODO를 생성하기 위해 최소 1명 이상의 배정자가 필요합니다."), INVALID_DATE_TYPE(HttpStatus.BAD_REQUEST, "e4004", "유효하지 않은 날짜 타입입니다."), INVALID_RESULT_TYPE(HttpStatus.BAD_REQUEST, "e4004", "유효하지 않은 성향 입력 값입니다."), + INVALID_PARTICIPANT_COUNT(HttpStatus.BAD_REQUEST, "e4005", "여행에 입장할 수 있는 최대 인원은 6명입니다."), /** * 401 Unauthorized