From c10d02050e0be1ca4177f60f054c65196e70a970 Mon Sep 17 00:00:00 2001 From: sunwoong Date: Wed, 17 Jan 2024 21:57:02 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=97=AC=ED=96=89=20=EC=9E=85=EC=9E=A5?= =?UTF-8?q?=20=EC=B5=9C=EB=8C=80=20=EC=9D=B8=EC=9B=90=20=EA=B2=80=EC=A6=9D?= =?UTF-8?q?=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95=20(#109)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/doorip/trip/service/TripService.java | 15 +++++++-------- .../java/org/doorip/message/ErrorMessage.java | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) 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 a4108b9..6313606 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 @@ -51,6 +51,7 @@ public TripEntryResponse entryTrip(Long userId, Long tripId, TripEntryRequest re User findUser = getUser(userId); Trip findTrip = getTrip(tripId); validateDuplicateParticipant(findUser, findTrip); + validateParticipantCount(findTrip.getParticipants()); createAndSaveParticipant(request, findUser, findTrip); return TripEntryResponse.of(findTrip); } @@ -63,17 +64,9 @@ 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); @@ -128,6 +121,12 @@ private void validateDuplicateParticipant(User user, Trip trip) { } } + private void validateParticipantCount(List participants) { + if (participants.size() == Constants.MAX_PARTICIPANT_COUNT) { + throw new InvalidValueException(ErrorMessage.INVALID_PARTICIPANT_COUNT); + } + } + private void createAndSaveParticipant(TripEntryRequest request, User user, Trip trip) { Participant.createParticipant(Role.PARTICIPATION, request.styleA(), request.styleB(), request.styleC(), request.styleD(), request.styleE(), user, trip); 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 eb14c79..28f6f10 100644 --- a/doorip-common/src/main/java/org/doorip/message/ErrorMessage.java +++ b/doorip-common/src/main/java/org/doorip/message/ErrorMessage.java @@ -64,7 +64,7 @@ public enum ErrorMessage { */ CONFLICT(HttpStatus.CONFLICT, "e4090", "이미 존재하는 리소스입니다."), DUPLICATE_USER(HttpStatus.CONFLICT, "e4091", "이미 존재하는 회원입니다."), - DUPLICATE_PARTICIPANT(HttpStatus.CONFLICT, "e4092", "이미 존재하는 참가자입니다."), + DUPLICATE_PARTICIPANT(HttpStatus.CONFLICT, "e4092", "이미 존재하는 참여자입니다."), /** * 500 Internal Server Error