diff --git a/README.md b/README.md index 28dc5692..f4693742 100644 --- a/README.md +++ b/README.md @@ -208,3 +208,19 @@ $("#btnClose").on('click', () => { }); ``` +## JSON Object ModelAndView에서 처리 +```js +// ModelAndView return +gridInfo={"next":null,"perPage":15,"page":1,"totalCount":15,"curRowData":{"regltSeCode":"01","extrlRegltCntcId":"000000001051"},"curRowPos":1,"curGridDataPos":0,"curGridDatas":[{"regltSeCode":"01","extrlRegltCntcId":"000000001051"},{"regltSeCode":"01","extrlRegltCntcId":"000000001052"},{"regltSeCode":"01","extrlRegltCntcId":"000000001065"}]} + +// jstl사용시 보안상의 이유로 " 문자를 " 치환 +// 아래와 같이 처리 +let gridInfo = ''; // string으로 +gridInfo = gridInfo.replace(/"/g, '"'); +gridInfo = JSON.parse(gridInfo); + +// escapeXml = "false" 사용 - xss 보안상 문제 발생 +let gridInfo = ; //객체이므로 "" 미사용 + +let gridInfo = ${gridInfo}; +``` diff --git a/src/main/java/kr/xit/fims/biz/ec/mapper/IEcCctvCrackdownMapper.java b/src/main/java/kr/xit/fims/biz/ec/mapper/IEcCctvCrackdownMapper.java index c5994e36..a785459b 100644 --- a/src/main/java/kr/xit/fims/biz/ec/mapper/IEcCctvCrackdownMapper.java +++ b/src/main/java/kr/xit/fims/biz/ec/mapper/IEcCctvCrackdownMapper.java @@ -11,7 +11,7 @@ import kr.xit.fims.biz.ec.model.CctvCrackdownDTO; @Mapper public interface IEcCctvCrackdownMapper { List selectEcExtrlRegltCntcs(final Map paraMap, final RowBounds rowBounds); - CctvCrackdownDTO.ExtrlRegltCntc selectEcExtrlRegltCntc(final String extrlRegltCntcId); + CctvCrackdownDTO.ExtrlRegltCntc selectEcExtrlRegltCntc(final T t); int insertEcExtrlRegltCntc(final CctvCrackdownDTO.ExtrlRegltCntc dto); void updateEcExtrlRegltCntc(final CctvCrackdownDTO.ExtrlRegltCntc dto); diff --git a/src/main/java/kr/xit/fims/biz/ec/service/EcCctvCrackdownService.java b/src/main/java/kr/xit/fims/biz/ec/service/EcCctvCrackdownService.java index 4693abbb..4555f878 100644 --- a/src/main/java/kr/xit/fims/biz/ec/service/EcCctvCrackdownService.java +++ b/src/main/java/kr/xit/fims/biz/ec/service/EcCctvCrackdownService.java @@ -70,8 +70,8 @@ public class EcCctvCrackdownService implements IEcCctvCrackdownService { @Override @Transactional(readOnly = true) - public CctvCrackdownDTO.ExtrlRegltCntc findExtrlRegltCntc(final String extrlRegltCntcId) { - return mapper.selectEcExtrlRegltCntc(extrlRegltCntcId); + public CctvCrackdownDTO.ExtrlRegltCntc findExtrlRegltCntc(final T t) { + return mapper.selectEcExtrlRegltCntc(t); } /** diff --git a/src/main/java/kr/xit/fims/biz/ec/service/IEcCctvCrackdownService.java b/src/main/java/kr/xit/fims/biz/ec/service/IEcCctvCrackdownService.java index 9107879d..6ce0dbbc 100644 --- a/src/main/java/kr/xit/fims/biz/ec/service/IEcCctvCrackdownService.java +++ b/src/main/java/kr/xit/fims/biz/ec/service/IEcCctvCrackdownService.java @@ -13,7 +13,7 @@ import kr.xit.framework.core.utils.XitCmmnUtil; public interface IEcCctvCrackdownService { List findExtrlRegltCntcs(final Map paraMap, final RowBounds rowBounds); - CctvCrackdownDTO.ExtrlRegltCntc findExtrlRegltCntc(final String extrlRegltCntcId); + CctvCrackdownDTO.ExtrlRegltCntc findExtrlRegltCntc(final T t); void saveCctvCrackdownDatas(final CctvCrackdownDTO.Request dto); void saveBusCctvCrackdownDatas(final FolderReqDTO dto); diff --git a/src/main/java/kr/xit/fims/biz/ec/web/EcCctvCrackdownController.java b/src/main/java/kr/xit/fims/biz/ec/web/EcCctvCrackdownController.java index 8ebe34f4..12bc83c8 100644 --- a/src/main/java/kr/xit/fims/biz/ec/web/EcCctvCrackdownController.java +++ b/src/main/java/kr/xit/fims/biz/ec/web/EcCctvCrackdownController.java @@ -57,28 +57,38 @@ public class EcCctvCrackdownController { } @RequestMapping(value = "/ecCctvCrackdownPopup") - public ModelAndView ecCctvCrackdownPopup(final String extrlRegltCntcId, final String regltSeCode){ + public ModelAndView ecCctvCrackdownPopup(final CctvCrackdownDTO.Request dto){ ModelAndView mav = new ModelAndView(FimsConst.FIMS_JSP_BASE_PATH +"ec/ecCctvCrackdownPopup.popup"); - String fileJobSeCode = FimsBizUtils.getFileJobSeCode(regltSeCode); - mav.addObject("extrlRegltCntcDTO", service - .findExtrlRegltCntc(extrlRegltCntcId)); + mav.addObject("extrDTO", service.findExtrlRegltCntc(dto.getExtrlRegltCntcId())); mav.addObject("attchFiles", fileService.findFilesByJobSeCodeAndJobId( CmmFileDTO.FileMst.builder() - .jobSeCode(fileJobSeCode) - .fileJobId(extrlRegltCntcId) + .jobSeCode(FimsBizUtils.getFileJobSeCode(dto.getRegltSeCode())) + .fileJobId(dto.getExtrlRegltCntcId()) .build())); return mav; } - @RequestMapping(value = "/findBusCctvCrackdownFiles") - public ModelAndView findBusCctvCrackdownFiles(final String dirPath){ - XitFileExplorerUtil explorer = new XitFileExplorerUtil(new DirectorySearch(dirPath)); - return ResultResponse.of( - explorer.getList().stream() - .filter(m->"Y".equals(m.get("isFile"))) - .collect(Collectors.toList()) - ); + @GetMapping(value = "/findExtrlRegltCntcs") + public ModelAndView findExtrlRegltCntcs(@RequestParam final Map paraMap) { + return ResultResponse.of(service.findExtrlRegltCntcs(paraMap, MybatisUtils.getPagingInfo(paraMap))); + } + + @RequestMapping(value = "/findExtrlRegltCntcAndAttchFiles") + public ModelAndView findExtrlRegltCntcAndAttchFiles(final CctvCrackdownDTO.Request dto) { + ModelAndView mav = new ModelAndView(FrameworkConstants.JSON_VIEW); + mav.addObject("extrDTO", service.findExtrlRegltCntc(dto)); + mav.addObject("attchFiles", fileService.findFilesByJobSeCodeAndJobId( + CmmFileDTO.FileMst.builder() + .jobSeCode(FimsBizUtils.getFileJobSeCode(dto.getRegltSeCode())) + .fileJobId(dto.getExtrlRegltCntcId()) + .build())); + return mav; + } + + @RequestMapping(value = "/findExtrlRegltCntc") + public ModelAndView findExtrlRegltCntc(final CctvCrackdownDTO.Request dto) { + return ResultResponse.of("extrDTO", service.findExtrlRegltCntc(dto)); } @PostMapping(value = "/saveCctvCrackdownDatas") @@ -99,11 +109,6 @@ public class EcCctvCrackdownController { return mav; } - @GetMapping(value = "/findExtrlRegltCntcs") - public ModelAndView findExtrlRegltCntcs(@RequestParam final Map paraMap) { - return ResultResponse.of(service.findExtrlRegltCntcs(paraMap, MybatisUtils.getPagingInfo(paraMap))); - } - @PostMapping("/modifyExtrlRegltCntc") public ModelAndView modifyExtrlRegltCntc(final CctvCrackdownDTO.ExtrlRegltCntc dto) { ModelAndView mav = new ModelAndView(FrameworkConstants.JSON_VIEW); @@ -141,6 +146,17 @@ public class EcCctvCrackdownController { return mav; } + @RequestMapping(value = "/findBusCctvCrackdownFiles") + public ModelAndView findBusCctvCrackdownFiles(final String dirPath){ + + XitFileExplorerUtil explorer = new XitFileExplorerUtil(new DirectorySearch(dirPath)); + return ResultResponse.of( + explorer.getList().stream() + .filter(m->"Y".equals(m.get("isFile"))) + .collect(Collectors.toList()) + ); + } + @RequestMapping("/findExtrlRegltCntcAttchFiles") public ModelAndView findExtrlRegltCntcAttchFiles(final String extrlRegltCntcId, final String regltSeCode) { return ResultResponse.of( diff --git a/src/main/java/kr/xit/framework/core/utils/json/ConvertHelper.java b/src/main/java/kr/xit/framework/core/utils/json/ConvertHelper.java index 110248c9..ecd8306c 100644 --- a/src/main/java/kr/xit/framework/core/utils/json/ConvertHelper.java +++ b/src/main/java/kr/xit/framework/core/utils/json/ConvertHelper.java @@ -1,14 +1,16 @@ package kr.xit.framework.core.utils.json; +import java.io.StringWriter; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.joda.JodaModule; -import lombok.NoArgsConstructor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.io.StringWriter; +import lombok.NoArgsConstructor; @NoArgsConstructor public class ConvertHelper{ @@ -40,7 +42,7 @@ public class ConvertHelper{ } } - public static Object objectToJson(String json, Class clazz){ + public static T objectToJson(String json, Class clazz){ try{ OBJECT_MAPPER.registerModule(new JodaModule()); return OBJECT_MAPPER.readValue(json, clazz); diff --git a/src/main/resources/props/local/globals.properties b/src/main/resources/props/local/globals.properties index af81308b..e182fe10 100644 --- a/src/main/resources/props/local/globals.properties +++ b/src/main/resources/props/local/globals.properties @@ -120,7 +120,7 @@ Globals.Xit.Bbs.useAt = Y # ############################################## # # //XitFramework \uC0AC\uC6A9\uC790 \uCEE4\uC2A4\uD140 \uD56D\uBAA9 # ############################################## # -debug.result.log.trace=false +debug.result.log.trace=true exception.log.trace=true # k byte diff --git a/src/main/webapp/WEB-INF/jsp/fims/biz/ec/ecCctvCrackdownMgtForm.jsp b/src/main/webapp/WEB-INF/jsp/fims/biz/ec/ecCctvCrackdownMgtForm.jsp index 59118afe..c418a448 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/biz/ec/ecCctvCrackdownMgtForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/biz/ec/ecCctvCrackdownMgtForm.jsp @@ -52,8 +52,6 @@ let GRID = null; var callbackSearch = () => fnBiz.search(); var pageNav = null; - //var unblockUI = () => $.unblockUI(); - //var popup = null; /* ******************************* * Biz function @@ -68,7 +66,6 @@ let popOption; switch (flag) { case "detail": - <%--url = ''; --%> url = fimsApiUrl.POPUP_CCTV_EC_EXTRL_REGLT_CNTC_INFO; popOption = {width: 900, height:800}; popTitle = "외부연계 데이타 상세"; @@ -92,21 +89,10 @@ popup = CmmPopup.open(url, params, popOption, popTitle); } ,onClickGrid: function(props){ - const {page, perPage, totalCount} = GRID.store.data.pageOptions; - // gridInfo = { - // curGridDatas: GRID.store.data.rawData - // ,curRowData: GRID.store.data.rawData[props.rowKey] - // ,curRowPos: (page - 1) * perPage + GRID.store.data.rawData[props.rowKey].rowKey + 1 - // ,curGridDataPos: GRID.store.data.rawData[props.rowKey].rowKey - // ,page - // ,perPage - // ,totalCount - // ,isNext: null - // } - // fnBiz.pagePopup('detail', {extrlRegltCntcId: gridInfo.curRowData.extrlRegltCntcId, regltSeCode: gridInfo.curRowData.regltSeCode}); - - - pageNav = new PageNavigation(GRID, props); + const gridDatas = GRID.store.data.rawData.map(d => { + return {extrlRegltCntcId: d.extrlRegltCntcId, regltSeCode: d.regltSeCode} + }) + pageNav = new PageNavigation(GRID, gridDatas, props.rowKey); fnBiz.pagePopup('detail', {extrlRegltCntcId: pageNav.gridInfo.curRowData.extrlRegltCntcId, regltSeCode: pageNav.gridInfo.curRowData.regltSeCode}); } } @@ -209,7 +195,6 @@ initialRequest: true, // 화면 load시 조회 안함 - default api: { readData: { - <%--url: ''--%> url: fimsApiUrl.FIND_CCTV_EC_EXTRL_REGLT_CNTCS ,serializer: (params) => fnAddPageInfo(document.frmSearch, params) } @@ -217,29 +202,15 @@ }; GRID = TuiGrid.of(gridOptions, gridDatasource, (res) => { - - // if(gridInfo !== null && gridInfo?.isNext !== 'undefinded' && gridInfo?.isNext !== null) { - // GRID.resetData(res.data?.contents); - // - // if(gridInfo.isNext){ - // gridInfo.curRowPos = (gridInfo.page - 1) * gridInfo.perPage + 1; - // gridInfo.curGridDataPos = 0; - // } else{ - // gridInfo.curRowPos = gridInfo.page * gridInfo.perPage; - // gridInfo.curGridDataPos = gridInfo.perPage - 1; - // } - // // grid page data position reset - // gridInfo.isNext = null; - // gridInfo.curGridDatas = GRID.store.data.rawData; - // gridInfo.curRowData = gridInfo.curGridDatas[gridInfo.curGridDataPos]; - // - // fnBiz.pagePopup('detail', {extrlRegltCntcId: gridInfo.curRowData.extrlRegltCntcId, regltSeCode: gridInfo.curRowData.regltSeCode}); - // } - // if(gridInfo?.isNext) gridInfo.isNext = null; - - if(pageNav?.gridInfo?.curRowData) { - //loadPageNavigation(res, GRID, {extrlRegltCntcId: gridInfo.curRowData.extrlRegltCntcId, regltSeCode: gridInfo.curRowData.regltSeCode}) - pageNav.loadNavigation(res, {extrlRegltCntcId: pageNav.gridInfo.curRowData.extrlRegltCntcId, regltSeCode: pageNav.gridInfo.curRowData.regltSeCode}) + const gridInfo = pageNav?.gridInfo; + if(gridInfo && gridInfo?.pageMove) { + const datas = res.data?.contents.map(d => { + return {extrlRegltCntcId: d.extrlRegltCntcId, regltSeCode: d.regltSeCode} + }); + pageNav.resetGrid(res, datas, (pagiNavigation)=>{ + pageNav = pagiNavigation; + fnBiz.pagePopup('detail', pageNav.gridInfo.curRowData); + }) } }); } diff --git a/src/main/webapp/WEB-INF/jsp/fims/biz/ec/ecCctvCrackdownPopup.jsp b/src/main/webapp/WEB-INF/jsp/fims/biz/ec/ecCctvCrackdownPopup.jsp index 3d4aaf9f..2096d6ff 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/biz/ec/ecCctvCrackdownPopup.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/biz/ec/ecCctvCrackdownPopup.jsp @@ -4,11 +4,12 @@ <%--rcvXmlDTO--%> +<%----%>