diff --git a/src/main/java/itn/com/cmm/util/StringUtil.java b/src/main/java/itn/com/cmm/util/StringUtil.java index ecc7552d..0a0e7b9b 100644 --- a/src/main/java/itn/com/cmm/util/StringUtil.java +++ b/src/main/java/itn/com/cmm/util/StringUtil.java @@ -578,4 +578,26 @@ public class StringUtil { return ntceEndde; } + /* + * 검색 키워드 내용에 한글, 영문, 숫자를 제외한 특수문자가 있는 경우 검색이 안되도록 처리 + * + * + * */ + public static boolean getSearchKeywordValidation(String paramKeyword) { + + boolean resultType = false; + String keyword = paramKeyword; + + keyword = keyword.replaceAll("[ㄱ-ㅎㅏ-ㅣ가-힣a-zA-Z0-9 ]", ""); + + //검색어에 특수기호가 없어서 공백이 되는 경우만 true를 리턴한다. + if(keyword.equals("")) { + + resultType = true; + } + + return resultType; + + } + } \ No newline at end of file diff --git a/src/main/java/itn/let/mjo/msgcampain/web/MjonMsgCampainDataController.java b/src/main/java/itn/let/mjo/msgcampain/web/MjonMsgCampainDataController.java index 20e151d3..078c6873 100644 --- a/src/main/java/itn/let/mjo/msgcampain/web/MjonMsgCampainDataController.java +++ b/src/main/java/itn/let/mjo/msgcampain/web/MjonMsgCampainDataController.java @@ -1201,6 +1201,18 @@ public class MjonMsgCampainDataController { RedirectAttributes redirectAttributes) throws Exception { + //검색 키워드 체크 기능 추가 + String keyword = letterVO.getSearchKeyword(); + boolean searchKeyType = StringUtil.getSearchKeywordValidation(keyword); + + if(!searchKeyType) {//검색 결과 Null로 리턴함. + + List exceptionLetterList = new ArrayList<>(); + + model.addAttribute("resultLetterList", exceptionLetterList); + return "web/msgcampain/LetterListAjax"; + } + CateCode cateCode = new CateCode(); cateCode.setCateNo(letterVO.getCategoryCode()); CateCode cateCodeInfoVO = cmmnDetailCodeManageService.selectCateCodeInfo(cateCode); //카테고리 상세 조회 @@ -1341,6 +1353,18 @@ public class MjonMsgCampainDataController { RedirectAttributes redirectAttributes) throws Exception { + //검색 키워드 체크 기능 추가 + String keyword = letterVO.getSearchKeyword(); + boolean searchKeyType = StringUtil.getSearchKeywordValidation(keyword); + + if(!searchKeyType) {//검색 결과 Null로 리턴함. + + List exceptionPhoList = new ArrayList<>(); + + model.addAttribute("resultPhoList", exceptionPhoList); + return "web/msgcampain/PhotoListAjax"; + } + CateCode cateCode = new CateCode(); cateCode.setCateNo(letterVO.getCategoryCode()); CateCode cateCodeInfoVO = cmmnDetailCodeManageService.selectCateCodeInfo(cateCode); //카테고리 상세 조회 @@ -1555,6 +1579,19 @@ public class MjonMsgCampainDataController { mjonMsgDataVO.setUserId(userId); + + //검색 키워드 체크 기능 추가 + String keyword = mjonMsgDataVO.getSearchKeyword(); + boolean searchKeyType = StringUtil.getSearchKeywordValidation(keyword); + + if(!searchKeyType) {//검색 결과 Null로 리턴함. + + List exceptionMyMsgList = new ArrayList<>(); + + model.addAttribute("resultMyMsgList", exceptionMyMsgList); + return "web/msgcampain/MyMsgListAjax"; + } + //그림 문자 리스트 불러오기 //LetterVO letterVO = new LetterVO(); if(mjonMsgDataVO.getPageUnit() != 10) { diff --git a/src/main/java/itn/let/mjo/msgdata/web/MjonMsgDataController.java b/src/main/java/itn/let/mjo/msgdata/web/MjonMsgDataController.java index ba2d0444..1942fd60 100644 --- a/src/main/java/itn/let/mjo/msgdata/web/MjonMsgDataController.java +++ b/src/main/java/itn/let/mjo/msgdata/web/MjonMsgDataController.java @@ -1131,6 +1131,20 @@ public class MjonMsgDataController { SessionStatus status, RedirectAttributes redirectAttributes) throws Exception { + + //검색 키워드 체크 기능 추가 + String keyword = letterVO.getSearchKeyword(); + boolean searchKeyType = StringUtil.getSearchKeywordValidation(keyword); + + if(!searchKeyType) {//검색 결과 Null로 리턴함. + + List exceptionLetterList = new ArrayList<>(); + + model.addAttribute("resultLetterList", exceptionLetterList); + return "web/msgdata/LetterListAjax"; + } + + CateCode cateCode = new CateCode(); cateCode.setCateNo(letterVO.getCategoryCode()); CateCode cateCodeInfoVO = cmmnDetailCodeManageService.selectCateCodeInfo(cateCode); //카테고리 상세 조회 @@ -1303,6 +1317,18 @@ public class MjonMsgDataController { letterVO.setCategoryCode(letterVO.getUpperCateNo().substring(0, 3)); }*/ + //검색 키워드 체크 기능 추가 + String keyword = letterVO.getSearchKeyword(); + boolean searchKeyType = StringUtil.getSearchKeywordValidation(keyword); + + if(!searchKeyType) {//검색 결과 Null로 리턴함. + + List exceptionPhoList = new ArrayList<>(); + + model.addAttribute("resultPhoList", exceptionPhoList); + return "web/msgdata/PhotoListAjax"; + } + CateCode cateCode = new CateCode(); cateCode.setCateNo(letterVO.getCategoryCode()); CateCode cateCodeInfoVO = cmmnDetailCodeManageService.selectCateCodeInfo(cateCode); //카테고리 상세 조회 @@ -1528,6 +1554,20 @@ public class MjonMsgDataController { if(loginVO == null) { return "redirect:/web/main/mainPage.do"; } + + + //검색 키워드 체크 기능 추가 + String keyword = mjonMsgDataVO.getSearchKeyword(); + boolean searchKeyType = StringUtil.getSearchKeywordValidation(keyword); + + if(!searchKeyType) {//검색 결과 Null로 리턴함. + + List exceptionMyMsgList = new ArrayList<>(); + + model.addAttribute("resultPhoList", exceptionMyMsgList); + return "web/msgdata/MyMsgListAjax"; + } + mjonMsgDataVO.setUserId(userId); @@ -5064,14 +5104,15 @@ public class MjonMsgDataController { * 2023-04-24 우영두 * * */ - String keyword = mjonMsgDataVO.getSearchKeyword(); - keyword = keyword.replaceAll("[ㄱ-ㅎㅏ-ㅣ가-힣a-zA-Z0-9 ]", ""); - if(!keyword.equals("")) { + String keyword = mjonMsgDataVO.getSearchKeyword(); + boolean searchKeyType = StringUtil.getSearchKeywordValidation(keyword); + + if(!searchKeyType) { modelAndView.addObject("status", "wordFail"); modelAndView.addObject("message", "잘못된 검색어 입니다."); - return modelAndView; + return modelAndView; } //욕설 및 금지 단어 리스트 불러오기