--- src/main/java/itn/com/cmm/util/DateUtils.java
+++ src/main/java/itn/com/cmm/util/DateUtils.java
... | ... | @@ -143,47 +143,43 @@ |
| 143 | 143 |
* @param dateVal |
| 144 | 144 |
* @return |
| 145 | 145 |
*/ |
| 146 |
- public static boolean dateChkAndValueChk(String searchStartDate, String searchEndDate, int dateVal) {
|
|
| 147 |
- |
|
| 146 |
+ public static boolean dateChkAndValueChk(String searchStartDate, String searchEndDate, int months) {
|
|
| 147 |
+ boolean isValid = true; |
|
| 148 | 148 |
|
| 149 |
- boolean isValid = true; |
|
| 150 | 149 |
|
| 151 |
- // 날짜 형식 지정 |
|
| 152 |
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
|
|
| 150 |
+ // 날짜 검증 |
|
| 151 |
+ LocalDate startDate = null; |
|
| 152 |
+ LocalDate endDate = null; |
|
| 153 | 153 |
|
| 154 |
- //날짜 검증 |
|
| 155 |
- LocalDate startDate = null; |
|
| 156 |
- LocalDate endDate = null; |
|
| 154 |
+ // 검색 시작일자와 종료일자가 있는지 체크 |
|
| 155 |
+ if (searchStartDate == null || searchStartDate.isEmpty() || searchEndDate == null || searchEndDate.isEmpty()) {
|
|
| 156 |
+ isValid = false; |
|
| 157 |
+ } |
|
| 157 | 158 |
|
| 158 |
- // 검색 시작일자와 종료일자가 있는지 체크 |
|
| 159 |
- if (searchStartDate == null || searchStartDate.isEmpty() || searchEndDate == null || searchEndDate.isEmpty()) {
|
|
| 160 |
- isValid = false; |
|
| 161 |
- } |
|
| 159 |
+ // 날짜 형식으로 변환 |
|
| 160 |
+ if (isValid) {
|
|
| 161 |
+ try {
|
|
| 162 |
+ startDate = LocalDate.parse(searchStartDate, SLUSH_FORMATTER); |
|
| 163 |
+ endDate = LocalDate.parse(searchEndDate, SLUSH_FORMATTER); |
|
| 164 |
+ } catch (Exception e) {
|
|
| 165 |
+ isValid = false; |
|
| 166 |
+ } |
|
| 167 |
+ } |
|
| 162 | 168 |
|
| 163 |
- // 날짜 형식으로 변환 |
|
| 164 |
- if (isValid) {
|
|
| 165 |
- try {
|
|
| 166 |
- startDate = LocalDate.parse(searchStartDate, formatter); |
|
| 167 |
- endDate = LocalDate.parse(searchEndDate, formatter); |
|
| 168 |
- } catch (Exception e) {
|
|
| 169 |
- isValid = false; |
|
| 170 |
- } |
|
| 171 |
- } |
|
| 169 |
+ // 시작일자가 종료일자보다 이후인지 확인 |
|
| 170 |
+ if (isValid && startDate.isAfter(endDate)) {
|
|
| 171 |
+ isValid = false; |
|
| 172 |
+ } |
|
| 172 | 173 |
|
| 173 |
- // 시작일자가 종료일자보다 이후인지 확인 |
|
| 174 |
- if (isValid && startDate.isAfter(endDate)) {
|
|
| 175 |
- isValid = false; |
|
| 176 |
- } |
|
| 174 |
+ // 총 기간이 지정한 개월 수를 넘는지 확인 |
|
| 175 |
+ if (isValid) {
|
|
| 176 |
+ long monthsBetween = ChronoUnit.MONTHS.between(startDate, endDate); |
|
| 177 |
+ System.out.println("monthsBetween : "+ monthsBetween);
|
|
| 178 |
+ if (monthsBetween >= months) {
|
|
| 179 |
+ isValid = false; |
|
| 180 |
+ } |
|
| 181 |
+ } |
|
| 177 | 182 |
|
| 178 |
- // 총 기간이 365일을 넘는지 확인 |
|
| 179 |
- if (isValid) {
|
|
| 180 |
- long daysBetween = ChronoUnit.DAYS.between(startDate, endDate); |
|
| 181 |
- if (daysBetween > dateVal) {
|
|
| 182 |
- isValid = false; |
|
| 183 |
- } |
|
| 184 |
- } |
|
| 185 |
- System.out.println("isValid : "+ isValid);
|
|
| 186 |
- |
|
| 187 |
- return isValid; |
|
| 188 |
- } |
|
| 183 |
+ return isValid; |
|
| 184 |
+ } |
|
| 189 | 185 |
} |
--- src/main/java/itn/let/mjo/msgCustom/web/MjonMsgCustomWebController.java
+++ src/main/java/itn/let/mjo/msgCustom/web/MjonMsgCustomWebController.java
... | ... | @@ -229,7 +229,7 @@ |
| 229 | 229 |
// 검색 데이터가 없거나 |
| 230 | 230 |
// 시작일자가 종료일자보다 이후이거나 |
| 231 | 231 |
// 총 기간이 365일이 넘으면 현재일부터 365일 전 날짜를 넣어서 검색 |
| 232 |
- if(!DateUtils.dateChkAndValueChk(mjonMsgCustomVO.getSearchStartDate(),mjonMsgCustomVO.getSearchEndDate(), 365 )) {
|
|
| 232 |
+ if(!DateUtils.dateChkAndValueChk(mjonMsgCustomVO.getSearchStartDate(),mjonMsgCustomVO.getSearchEndDate(), 12 )) {
|
|
| 233 | 233 |
|
| 234 | 234 |
mjonMsgCustomVO.setSearchStartDate(DateUtils.getDateDaysAgo(365)); |
| 235 | 235 |
mjonMsgCustomVO.setSearchEndDate(DateUtils.getCurrentDate()); |
--- src/main/java/itn/let/mjo/pay/web/MjonPayController.java
+++ src/main/java/itn/let/mjo/pay/web/MjonPayController.java
... | ... | @@ -2108,7 +2108,11 @@ |
| 2108 | 2108 |
// mjonPayVO.setStartDate(mjonPayVO.getStartDate() == null ? DateUtil.getDateDaysAgo(365) : mjonPayVO.getStartDate()); |
| 2109 | 2109 |
// mjonPayVO.setEndDate(mjonPayVO.getEndDate() == null ? DateUtil.getCurrentDate() : mjonPayVO.getEndDate()); |
| 2110 | 2110 |
|
| 2111 |
- if(!DateUtils.dateChkAndValueChk(mjonPayVO.getSearchStartDate(),mjonPayVO.getSearchEndDate(), 365 )) {
|
|
| 2111 |
+ System.out.println("???");
|
|
| 2112 |
+ System.out.println("mjonPayVO.getStartDate() :: "+mjonPayVO.getStartDate());
|
|
| 2113 |
+ System.out.println("mjonPayVO.getEndDate() :: "+mjonPayVO.getEndDate());
|
|
| 2114 |
+ if(!DateUtils.dateChkAndValueChk(mjonPayVO.getStartDate(),mjonPayVO.getEndDate(), 12 )) {
|
|
| 2115 |
+ System.out.println("???");
|
|
| 2112 | 2116 |
mjonPayVO.setStartDate(DateUtils.getDateDaysAgo(365)); |
| 2113 | 2117 |
mjonPayVO.setEndDate(DateUtils.getCurrentDate()); |
| 2114 | 2118 |
}; |
... | ... | @@ -2762,7 +2766,7 @@ |
| 2762 | 2766 |
// 검색 데이터가 없거나 |
| 2763 | 2767 |
// 시작일자가 종료일자보다 이후이거나 |
| 2764 | 2768 |
// 총 기간이 365일이 넘으면 현재일부터 365일 전 날짜를 넣어서 검색 |
| 2765 |
- if(!DateUtils.dateChkAndValueChk(mjonMsgVO.getStartDate(),mjonMsgVO.getEndDate(), 365 )) {
|
|
| 2769 |
+ if(!DateUtils.dateChkAndValueChk(mjonMsgVO.getStartDate(),mjonMsgVO.getEndDate(), 12 )) {
|
|
| 2766 | 2770 |
|
| 2767 | 2771 |
mjonMsgVO.setStartDate(DateUtils.getDateDaysAgo(365)); |
| 2768 | 2772 |
mjonMsgVO.setEndDate(DateUtils.getCurrentDate()); |
--- src/main/webapp/WEB-INF/jsp/web/custom/MsgCustomView.jsp
+++ src/main/webapp/WEB-INF/jsp/web/custom/MsgCustomView.jsp
... | ... | @@ -129,7 +129,7 @@ |
| 129 | 129 |
//맞춤제작 내보관함 리스트 |
| 130 | 130 |
function myCustomListAjax(pageNo){
|
| 131 | 131 |
|
| 132 |
- if(!fn_cmndataValueChk("startDate", "endDate", 365)){
|
|
| 132 |
+ if(!fn_cmndataValueChk("startDate", "endDate", 12)){
|
|
| 133 | 133 |
return; |
| 134 | 134 |
}; |
| 135 | 135 |
|
--- src/main/webapp/WEB-INF/jsp/web/pay/PayList.jsp
+++ src/main/webapp/WEB-INF/jsp/web/pay/PayList.jsp
... | ... | @@ -54,7 +54,7 @@ |
| 54 | 54 |
|
| 55 | 55 |
function linkPage(pageNo){
|
| 56 | 56 |
|
| 57 |
- if(!fn_cmndataValueChk("startDate", "endDate", 365)){
|
|
| 57 |
+ if(!fn_cmndataValueChk("startDate", "endDate", 12)){
|
|
| 58 | 58 |
return; |
| 59 | 59 |
}; |
| 60 | 60 |
|
--- src/main/webapp/WEB-INF/jsp/web/pay/PayUserSWList.jsp
+++ src/main/webapp/WEB-INF/jsp/web/pay/PayUserSWList.jsp
... | ... | @@ -57,7 +57,7 @@ |
| 57 | 57 |
// 요금사용내역 리스트 |
| 58 | 58 |
function payUserListAjax(pageNo){
|
| 59 | 59 |
|
| 60 |
- if(!fn_cmndataValueChk("startDate", "endDate", 365)){
|
|
| 60 |
+ if(!fn_cmndataValueChk("startDate", "endDate", 12)){
|
|
| 61 | 61 |
return; |
| 62 | 62 |
}; |
| 63 | 63 |
|
--- src/main/webapp/publish/js/dateUtils.js
+++ src/main/webapp/publish/js/dateUtils.js
... | ... | @@ -2,41 +2,38 @@ |
| 2 | 2 |
|
| 3 | 3 |
}); |
| 4 | 4 |
|
| 5 |
- |
|
| 6 |
-function fn_cmndataValueChk(startId, endId, chkDay){
|
|
| 7 |
- // 시작일자와 종료일자를 가져오기 |
|
| 8 |
- var startDate = document.getElementById(startId).value; |
|
| 9 |
- var endDate = document.getElementById(endId).value; |
|
| 10 |
- |
|
| 11 |
- // 날짜가 입력되었는지 확인 |
|
| 12 |
- if (!startDate || !endDate) {
|
|
| 13 |
- alert("검색 시작일자와 종료일자를 입력해주세요.");
|
|
| 14 |
- return false; |
|
| 15 |
- } |
|
| 16 |
- |
|
| 17 |
- // 날짜 형식으로 변환 |
|
| 18 |
- var start = new Date(startDate); |
|
| 19 |
- var end = new Date(endDate); |
|
| 20 |
- |
|
| 21 |
- // 날짜 유효성 체크 |
|
| 22 |
- if (isNaN(start.getTime()) || isNaN(end.getTime())) {
|
|
| 23 |
- alert("유효한 날짜 형식을 입력해주세요.");
|
|
| 24 |
- return false; |
|
| 25 |
- } |
|
| 26 |
- |
|
| 27 |
- // 총 기간이 chkDay일을 넘는지 확인 |
|
| 28 |
- var diffTime = Math.abs(end - start); |
|
| 29 |
- var diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)); |
|
| 30 |
- if (diffDays > chkDay) {
|
|
| 31 |
- |
|
| 32 |
- var chkDayTxt = ""; |
|
| 33 |
- if(chkDay == 365){
|
|
| 34 |
- chkDayTxt = '1년'; |
|
| 35 |
- } |
|
| 36 |
- |
|
| 37 |
- alert("총 검색 기간은 "+chkDayTxt+"을 넘을 수 없습니다.");
|
|
| 38 |
- return false; |
|
| 39 |
- } |
|
| 40 |
- |
|
| 41 |
- return true; |
|
| 42 |
-}(No newline at end of file) |
|
| 5 |
+function fn_cmndataValueChk(startId, endId, chkMonth) {
|
|
| 6 |
+ // 시작일자와 종료일자를 가져오기 |
|
| 7 |
+ var startDate = document.getElementById(startId).value; |
|
| 8 |
+ var endDate = document.getElementById(endId).value; |
|
| 9 |
+ |
|
| 10 |
+ // 날짜가 입력되었는지 확인 |
|
| 11 |
+ if (!startDate || !endDate) {
|
|
| 12 |
+ alert("검색 시작일자와 종료일자를 입력해주세요.");
|
|
| 13 |
+ return false; |
|
| 14 |
+ } |
|
| 15 |
+ |
|
| 16 |
+ // 날짜 형식으로 변환 |
|
| 17 |
+ var start = new Date(startDate); |
|
| 18 |
+ var end = new Date(endDate); |
|
| 19 |
+ |
|
| 20 |
+ // 날짜 유효성 체크 |
|
| 21 |
+ if (isNaN(start.getTime()) || isNaN(end.getTime())) {
|
|
| 22 |
+ alert("유효한 날짜 형식을 입력해주세요.");
|
|
| 23 |
+ return false; |
|
| 24 |
+ } |
|
| 25 |
+ |
|
| 26 |
+ // 종료일자를 기준으로 chkMonth 개월 전의 날짜 계산 |
|
| 27 |
+ var maxStartDate = new Date(end); |
|
| 28 |
+ maxStartDate.setMonth(maxStartDate.getMonth() - chkMonth); |
|
| 29 |
+ |
|
| 30 |
+ // 시작일자가 종료일자 기준 chkMonth 개월 전보다 이전인지 확인 |
|
| 31 |
+ console.log('start :: ',start);
|
|
| 32 |
+ console.log('maxStartDate :: ',maxStartDate);
|
|
| 33 |
+ if (start <= maxStartDate) {
|
|
| 34 |
+ alert("총 검색 기간은 " + chkMonth + "개월을 넘을 수 없습니다.");
|
|
| 35 |
+ return false; |
|
| 36 |
+ } |
|
| 37 |
+ |
|
| 38 |
+ return true; |
|
| 39 |
+} |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?