From 26c2c0374f92bf61360d425027882f5f0758ee5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EC=84=9D=20=EC=B5=9C?= Date: Mon, 24 Oct 2022 18:18:53 +0900 Subject: [PATCH] =?UTF-8?q?=EC=99=B8=EC=82=AC=EC=A0=95=EB=B3=B4=EB=B3=B4?= =?UTF-8?q?=EA=B3=A0=20=EC=9E=91=EC=97=85=EC=A4=91.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dbnt/faisp/config/ModalController.java | 4 + .../com/dbnt/faisp/faRpt/FaRptController.java | 13 ++- .../repository/FaRptReadUserRepository.java | 2 + .../faisp/faRpt/service/FaRptService.java | 56 ++++++++++- .../resources/mybatisMapper/FaRptMapper.xml | 5 + src/main/resources/static/js/common.js | 2 +- src/main/resources/static/js/faRpt/faRpt.js | 2 +- .../resources/static/js/modal/menuModal.js | 49 ++++++++++ .../resources/static/js/modal/userModal.js | 49 ++++++++++ src/main/resources/static/js/user/info.js | 50 +--------- .../templates/commonModal/menuModal.html | 2 +- .../templates/commonModal/userModal.html | 35 ++++--- .../resources/templates/faRpt/faRptBoard.html | 5 +- .../templates/faRpt/faRptViewModal.html | 93 +++++++++++++++++++ .../templates/faRpt/readUserRow.html | 20 ++-- src/main/resources/templates/user/myInfo.html | 3 +- 16 files changed, 307 insertions(+), 83 deletions(-) create mode 100644 src/main/resources/static/js/modal/menuModal.js create mode 100644 src/main/resources/static/js/modal/userModal.js create mode 100644 src/main/resources/templates/faRpt/faRptViewModal.html diff --git a/src/main/java/com/dbnt/faisp/config/ModalController.java b/src/main/java/com/dbnt/faisp/config/ModalController.java index 9e666da3..bdf2639d 100644 --- a/src/main/java/com/dbnt/faisp/config/ModalController.java +++ b/src/main/java/com/dbnt/faisp/config/ModalController.java @@ -1,5 +1,6 @@ package com.dbnt.faisp.config; +import com.dbnt.faisp.codeMgt.service.CodeMgtService; import com.dbnt.faisp.menuMgt.model.MenuMgt; import com.dbnt.faisp.menuMgt.service.MenuMgtService; import com.dbnt.faisp.userInfo.model.UserInfo; @@ -19,6 +20,7 @@ public class ModalController { private final MenuMgtService menuMgtService; private final UserInfoService userInfoService; + private final CodeMgtService codeMgtService; @GetMapping("/menuModal") public ModelAndView menuModalPage(@AuthenticationPrincipal UserInfo loginUser, MenuMgt menuMgt){ @@ -39,6 +41,8 @@ public class ModalController { if(userInfo.getUserStatus() == null || userInfo.getUserStatus().equals("")) { userInfo.setUserStatus("USC003"); } + mav.addObject("OgList", codeMgtService.selectCodeMgtList("OG")); + mav.addObject("OfcList", codeMgtService.selectCodeMgtList("OFC")); mav.addObject("userInfoList", userInfoService.selectUserInfoList(userInfo)); userInfo.setContentCnt(userInfoService.selectUserInfoListCnt(userInfo)); userInfo.setPaginationInfo(); diff --git a/src/main/java/com/dbnt/faisp/faRpt/FaRptController.java b/src/main/java/com/dbnt/faisp/faRpt/FaRptController.java index c7dda051..378d5ca5 100644 --- a/src/main/java/com/dbnt/faisp/faRpt/FaRptController.java +++ b/src/main/java/com/dbnt/faisp/faRpt/FaRptController.java @@ -3,6 +3,7 @@ package com.dbnt.faisp.faRpt; import com.dbnt.faisp.authMgt.service.AuthMgtService; import com.dbnt.faisp.codeMgt.service.CodeMgtService; import com.dbnt.faisp.faRpt.model.FaRptBoard; +import com.dbnt.faisp.faRpt.model.FaRptReadUser; import com.dbnt.faisp.faRpt.service.FaRptService; import com.dbnt.faisp.fpiMgt.affairPlan.model.PlanBoard; import com.dbnt.faisp.userInfo.model.UserInfo; @@ -27,10 +28,10 @@ public class FaRptController { public ModelAndView faRptBoard(@AuthenticationPrincipal UserInfo loginUser, FaRptBoard faRptBoard){ ModelAndView mav; if(faRptBoard.getDashboardFlag()){ - mav = new ModelAndView("/faRpt/faRptDashboard"); + mav = new ModelAndView("faRpt/faRptDashboard"); faRptBoard.setRowCnt(5); }else{ - mav = new ModelAndView("/faRpt/faRptBoard"); + mav = new ModelAndView("faRpt/faRptBoard"); } if(faRptBoard.getActiveTab()==null){ faRptBoard.setActiveTab("send"); @@ -97,4 +98,12 @@ public class FaRptController { faRptBoard.setMultipartFileList(request.getMultiFileMap().get("uploadFiles")); return faRptService.saveFaRptBoard(faRptBoard, deleteFileSeq); } + + @PostMapping("/selectedUserTable") + @ResponseBody + public ModelAndView selectedUserTable(@RequestBody List userList){ + ModelAndView mav = new ModelAndView("faRpt/readUserRow"); + mav.addObject("userList", userList); + return mav; + } } diff --git a/src/main/java/com/dbnt/faisp/faRpt/repository/FaRptReadUserRepository.java b/src/main/java/com/dbnt/faisp/faRpt/repository/FaRptReadUserRepository.java index d9a1d42e..9a12ab3a 100644 --- a/src/main/java/com/dbnt/faisp/faRpt/repository/FaRptReadUserRepository.java +++ b/src/main/java/com/dbnt/faisp/faRpt/repository/FaRptReadUserRepository.java @@ -7,4 +7,6 @@ import java.util.List; public interface FaRptReadUserRepository extends JpaRepository { List findByFaRptKey(Integer faRptKey); + + void deleteByFaRptKey(Integer faRptKey); } diff --git a/src/main/java/com/dbnt/faisp/faRpt/service/FaRptService.java b/src/main/java/com/dbnt/faisp/faRpt/service/FaRptService.java index 0f307cfc..6da4c279 100644 --- a/src/main/java/com/dbnt/faisp/faRpt/service/FaRptService.java +++ b/src/main/java/com/dbnt/faisp/faRpt/service/FaRptService.java @@ -4,6 +4,7 @@ import com.dbnt.faisp.config.BaseService; import com.dbnt.faisp.config.FileInfo; import com.dbnt.faisp.faRpt.mapper.FaRptMapper; import com.dbnt.faisp.faRpt.model.FaRptBoard; +import com.dbnt.faisp.faRpt.model.FaRptFile; import com.dbnt.faisp.faRpt.model.FaRptReadUser; import com.dbnt.faisp.faRpt.repository.FaRptBoardRepository; import com.dbnt.faisp.faRpt.repository.FaRptFileRepository; @@ -38,8 +39,19 @@ public class FaRptService extends BaseService { return faRptMapper.selectFaRptCnt(faRptBoard); } + @Transactional public Integer saveFaRptBoard(FaRptBoard faRptBoard, List deleteFileSeq) { - return 0; + Integer faRptKey = faRptBoardRepository.save(faRptBoard).getFaRptKey(); + if(deleteFileSeq!=null && deleteFileSeq.size()>0){ + deleteFaRptFile(faRptKey, deleteFileSeq); + } + if(faRptBoard.getMultipartFileList() != null){ + saveUploadFiles(faRptKey, faRptBoard.getMultipartFileList()); + } + if(faRptBoard.getReadUserList() != null){ + saveFaRptReadUser(faRptKey, faRptBoard.getReadUserList()); + } + return faRptKey; } public FaRptBoard selectFaRptBoard(Integer faRptKey) { @@ -48,4 +60,46 @@ public class FaRptService extends BaseService { faRptBoard.setReadUserList(faRptReadUserRepository.findByFaRptKey(faRptKey)); return faRptBoard; } + + + + private void saveFaRptReadUser(Integer faRptKey, List readUserList) { + faRptReadUserRepository.deleteByFaRptKey(faRptKey); + for(FaRptReadUser readUser: readUserList){ + readUser.setFaRptKey(faRptKey); + } + faRptReadUserRepository.saveAll(readUserList); + } + + private void saveUploadFiles(Integer faRptKey, List multipartFileList) { + FaRptFile lastFile = faRptFileRepository.findTopByFaRptKeyOrderByFileSeq(faRptKey).orElse(null); + int fileSeq = lastFile==null?1:(lastFile.getFileSeq()+1); + for(MultipartFile file: multipartFileList){ + String saveName = UUID.randomUUID().toString(); + String path = locationPath+File.separator+"faRpt"+File.separator; + saveFile(file, new File(path+File.separator+saveName)); + + String originalFilename = file.getOriginalFilename(); + int extnIdx = originalFilename.lastIndexOf("."); + FaRptFile fileInfo = new FaRptFile(); + fileInfo.setFaRptKey(faRptKey); + fileInfo.setFileSeq(fileSeq++); + fileInfo.setOrigNm(originalFilename.substring(0, extnIdx)); + fileInfo.setFileExtn(originalFilename.substring(extnIdx+1)); + fileInfo.setConvNm(saveName); + fileInfo.setFileSize(calculationSize(file.getSize())); + fileInfo.setSavePath(path); + faRptFileRepository.save(fileInfo); + } + } + + private void deleteFaRptFile(Integer faRptKey, List deleteFileSeq) { + List fileList = faRptFileRepository.findByFaRptKey(faRptKey); + for(FaRptFile file: fileList){ + if(deleteFileSeq.contains(file.getFileSeq())){ + deleteStoredFile(new File(file.getSavePath(), file.getConvNm())); + faRptFileRepository.delete(file); + } + } + } } \ No newline at end of file diff --git a/src/main/resources/mybatisMapper/FaRptMapper.xml b/src/main/resources/mybatisMapper/FaRptMapper.xml index b7753e52..b70070b0 100644 --- a/src/main/resources/mybatisMapper/FaRptMapper.xml +++ b/src/main/resources/mybatisMapper/FaRptMapper.xml @@ -9,6 +9,11 @@ and a.wrt_user_seq = #{wrtUserSeq} + + and a.fa_rpt_key = (select fa_rpt_key + from fa_rpt_read_user + where user_seq = #{receiveUserSeq}) + and a.wrt_user_nm like '%'||#{wrtUserNm}||'%' diff --git a/src/main/resources/static/js/common.js b/src/main/resources/static/js/common.js index 504652c4..2fc61d56 100644 --- a/src/main/resources/static/js/common.js +++ b/src/main/resources/static/js/common.js @@ -37,7 +37,7 @@ function searchModalSubmit(pageIndex){ contentType: false, dataType:"html", success: function(html){ - $("#modalBody").empty().append(html) + $("#subModalBody").empty().append(html) if(selectedList !== undefined && selectedList.length>0){ setSelectedChkBox(); } diff --git a/src/main/resources/static/js/faRpt/faRpt.js b/src/main/resources/static/js/faRpt/faRpt.js index 1ed0b408..91728d02 100644 --- a/src/main/resources/static/js/faRpt/faRpt.js +++ b/src/main/resources/static/js/faRpt/faRpt.js @@ -21,7 +21,7 @@ $(document).on('click', '#addFaRptBtn', function (){ }) $(document).on('click', '#editFaRptBtn', function (){ $("#faRptViewModal").modal('hide'); - getFaRptEditModal(Number($("#faRptViewBody").find("[name='faRptKey']").val())); + getFaRptEditModal(Number($(this).attr("data-farptkey"))); }) $(document).on('click', '#addReadUserBtn', function (){ diff --git a/src/main/resources/static/js/modal/menuModal.js b/src/main/resources/static/js/modal/menuModal.js new file mode 100644 index 00000000..1c0ce308 --- /dev/null +++ b/src/main/resources/static/js/modal/menuModal.js @@ -0,0 +1,49 @@ +$(document).on('click', '.menuTr', function (){ + const checkBox = $(this).find(".menuCheckBox")[0] + checkBox.checked = !checkBox.checked; + if(checkBox.checked){ + selectedList.push({ + menuKey: Number(checkBox.value), + orderNum: selectedList.length+1, + cat1Cd: $(this).find(".cat1Cd").val(), + cat2Cd: $(this).find(".cat2Cd").val(), + cat3Cd: $(this).find(".cat3Cd").val(), + menuUrl: $(this).find(".menuUrl").val() + }); + }else{ + const tempList = []; + $.each(selectedList, function (idx, menu){ + if(menu.menuKey !== Number(checkBox.value)){ + menu.orderNum = idx+1; + tempList.push(menu); + } + }) + selectedList = tempList; + } +}) + +$(document).on('click', '#getMenuBtn', function (){ + $.ajax({ + type : 'POST', + url : "/myInfo/selectedMenuTable", + data : JSON.stringify(selectedList), + contentType: 'application/json', + dataType:"html", + beforeSend: function (xhr){ + xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); + }, + success : function(html) { + $("#dashboardConfigTbody").empty().append($(html)[1].children[0].children); + $("#menuModal").modal("hide"); + }, + error : function(xhr, status) { + + } + }) +}) + +function setSelectedChkBox(){ + $.each(selectedList, function (idx, item){ + $("[value="+item.menuKey+"]").prop("checked", true); + }) +} \ No newline at end of file diff --git a/src/main/resources/static/js/modal/userModal.js b/src/main/resources/static/js/modal/userModal.js new file mode 100644 index 00000000..58a6360c --- /dev/null +++ b/src/main/resources/static/js/modal/userModal.js @@ -0,0 +1,49 @@ +$(document).on('click', '.userInfoTr', function (){ + const checkBox = $(this).find(".userInfoCheckBox")[0] + checkBox.checked = !checkBox.checked; + + const userSeq = $(this).find(".userSeq").val(); + if(checkBox.checked){ + selectedList.push({ + userSeq: userSeq, + ogCd: $(this).find(".ogCd").val(), + ofcCd: $(this).find(".ofcCd").val(), + titleCd: $(this).find(".titleCd").val(), + userNm: $(this).find(".userNm").val() + }) + }else{ + const tempList = []; + $.each(selectedList, function (idx, user){ + if(user.userSeq !== userSeq){ + tempList.push(user); + } + }) + selectedList = tempList; + } +}) + +$(document).on('click', '#getMenuBtn', function (){ + $.ajax({ + type : 'POST', + url : "/faRpt/selectedUserTable", + data : JSON.stringify(selectedList), + contentType: 'application/json', + dataType:"html", + beforeSend: function (xhr){ + xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); + }, + success : function(html) { + $("#readUserRow").empty().append(html); + $("#userModal").modal("hide"); + }, + error : function(xhr, status) { + + } + }) +}) + +function setSelectedChkBox(){ + $.each(selectedList, function (idx, item){ + $(".userInfoCheckBox[value="+item.userSeq+"]").prop("checked", true); + }) +} \ No newline at end of file diff --git a/src/main/resources/static/js/user/info.js b/src/main/resources/static/js/user/info.js index b9b02010..dece88b4 100644 --- a/src/main/resources/static/js/user/info.js +++ b/src/main/resources/static/js/user/info.js @@ -1,4 +1,5 @@ let selectedList = []; + $(function (){ $.ajax({ type : 'GET', @@ -40,50 +41,6 @@ $(document).on('click', '#configDeleteBtn', function (){ orderNumSort(); }) -$(document).on('click', '.menuTr', function (){ - const checkBox = $(this).find(".menuCheckBox")[0] - checkBox.checked = !checkBox.checked; - if(checkBox.checked){ - selectedList.push({ - menuKey: Number(checkBox.value), - orderNum: selectedList.length+1, - cat1Cd: $(this).find(".cat1Cd").val(), - cat2Cd: $(this).find(".cat2Cd").val(), - cat3Cd: $(this).find(".cat3Cd").val(), - menuUrl: $(this).find(".menuUrl").val() - }); - }else{ - const tempList = []; - $.each(selectedList, function (idx, menu){ - if(menu.menuKey !== Number(checkBox.value)){ - menu.orderNum = idx+1; - tempList.push(menu); - } - }) - selectedList = tempList; - } -}) - -$(document).on('click', '#getMenuBtn', function (){ - $.ajax({ - type : 'POST', - url : "/myInfo/selectedMenuTable", - data : JSON.stringify(selectedList), - contentType: 'application/json', - dataType:"html", - beforeSend: function (xhr){ - xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); - }, - success : function(html) { - $("#dashboardConfigTbody").empty().append($(html)[1].children[0].children); - $("#menuModal").modal("hide"); - }, - error : function(xhr, status) { - - } - }) -}) - $(document).on('click', '#savePasswordBtn', function (){ if(passwordCheck()){ const formData = new FormData($("#modifyPasswordForm")[0]); @@ -161,11 +118,6 @@ function orderNumSort(){ return 0; }) } -function setSelectedChkBox(){ - $.each(selectedList, function (idx, item){ - $("[value="+item.menuKey+"]").prop("checked", true); - }) -} function passwordCheck(){ let returnFlag = true; diff --git a/src/main/resources/templates/commonModal/menuModal.html b/src/main/resources/templates/commonModal/menuModal.html index 7f7c7f4c..85bbed11 100644 --- a/src/main/resources/templates/commonModal/menuModal.html +++ b/src/main/resources/templates/commonModal/menuModal.html @@ -3,7 +3,7 @@
- +
- -
-
- -
+ + +
@@ -27,7 +20,7 @@
@@ -38,7 +31,7 @@
- +
@@ -51,7 +44,7 @@ - + @@ -62,9 +55,13 @@ - + + + + + @@ -89,19 +86,19 @@
소속 부서 계급
- +