임간물 등록 월 파라메터 이용시 13개월안 범위 확인 추가

This commit is contained in:
주우성
2025-06-18 21:04:53 +09:00
parent c5beca58cb
commit 9eb77e2cc6

View File

@@ -47,6 +47,12 @@ class CreateMonthlyUIController {
@GetMapping(path = "/info/monthly/month/{month}")
String operateMonth(@PathVariable String month) {
boolean isTargetMonth = isWithin13MonthsFromNow(month);
if(!isTargetMonth){
return "redirect:/info/monthly";
}
Pageable pageable = PageRequest.of(
0,
13,
@@ -135,4 +141,19 @@ class CreateMonthlyUIController {
return "info/monthly/form";
}
private static boolean isWithin13MonthsFromNow(String yyyymm) {
if (yyyymm == null || yyyymm.length() != 6) return false;
try {
YearMonth inputMonth = YearMonth.parse(yyyymm.substring(0, 4) + "-" + yyyymm.substring(4, 6));
YearMonth now = YearMonth.now();
YearMonth earliest = now.minusMonths(12); // 이번 달 포함해서 12개월 전
return !(inputMonth.isBefore(earliest) || inputMonth.isAfter(now));
} catch (Exception e) {
return false;
}
}
}