단속사진관련 기능 이동(FileController -> Crdn06Controller)

main
이범준 2 months ago
parent 0ec6777157
commit 0171f96c4a

@ -8,11 +8,9 @@ import java.io.StringWriter;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.regex.Matcher; import java.util.regex.Matcher;
@ -44,15 +42,11 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import org.xml.sax.SAXException; 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.dao.FileMapper;
import cokr.xit.base.file.service.FileQuery; import cokr.xit.base.file.service.FileQuery;
import cokr.xit.base.file.service.bean.FileBean; 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.Crdn;
import cokr.xit.fims.crdn.dao.CrdnInfoMapper; 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.Sprt;
import cokr.xit.fims.sprt.service.bean.MediaBean; import cokr.xit.fims.sprt.service.bean.MediaBean;
import cokr.xit.foundation.Downloadable; import cokr.xit.foundation.Downloadable;
@ -72,9 +66,6 @@ public class FileController extends cokr.xit.base.file.web.FileController {
@Resource(name="mediaBean") @Resource(name="mediaBean")
private MediaBean mediaBean; private MediaBean mediaBean;
@Resource(name="crdnService")
private CrdnService crdnService;
@Override @Override
public ModelAndView getFileList(FileQuery req) { public ModelAndView getFileList(FileQuery req) {
ModelAndView mav = new ModelAndView("jsonView"); 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<FileInfo> newFileInfoList = new FileInfoFactory().makeFileInfos(relation, newFileList);
List<Map<String, Object>> 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<Map<String, Object>> 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<Map<String, Object>> 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<Map<String, Object>> 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 * @return
* @throws Exception * @throws Exception

@ -1,5 +1,6 @@
package cokr.xit.fims.crdn.web; package cokr.xit.fims.crdn.web;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -9,7 +10,9 @@ import javax.servlet.http.HttpServletRequest;
import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.CellStyle;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import cokr.xit.base.code.CommonCode; 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.Format;
import cokr.xit.base.docs.xls.Style; import cokr.xit.base.docs.xls.Style;
import cokr.xit.base.docs.xls.XLSWriter; 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.FileQuery;
import cokr.xit.base.file.service.bean.FileBean; 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.user.dao.UserMapper;
import cokr.xit.base.web.ApplicationController; import cokr.xit.base.web.ApplicationController;
import cokr.xit.fims.base.FimsUser; import cokr.xit.fims.base.FimsUser;
@ -397,4 +403,141 @@ public class Crdn06Controller extends ApplicationController {
.addObject("rtnMsg", rtnMsg); .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<FileInfo> newFileInfoList = new FileInfoFactory().makeFileInfos(relation, newFileList);
List<Map<String, Object>> 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<Map<String, Object>> 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<Map<String, Object>> 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<Map<String, Object>> 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);
}
} }

Loading…
Cancel
Save