date 모듈 수정
This commit is contained in:
parent
339e233c0b
commit
7d2ce518aa
@ -143,15 +143,11 @@ public final class DateUtils {
|
|||||||
* @param dateVal
|
* @param dateVal
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean dateChkAndValueChk(String searchStartDate, String searchEndDate, int dateVal) {
|
public static boolean dateChkAndValueChk(String searchStartDate, String searchEndDate, int months) {
|
||||||
|
|
||||||
|
|
||||||
boolean isValid = true;
|
boolean isValid = true;
|
||||||
|
|
||||||
// 날짜 형식 지정
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
|
|
||||||
|
|
||||||
//날짜 검증
|
// 날짜 검증
|
||||||
LocalDate startDate = null;
|
LocalDate startDate = null;
|
||||||
LocalDate endDate = null;
|
LocalDate endDate = null;
|
||||||
|
|
||||||
@ -163,8 +159,8 @@ public final class DateUtils {
|
|||||||
// 날짜 형식으로 변환
|
// 날짜 형식으로 변환
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
try {
|
try {
|
||||||
startDate = LocalDate.parse(searchStartDate, formatter);
|
startDate = LocalDate.parse(searchStartDate, SLUSH_FORMATTER);
|
||||||
endDate = LocalDate.parse(searchEndDate, formatter);
|
endDate = LocalDate.parse(searchEndDate, SLUSH_FORMATTER);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
isValid = false;
|
isValid = false;
|
||||||
}
|
}
|
||||||
@ -175,14 +171,14 @@ public final class DateUtils {
|
|||||||
isValid = false;
|
isValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 총 기간이 365일을 넘는지 확인
|
// 총 기간이 지정한 개월 수를 넘는지 확인
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
long daysBetween = ChronoUnit.DAYS.between(startDate, endDate);
|
long monthsBetween = ChronoUnit.MONTHS.between(startDate, endDate);
|
||||||
if (daysBetween > dateVal) {
|
System.out.println("monthsBetween : "+ monthsBetween);
|
||||||
|
if (monthsBetween >= months) {
|
||||||
isValid = false;
|
isValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println("isValid : "+ isValid);
|
|
||||||
|
|
||||||
return isValid;
|
return isValid;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -229,7 +229,7 @@ public class MjonMsgCustomWebController {
|
|||||||
// 검색 데이터가 없거나
|
// 검색 데이터가 없거나
|
||||||
// 시작일자가 종료일자보다 이후이거나
|
// 시작일자가 종료일자보다 이후이거나
|
||||||
// 총 기간이 365일이 넘으면 현재일부터 365일 전 날짜를 넣어서 검색
|
// 총 기간이 365일이 넘으면 현재일부터 365일 전 날짜를 넣어서 검색
|
||||||
if(!DateUtils.dateChkAndValueChk(mjonMsgCustomVO.getSearchStartDate(),mjonMsgCustomVO.getSearchEndDate(), 365 )) {
|
if(!DateUtils.dateChkAndValueChk(mjonMsgCustomVO.getSearchStartDate(),mjonMsgCustomVO.getSearchEndDate(), 12 )) {
|
||||||
|
|
||||||
mjonMsgCustomVO.setSearchStartDate(DateUtils.getDateDaysAgo(365));
|
mjonMsgCustomVO.setSearchStartDate(DateUtils.getDateDaysAgo(365));
|
||||||
mjonMsgCustomVO.setSearchEndDate(DateUtils.getCurrentDate());
|
mjonMsgCustomVO.setSearchEndDate(DateUtils.getCurrentDate());
|
||||||
|
|||||||
@ -2108,7 +2108,11 @@ public class MjonPayController {
|
|||||||
// mjonPayVO.setStartDate(mjonPayVO.getStartDate() == null ? DateUtil.getDateDaysAgo(365) : mjonPayVO.getStartDate());
|
// mjonPayVO.setStartDate(mjonPayVO.getStartDate() == null ? DateUtil.getDateDaysAgo(365) : mjonPayVO.getStartDate());
|
||||||
// mjonPayVO.setEndDate(mjonPayVO.getEndDate() == null ? DateUtil.getCurrentDate() : mjonPayVO.getEndDate());
|
// mjonPayVO.setEndDate(mjonPayVO.getEndDate() == null ? DateUtil.getCurrentDate() : mjonPayVO.getEndDate());
|
||||||
|
|
||||||
if(!DateUtils.dateChkAndValueChk(mjonPayVO.getSearchStartDate(),mjonPayVO.getSearchEndDate(), 365 )) {
|
System.out.println("???");
|
||||||
|
System.out.println("mjonPayVO.getStartDate() :: "+mjonPayVO.getStartDate());
|
||||||
|
System.out.println("mjonPayVO.getEndDate() :: "+mjonPayVO.getEndDate());
|
||||||
|
if(!DateUtils.dateChkAndValueChk(mjonPayVO.getStartDate(),mjonPayVO.getEndDate(), 12 )) {
|
||||||
|
System.out.println("???");
|
||||||
mjonPayVO.setStartDate(DateUtils.getDateDaysAgo(365));
|
mjonPayVO.setStartDate(DateUtils.getDateDaysAgo(365));
|
||||||
mjonPayVO.setEndDate(DateUtils.getCurrentDate());
|
mjonPayVO.setEndDate(DateUtils.getCurrentDate());
|
||||||
};
|
};
|
||||||
@ -2762,7 +2766,7 @@ public class MjonPayController {
|
|||||||
// 검색 데이터가 없거나
|
// 검색 데이터가 없거나
|
||||||
// 시작일자가 종료일자보다 이후이거나
|
// 시작일자가 종료일자보다 이후이거나
|
||||||
// 총 기간이 365일이 넘으면 현재일부터 365일 전 날짜를 넣어서 검색
|
// 총 기간이 365일이 넘으면 현재일부터 365일 전 날짜를 넣어서 검색
|
||||||
if(!DateUtils.dateChkAndValueChk(mjonMsgVO.getStartDate(),mjonMsgVO.getEndDate(), 365 )) {
|
if(!DateUtils.dateChkAndValueChk(mjonMsgVO.getStartDate(),mjonMsgVO.getEndDate(), 12 )) {
|
||||||
|
|
||||||
mjonMsgVO.setStartDate(DateUtils.getDateDaysAgo(365));
|
mjonMsgVO.setStartDate(DateUtils.getDateDaysAgo(365));
|
||||||
mjonMsgVO.setEndDate(DateUtils.getCurrentDate());
|
mjonMsgVO.setEndDate(DateUtils.getCurrentDate());
|
||||||
|
|||||||
@ -129,7 +129,7 @@ function customSampleListAjax(pageNo){
|
|||||||
//맞춤제작 내보관함 리스트
|
//맞춤제작 내보관함 리스트
|
||||||
function myCustomListAjax(pageNo){
|
function myCustomListAjax(pageNo){
|
||||||
|
|
||||||
if(!fn_cmndataValueChk("startDate", "endDate", 365)){
|
if(!fn_cmndataValueChk("startDate", "endDate", 12)){
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -54,7 +54,7 @@ function listLoad(subpage , searchFlag ){
|
|||||||
|
|
||||||
function linkPage(pageNo){
|
function linkPage(pageNo){
|
||||||
|
|
||||||
if(!fn_cmndataValueChk("startDate", "endDate", 365)){
|
if(!fn_cmndataValueChk("startDate", "endDate", 12)){
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -57,7 +57,7 @@ function setCalVal(val,targetObj){
|
|||||||
// 요금사용내역 리스트
|
// 요금사용내역 리스트
|
||||||
function payUserListAjax(pageNo){
|
function payUserListAjax(pageNo){
|
||||||
|
|
||||||
if(!fn_cmndataValueChk("startDate", "endDate", 365)){
|
if(!fn_cmndataValueChk("startDate", "endDate", 12)){
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -2,8 +2,7 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function fn_cmndataValueChk(startId, endId, chkMonth) {
|
||||||
function fn_cmndataValueChk(startId, endId, chkDay){
|
|
||||||
// 시작일자와 종료일자를 가져오기
|
// 시작일자와 종료일자를 가져오기
|
||||||
var startDate = document.getElementById(startId).value;
|
var startDate = document.getElementById(startId).value;
|
||||||
var endDate = document.getElementById(endId).value;
|
var endDate = document.getElementById(endId).value;
|
||||||
@ -24,17 +23,15 @@ function fn_cmndataValueChk(startId, endId, chkDay){
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 총 기간이 chkDay일을 넘는지 확인
|
// 종료일자를 기준으로 chkMonth 개월 전의 날짜 계산
|
||||||
var diffTime = Math.abs(end - start);
|
var maxStartDate = new Date(end);
|
||||||
var diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
|
maxStartDate.setMonth(maxStartDate.getMonth() - chkMonth);
|
||||||
if (diffDays > chkDay) {
|
|
||||||
|
|
||||||
var chkDayTxt = "";
|
// 시작일자가 종료일자 기준 chkMonth 개월 전보다 이전인지 확인
|
||||||
if(chkDay == 365){
|
console.log('start :: ',start);
|
||||||
chkDayTxt = '1년';
|
console.log('maxStartDate :: ',maxStartDate);
|
||||||
}
|
if (start <= maxStartDate) {
|
||||||
|
alert("총 검색 기간은 " + chkMonth + "개월을 넘을 수 없습니다.");
|
||||||
alert("총 검색 기간은 "+chkDayTxt+"을 넘을 수 없습니다.");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user