Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 방의 인증 시간에는 입장하지 못하도록 수정 #223

Merged
merged 1 commit into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/main/java/com/moabam/api/application/room/RoomService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("어드민키가 달라요"),
Expand Down