Skip to content

Commit fffa865

Browse files
committed
fix: 매직넘버 상수로 변경
1 parent 6caa163 commit fffa865

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

src/main/java/com/planetrush/planetrush/planet/service/PlanetPolicy.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,25 @@
1616
@Component
1717
public final class PlanetPolicy {
1818

19+
private static final int MAX_RESIDENT_LIMIT = 9;
20+
private static final int MAX_CHALLENGE_START_OFFSET = 14;
21+
1922
/**
20-
* 최대 입주 가능 인원을 확인합니다.
23+
* 가입 가능한 최대 챌린지 수를 초과하는지 검사합니다.
24+
* @param member
25+
* @param residentRepositoryCustom
2126
*/
2227
public static void validateResidentLimit(Member member, ResidentRepositoryCustom residentRepositoryCustom) {
23-
if (residentRepositoryCustom.getReadyAndInProgressResidents(member) >= 9) {
28+
if (residentRepositoryCustom.getReadyAndInProgressResidents(member) >= MAX_RESIDENT_LIMIT) {
2429
throw new ResidentOverflowException("resident count overflow");
2530
}
2631
}
2732

2833
/**
2934
* 동일한 행성에 중복 가입을 방지합니다.
35+
* @param member
36+
* @param planet
37+
* @param residentRepository
3038
*/
3139
public static void validateDuplicateResident(Member member, Planet planet, ResidentRepository residentRepository) {
3240
residentRepository.findByMemberIdAndPlanetId(member.getId(), planet.getId())
@@ -35,8 +43,12 @@ public static void validateDuplicateResident(Member member, Planet planet, Resid
3543
});
3644
}
3745

46+
/**
47+
* 2주 이내로 시작하는지 검사합니다.
48+
* @param startDate
49+
*/
3850
public static void validateStartDateWithinTwoWeeks(LocalDate startDate) {
39-
if(ChronoUnit.DAYS.between(LocalDate.now(), startDate) > 14) {
51+
if(ChronoUnit.DAYS.between(LocalDate.now(), startDate) > MAX_CHALLENGE_START_OFFSET) {
4052
throw new InvalidStartDateException("Start date must be within 14 days from today.");
4153
}
4254
}

0 commit comments

Comments
 (0)