From a500b86cb6a7b618c33c371947222b3eb47b9e25 Mon Sep 17 00:00:00 2001 From: Youngmyung Kim <83266154+ymkim97@users.noreply.github.com> Date: Sat, 2 Dec 2023 22:30:08 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=B0=A9=EC=9D=98=20=EC=9D=B8=EC=A6=9D?= =?UTF-8?q?=20=EC=8B=9C=EA=B0=84=EC=97=90=EB=8A=94=20=EC=9E=85=EC=9E=A5?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EB=AA=BB=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20(#223)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../moabam/api/application/room/RoomService.java | 14 ++++++++++++++ .../moabam/global/error/model/ErrorMessage.java | 1 + 2 files changed, 15 insertions(+) diff --git a/src/main/java/com/moabam/api/application/room/RoomService.java b/src/main/java/com/moabam/api/application/room/RoomService.java index 43b5c281..48dd9d04 100644 --- a/src/main/java/com/moabam/api/application/room/RoomService.java +++ b/src/main/java/com/moabam/api/application/room/RoomService.java @@ -3,6 +3,7 @@ import static com.moabam.api.domain.room.RoomType.*; import static com.moabam.global.error.model.ErrorMessage.*; +import java.time.LocalDateTime; import java.time.LocalTime; import java.util.List; @@ -199,6 +200,7 @@ private void validateManagerAuthorization(Participant participant) { private void validateRoomEnter(Long memberId, String requestPassword, Room room) { validateEnteredRoomCount(memberId, room.getRoomType()); + validateCertifyTime(room); if (!StringUtils.isEmpty(requestPassword) && !room.getPassword().equals(requestPassword)) { throw new BadRequestException(WRONG_ROOM_PASSWORD); @@ -219,6 +221,18 @@ private void validateEnteredRoomCount(Long memberId, RoomType roomType) { } } + private void validateCertifyTime(Room room) { + LocalDateTime now = clockHolder.times(); + LocalTime targetTime = LocalTime.of(room.getCertifyTime(), 0); + LocalDateTime targetDateTime = LocalDateTime.of(now.toLocalDate(), targetTime); + + LocalDateTime plusTenMinutes = targetDateTime.plusMinutes(10); + + if (now.isAfter(targetDateTime) && now.isBefore(plusTenMinutes)) { + throw new BadRequestException(ROOM_ENTER_FAILED); + } + } + private void validateRoomExit(Participant participant, Room room) { if (participant.isManager() && room.getCurrentUserCount() != 1) { throw new BadRequestException(ROOM_EXIT_MANAGER_FAIL); diff --git a/src/main/java/com/moabam/global/error/model/ErrorMessage.java b/src/main/java/com/moabam/global/error/model/ErrorMessage.java index 10d40ce0..3684e3ec 100644 --- a/src/main/java/com/moabam/global/error/model/ErrorMessage.java +++ b/src/main/java/com/moabam/global/error/model/ErrorMessage.java @@ -34,6 +34,7 @@ public enum ErrorMessage { IMAGE_CONVERT_FAIL("이미지 변환을 실패했습니다."), UNAVAILABLE_TO_CHANGE_CERTIFY_TIME("이미 한명 이상이 인증을 하면 인증 시간을 바꿀 수 없습니다."), CERTIFIED_ROOM_EXIT_FAILED("오늘 인증한 방은 나갈 수 없습니다."), + ROOM_ENTER_FAILED("해당 방의 인증 시간에는 입장할 수 없습니다."), LOGIN_FAILED("로그인에 실패했습니다."), LOGIN_FAILED_ADMIN_KEY("어드민키가 달라요"),