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: 0시 인증 방에서 인증이 안되는 버그 수정 #213

Merged
merged 3 commits into from
Nov 30, 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
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.moabam.api.application.room;

import static com.moabam.global.common.util.GlobalConstant.*;
import static com.moabam.global.error.model.ErrorMessage.*;

import java.time.LocalDate;
Expand Down Expand Up @@ -109,8 +110,13 @@ public Certification findCertification(Long certificationId) {

private void validateCertifyTime(LocalDateTime now, int certifyTime) {
LocalTime targetTime = LocalTime.of(certifyTime, 0);
LocalDateTime minusTenMinutes = LocalDateTime.of(now.toLocalDate(), targetTime).minusMinutes(10);
LocalDateTime plusTenMinutes = LocalDateTime.of(now.toLocalDate(), targetTime).plusMinutes(10);
LocalDateTime targetDateTime = LocalDateTime.of(now.toLocalDate(), targetTime);
if (certifyTime == MIDNIGHT_HOUR) {
targetDateTime = targetDateTime.plusDays(1);
}

LocalDateTime minusTenMinutes = targetDateTime.minusMinutes(10);
LocalDateTime plusTenMinutes = targetDateTime.plusMinutes(10);

if (now.isBefore(minusTenMinutes) || now.isAfter(plusTenMinutes)) {
throw new BadRequestException(INVALID_CERTIFY_TIME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class GlobalConstant {
public static final String DELIMITER = "/";
public static final String CHARSET_UTF_8 = ";charset=UTF-8";
public static final String SPACE = " ";
public static final int MIDNIGHT_HOUR = 0;
public static final int ONE_HOUR = 1;
public static final int HOURS_IN_A_DAY = 24;
public static final int NOT_COMPLETED_RANK = 500;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ void get_room_details_test() throws Exception {
dailyRoomCertificationRepository.save(dailyRoomCertification);

DailyRoomCertification dailyRoomCertification1 = RoomFixture.dailyRoomCertification(room.getId(),
LocalDate.of(LocalDate.now().getYear(), LocalDate.now().getMonth(), LocalDate.now().getDayOfMonth() - 3));
LocalDate.now().minusDays(3));
dailyRoomCertificationRepository.save(dailyRoomCertification1);

// expected
Expand Down