From 0171f96c4ade83c5bc568e4075dc5d1b5909b81b Mon Sep 17 00:00:00 2001 From: leebj Date: Thu, 5 Sep 2024 10:47:36 +0900 Subject: [PATCH] =?UTF-8?q?=EB=8B=A8=EC=86=8D=EC=82=AC=EC=A7=84=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20=EA=B8=B0=EB=8A=A5=20=EC=9D=B4=EB=8F=99(FileControl?= =?UTF-8?q?ler=20->=20Crdn06Controller)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xit/fims/base/web/FileController.java | 147 ------------------ .../xit/fims/crdn/web/Crdn06Controller.java | 143 +++++++++++++++++ 2 files changed, 143 insertions(+), 147 deletions(-) diff --git a/src/main/java/cokr/xit/fims/base/web/FileController.java b/src/main/java/cokr/xit/fims/base/web/FileController.java index af073d0e..ada61c96 100644 --- a/src/main/java/cokr/xit/fims/base/web/FileController.java +++ b/src/main/java/cokr/xit/fims/base/web/FileController.java @@ -8,11 +8,9 @@ import java.io.StringWriter; import java.net.URISyntaxException; import java.net.URLDecoder; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.List; -import java.util.Map; import java.util.function.Consumer; import java.util.regex.Matcher; @@ -44,15 +42,11 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; -import cokr.xit.base.file.FileInfo; -import cokr.xit.base.file.FileInfo.Relation; import cokr.xit.base.file.dao.FileMapper; import cokr.xit.base.file.service.FileQuery; import cokr.xit.base.file.service.bean.FileBean; -import cokr.xit.base.file.web.FileInfoFactory; import cokr.xit.fims.crdn.Crdn; import cokr.xit.fims.crdn.dao.CrdnInfoMapper; -import cokr.xit.fims.crdn.service.CrdnService; import cokr.xit.fims.sprt.Sprt; import cokr.xit.fims.sprt.service.bean.MediaBean; import cokr.xit.foundation.Downloadable; @@ -72,9 +66,6 @@ public class FileController extends cokr.xit.base.file.web.FileController { @Resource(name="mediaBean") private MediaBean mediaBean; - @Resource(name="crdnService") - private CrdnService crdnService; - @Override public ModelAndView getFileList(FileQuery req) { ModelAndView mav = new ModelAndView("jsonView"); @@ -141,144 +132,6 @@ public class FileController extends cokr.xit.base.file.web.FileController { } - @PostMapping(name= "단속 사진 추가", value = "/insertCrdnImageFile.do") - public ModelAndView insertCrdnImageFile(String crdnId, int atchFileCnt, MultipartFile[] newFileList) { - - boolean saved = false; - String retMessage = "[F] "; - if(newFileList == null || newFileList.length == 0 || newFileList[0] == null || newFileList[0].isEmpty()) { - throw new RuntimeException("파일 업로드 오류"); - } - - Relation relation = new Relation().setInfoType(Crdn.INF_TYPE).setInfoKey(crdnId); - List newFileInfoList = new FileInfoFactory().makeFileInfos(relation, newFileList); - - List> processList = new ArrayList<>(); - - int newFileSort = 999; - for(FileInfo newFileInfo : newFileInfoList) { - newFileInfo.setSortOrder(newFileSort++); - processList.add(Map.of("process", "insert", "obj", newFileInfo)); - } - - Crdn crdn = new Crdn(); - crdn.setCrdnId(crdnId); - crdn.setAtchFileCnt(atchFileCnt); - retMessage = crdnService.changeCrdnImageFile(crdn, processList); - - if (retMessage.contains("[S]")) { - saved = true; - } else { - saved = false; - } - - return new ModelAndView("jsonView") - .addObject("saved", saved) - .addObject("retMessage", retMessage); - - } - - @PostMapping(name= "단속 사진 수정", value = "/updateCrdnImageFile.do") - public ModelAndView updateCrdnImageFile(String crdnId, int atchFileCnt, - String beforeKey, int beforeOrder, MultipartFile modifyFile) { - - boolean saved = false; - String retMessage = "[F] "; - - if(modifyFile == null || modifyFile.isEmpty()) { - throw new RuntimeException("파일 업로드 오류"); - } - - Relation relation = new Relation().setInfoType(Crdn.INF_TYPE).setInfoKey(crdnId); - FileInfo modifyFileInfo = new FileInfoFactory().make(relation, modifyFile); - modifyFileInfo.setSortOrder(beforeOrder); - - List> processList = new ArrayList<>(); - processList.add(Map.of("process", "delete", "key", beforeKey)); - processList.add(Map.of("process", "insert", "obj", modifyFileInfo)); - - Crdn crdn = new Crdn(); - crdn.setCrdnId(crdnId); - crdn.setAtchFileCnt(atchFileCnt); - retMessage = crdnService.changeCrdnImageFile(crdn, processList); - - if (retMessage.contains("[S]")) { - saved = true; - } else { - saved = false; - } - - return new ModelAndView("jsonView") - .addObject("saved", saved) - .addObject("retMessage", retMessage); - - } - - @PostMapping(name= "단속 사진 삭제", value = "/deleteCrdnImageFile.do") - public ModelAndView deleteCrdnImageFile(String crdnId, int atchFileCnt, String[] deleteKeys) { - - boolean saved = false; - String retMessage = "[F] "; - - if(deleteKeys == null || deleteKeys.length == 0 || deleteKeys[0] == null || deleteKeys[0].isEmpty()) { - throw new RuntimeException("파일 삭제 오류"); - } - - List> processList = new ArrayList<>(); - for(String deleteKey : deleteKeys) { - processList.add(Map.of("process", "delete", "key", deleteKey)); - } - - Crdn crdn = new Crdn(); - crdn.setCrdnId(crdnId); - crdn.setAtchFileCnt(atchFileCnt); - retMessage = crdnService.changeCrdnImageFile(crdn, processList); - - if (retMessage.contains("[S]")) { - saved = true; - } else { - saved = false; - } - - return new ModelAndView("jsonView") - .addObject("saved", saved) - .addObject("retMessage", retMessage); - - } - - @PostMapping(name= "단속 사진 순서 변경", value = "/changeOrderCrdnImageFile.do") - public ModelAndView changeOrderCrdnImageFile(String crdnId, int atchFileCnt, String[] orderedKeys) { - - boolean saved = false; - String retMessage = "[F] "; - - if(orderedKeys == null || orderedKeys.length == 0 || orderedKeys[0] == null || orderedKeys[0].isEmpty()) { - throw new RuntimeException("파일 순서 변경 오류"); - } - - List> processList = new ArrayList<>(); - for(String orderedKey : orderedKeys) { - processList.add(Map.of("process", "order", "key", orderedKey)); - } - - Crdn crdn = new Crdn(); - crdn.setCrdnId(crdnId); - crdn.setAtchFileCnt(atchFileCnt); - retMessage = crdnService.changeCrdnImageFile(crdn, processList); - - if (retMessage.contains("[S]")) { - saved = true; - } else { - saved = false; - } - - return new ModelAndView("jsonView") - .addObject("saved", saved) - .addObject("retMessage", retMessage); - - } - - /** 메뉴얼을 다운로드한다. * @return 메뉴얼 파일 * @throws Exception diff --git a/src/main/java/cokr/xit/fims/crdn/web/Crdn06Controller.java b/src/main/java/cokr/xit/fims/crdn/web/Crdn06Controller.java index 2108a2f2..7765c82b 100644 --- a/src/main/java/cokr/xit/fims/crdn/web/Crdn06Controller.java +++ b/src/main/java/cokr/xit/fims/crdn/web/Crdn06Controller.java @@ -1,5 +1,6 @@ package cokr.xit.fims.crdn.web; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -9,7 +10,9 @@ import javax.servlet.http.HttpServletRequest; import org.apache.poi.ss.usermodel.CellStyle; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; import cokr.xit.base.code.CommonCode; @@ -18,8 +21,11 @@ import cokr.xit.base.docs.xls.Comment; import cokr.xit.base.docs.xls.Format; import cokr.xit.base.docs.xls.Style; import cokr.xit.base.docs.xls.XLSWriter; +import cokr.xit.base.file.FileInfo; +import cokr.xit.base.file.FileInfo.Relation; import cokr.xit.base.file.service.FileQuery; import cokr.xit.base.file.service.bean.FileBean; +import cokr.xit.base.file.web.FileInfoFactory; import cokr.xit.base.user.dao.UserMapper; import cokr.xit.base.web.ApplicationController; import cokr.xit.fims.base.FimsUser; @@ -397,4 +403,141 @@ public class Crdn06Controller extends ApplicationController { .addObject("rtnMsg", rtnMsg); } + + @PostMapping(name= "단속 사진 추가", value = "/insertCrdnImageFile.do") + public ModelAndView insertCrdnImageFile(String crdnId, int atchFileCnt, MultipartFile[] newFileList) { + + boolean saved = false; + String retMessage = "[F] "; + if(newFileList == null || newFileList.length == 0 || newFileList[0] == null || newFileList[0].isEmpty()) { + throw new RuntimeException("파일 업로드 오류"); + } + + Relation relation = new Relation().setInfoType(Crdn.INF_TYPE).setInfoKey(crdnId); + List newFileInfoList = new FileInfoFactory().makeFileInfos(relation, newFileList); + + List> processList = new ArrayList<>(); + + int newFileSort = 999; + for(FileInfo newFileInfo : newFileInfoList) { + newFileInfo.setSortOrder(newFileSort++); + processList.add(Map.of("process", "insert", "obj", newFileInfo)); + } + + Crdn crdn = new Crdn(); + crdn.setCrdnId(crdnId); + crdn.setAtchFileCnt(atchFileCnt); + retMessage = crdnService.changeCrdnImageFile(crdn, processList); + + if (retMessage.contains("[S]")) { + saved = true; + } else { + saved = false; + } + + return new ModelAndView("jsonView") + .addObject("saved", saved) + .addObject("retMessage", retMessage); + + } + + @PostMapping(name= "단속 사진 수정", value = "/updateCrdnImageFile.do") + public ModelAndView updateCrdnImageFile(String crdnId, int atchFileCnt, + String beforeKey, int beforeOrder, MultipartFile modifyFile) { + + boolean saved = false; + String retMessage = "[F] "; + + if(modifyFile == null || modifyFile.isEmpty()) { + throw new RuntimeException("파일 업로드 오류"); + } + + Relation relation = new Relation().setInfoType(Crdn.INF_TYPE).setInfoKey(crdnId); + FileInfo modifyFileInfo = new FileInfoFactory().make(relation, modifyFile); + modifyFileInfo.setSortOrder(beforeOrder); + + List> processList = new ArrayList<>(); + processList.add(Map.of("process", "delete", "key", beforeKey)); + processList.add(Map.of("process", "insert", "obj", modifyFileInfo)); + + Crdn crdn = new Crdn(); + crdn.setCrdnId(crdnId); + crdn.setAtchFileCnt(atchFileCnt); + retMessage = crdnService.changeCrdnImageFile(crdn, processList); + + if (retMessage.contains("[S]")) { + saved = true; + } else { + saved = false; + } + + return new ModelAndView("jsonView") + .addObject("saved", saved) + .addObject("retMessage", retMessage); + + } + + @PostMapping(name= "단속 사진 삭제", value = "/deleteCrdnImageFile.do") + public ModelAndView deleteCrdnImageFile(String crdnId, int atchFileCnt, String[] deleteKeys) { + + boolean saved = false; + String retMessage = "[F] "; + + if(deleteKeys == null || deleteKeys.length == 0 || deleteKeys[0] == null || deleteKeys[0].isEmpty()) { + throw new RuntimeException("파일 삭제 오류"); + } + + List> processList = new ArrayList<>(); + for(String deleteKey : deleteKeys) { + processList.add(Map.of("process", "delete", "key", deleteKey)); + } + + Crdn crdn = new Crdn(); + crdn.setCrdnId(crdnId); + crdn.setAtchFileCnt(atchFileCnt); + retMessage = crdnService.changeCrdnImageFile(crdn, processList); + + if (retMessage.contains("[S]")) { + saved = true; + } else { + saved = false; + } + + return new ModelAndView("jsonView") + .addObject("saved", saved) + .addObject("retMessage", retMessage); + + } + + @PostMapping(name= "단속 사진 순서 변경", value = "/changeOrderCrdnImageFile.do") + public ModelAndView changeOrderCrdnImageFile(String crdnId, int atchFileCnt, String[] orderedKeys) { + + boolean saved = false; + String retMessage = "[F] "; + + if(orderedKeys == null || orderedKeys.length == 0 || orderedKeys[0] == null || orderedKeys[0].isEmpty()) { + throw new RuntimeException("파일 순서 변경 오류"); + } + + List> processList = new ArrayList<>(); + for(String orderedKey : orderedKeys) { + processList.add(Map.of("process", "order", "key", orderedKey)); + } + + Crdn crdn = new Crdn(); + crdn.setCrdnId(crdnId); + crdn.setAtchFileCnt(atchFileCnt); + retMessage = crdnService.changeCrdnImageFile(crdn, processList); + + if (retMessage.contains("[S]")) { + saved = true; + } else { + saved = false; + } + + return new ModelAndView("jsonView") + .addObject("saved", saved) + .addObject("retMessage", retMessage); + + } }