임간물 등록 월 파라메터 이용시 13개월안 범위 확인 추가
This commit is contained in:
@@ -47,6 +47,12 @@ class CreateMonthlyUIController {
|
|||||||
@GetMapping(path = "/info/monthly/month/{month}")
|
@GetMapping(path = "/info/monthly/month/{month}")
|
||||||
String operateMonth(@PathVariable String month) {
|
String operateMonth(@PathVariable String month) {
|
||||||
|
|
||||||
|
|
||||||
|
boolean isTargetMonth = isWithin13MonthsFromNow(month);
|
||||||
|
|
||||||
|
if(!isTargetMonth){
|
||||||
|
return "redirect:/info/monthly";
|
||||||
|
}
|
||||||
Pageable pageable = PageRequest.of(
|
Pageable pageable = PageRequest.of(
|
||||||
0,
|
0,
|
||||||
13,
|
13,
|
||||||
@@ -135,4 +141,19 @@ class CreateMonthlyUIController {
|
|||||||
|
|
||||||
return "info/monthly/form";
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user