From 5fdad9364215bb73f2779af5c4ad6b6ab2efd98d Mon Sep 17 00:00:00 2001 From: "Jonguk. Lim" Date: Thu, 1 Dec 2022 02:35:40 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20DTO=20inner=20class=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/kr/xit/fims/biz/FimsConst.java | 2 +- ...eqDTO.java => NatlNewspaperRcvReqDTO.java} | 3 +- .../ec/service/EcNatlNewspaperService.java | 33 ++-- .../ec/service/IEcNatlNewspaperService.java | 4 +- .../biz/ec/web/EcNatlNewspaperController.java | 4 +- .../biz/cmm/mapper/ICmmFileDtlMapper.java | 36 ++-- .../biz/cmm/mapper/ICmmFileMapper.java | 20 +-- .../biz/cmm/mapper/ICmmFileMstMapper.java | 62 +++---- .../framework/biz/cmm/model/CmmFileDTO.java | 162 ++++++++++++++---- .../biz/cmm/model/CmmFileDtlDTO.java | 59 ------- .../biz/cmm/model/CmmFileMstDTO.java | 59 ------- .../biz/cmm/service/CmmFileService.java | 21 ++- .../biz/cmm/service/ICmmFileService.java | 9 +- .../biz/cmm/web/CmmFileMgtController.java | 90 +++++++++- .../framework/cmm/cmm-file-mysql-mapper.xml | 8 +- 15 files changed, 312 insertions(+), 260 deletions(-) rename src/main/java/kr/xit/fims/biz/ec/model/{EcNatlNewspaperRcvReqDTO.java => NatlNewspaperRcvReqDTO.java} (87%) delete mode 100644 src/main/java/kr/xit/framework/biz/cmm/model/CmmFileDtlDTO.java delete mode 100644 src/main/java/kr/xit/framework/biz/cmm/model/CmmFileMstDTO.java diff --git a/src/main/java/kr/xit/fims/biz/FimsConst.java b/src/main/java/kr/xit/fims/biz/FimsConst.java index ddf0cb22..5a89ebd9 100644 --- a/src/main/java/kr/xit/fims/biz/FimsConst.java +++ b/src/main/java/kr/xit/fims/biz/FimsConst.java @@ -51,7 +51,7 @@ public class FimsConst { */ @Getter @AllArgsConstructor - public enum FfnlgCode { + public enum SysCode { PVS("PVS", "주정차위반과태료") ,BPV("BPV", "전용차로위반과태료") ,DPV("DPV", "장애인전용주차구역") diff --git a/src/main/java/kr/xit/fims/biz/ec/model/EcNatlNewspaperRcvReqDTO.java b/src/main/java/kr/xit/fims/biz/ec/model/NatlNewspaperRcvReqDTO.java similarity index 87% rename from src/main/java/kr/xit/fims/biz/ec/model/EcNatlNewspaperRcvReqDTO.java rename to src/main/java/kr/xit/fims/biz/ec/model/NatlNewspaperRcvReqDTO.java index 8f52853a..91e8b05e 100644 --- a/src/main/java/kr/xit/fims/biz/ec/model/EcNatlNewspaperRcvReqDTO.java +++ b/src/main/java/kr/xit/fims/biz/ec/model/NatlNewspaperRcvReqDTO.java @@ -3,7 +3,6 @@ package kr.xit.fims.biz.ec.model; import java.io.Serializable; import java.util.List; -import kr.xit.framework.biz.cmm.model.CmmFileDtlDTO; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.EqualsAndHashCode; @@ -19,7 +18,7 @@ import lombok.ToString; @EqualsAndHashCode @Builder @ToString -public class EcNatlNewspaperRcvReqDTO implements Serializable { +public class NatlNewspaperRcvReqDTO implements Serializable { private static final long serialVersionUID = 1L; private String filePath; diff --git a/src/main/java/kr/xit/fims/biz/ec/service/EcNatlNewspaperService.java b/src/main/java/kr/xit/fims/biz/ec/service/EcNatlNewspaperService.java index 9f11d3f0..362a5bea 100644 --- a/src/main/java/kr/xit/fims/biz/ec/service/EcNatlNewspaperService.java +++ b/src/main/java/kr/xit/fims/biz/ec/service/EcNatlNewspaperService.java @@ -24,11 +24,10 @@ import kr.xit.fims.biz.FimsConst; import kr.xit.fims.biz.ec.mapper.IEcCtznSttemntMapper; import kr.xit.fims.biz.ec.mapper.IEcNatlNewspaperMapper; import kr.xit.fims.biz.ec.model.CtznSttemntDTO; -import kr.xit.fims.biz.ec.model.EcNatlNewspaperRcvReqDTO; +import kr.xit.fims.biz.ec.model.NatlNewspaperRcvReqDTO; import kr.xit.fims.biz.ec.model.NatlNewspaperRcvDTO; import kr.xit.fims.biz.ec.model.NatlNewspaperRcvXmlDTO; -import kr.xit.framework.biz.cmm.model.CmmFileDtlDTO; -import kr.xit.framework.biz.cmm.model.CmmFileMstDTO; +import kr.xit.framework.biz.cmm.model.CmmFileDTO; import kr.xit.framework.biz.cmm.service.ICmmFileService; import kr.xit.framework.support.exception.BizRuntimeException; import kr.xit.framework.support.util.Checks; @@ -74,7 +73,7 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService { @SuppressWarnings("ConstantConditions") @Override @Transactional - public void saveEsbRvcParse(final EcNatlNewspaperRcvReqDTO dto) { + public void saveEsbRvcParse(final NatlNewspaperRcvReqDTO dto) { String filePath = dto.getFilePath(); AtomicInteger index = new AtomicInteger(); // CmmFileMstDTO fstMstDTO = null; @@ -106,8 +105,8 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService { ctznSttemntMapper.insertEcCtznSttemnt(ctznSttemntDTO); index.set(0); - CmmFileMstDTO fstMstDTO = null; - CmmFileDtlDTO pngDtlDTO = null; + CmmFileDTO.FileMst fstMstDTO = null; + CmmFileDTO.FileDtl pngDtlDTO = null; for(CtznSttemntDTO.CtznSttemntDetailDTO dtl : ctznSttemntDTO.getSttemntDetailDTOs()){ ctznSttemntMapper.insertEcCtznSttemntDetail(dtl); @@ -144,7 +143,7 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService { if (fstMstDTO == null || fstMstDTO.getCmmFileDtls().size() == 0) throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, "시민신고 첨부 파일 처리중 오류가 발생하였습니다."); - for (CmmFileDtlDTO dtlDto : fstMstDTO.getCmmFileDtls()) { + for (CmmFileDTO.FileDtl dtlDto : fstMstDTO.getCmmFileDtls()) { if (Objects.equals(dtlDto.getFileExtsn(), "png")) { pngDtlDTO = dtlDto; break; @@ -159,7 +158,7 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService { }); } - public void saveCtznSttemnt(final EcNatlNewspaperRcvReqDTO dto){ + public void saveCtznSttemnt(final NatlNewspaperRcvReqDTO dto){ } @@ -183,7 +182,7 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService { dto.setInterfaceSeqN(xmlDto.getInterfaceSeqN()); dto.setInsttCode(xmlDto.getAncCodeV()); //TODO: 재정의 후 적용 - dto.setSysCode("88"); + dto.setSysCode(FimsConst.SysCode.PVS.getCode()); dto.setCvplSe(xmlDto.getPetiGubunC()); dto.setCvplReqstNo(xmlDto.getPetiNoC()); dto.setCvplRceptNo(xmlDto.getCivilNoC()); @@ -236,7 +235,7 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService { //공통 추가 항목 dtlDto.setInterfaceSeqN(xmlDto.getInterfaceSeqN()); - dtlDto.setRegister(""); + dtlDto.setRegister(getUserUniqId()); dtlDto.setCtznSttemntDetailProcessSttus(FimsConst.CtznSttemntStatusCode.UNTREATED.getCode()); dtlList.add(dtlDto); isFirst = false; @@ -338,7 +337,7 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService { } - private CmmFileMstDTO saveAllAppendFiles( + private CmmFileDTO.FileMst saveAllAppendFiles( NatlNewspaperRcvXmlDTO xmlDto, NatlNewspaperRcvXmlDTO.AppendFileInfoDTO appendFileDto, CtznSttemntDTO.CtznSttemntDetailDTO sttemntDetailDTO, @@ -377,7 +376,7 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService { throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, e.getMessage()); } } - CmmFileMstDTO fileMstDTO = new CmmFileMstDTO(); + CmmFileDTO.FileMst fileMstDTO = new CmmFileDTO.FileMst(); fileMstDTO.setJobSeCode(FimsConst.FileJobSeCode.NATL_NEWS_PAPER_RCV.getCode()); fileMstDTO.setFileJobId(sttemntDetailDTO.getInterfaceSeqN()+sttemntDetailDTO.getCtznSttemntDetailSn()); fileMstDTO.setUploadeJobPath(uploadNewsPaperPath); @@ -391,7 +390,7 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService { //TODO: 단속정보별 파일 저장 하도록 적용 필요 - 2건 단속자료면 1번은 1번 파일만, 2번은 2번 파일만 //TODO: 단속정보를 보여줄 때는 모든 이미지 정보 보여준다(insterfaceSeqN 별로 - 어느 DTL항목 파일인지는 당근 표시해야지!!!) //TODO: .png는 각각 set - 파일 업로드는 1번만 - private CmmFileMstDTO saveAppendFiles( + private CmmFileDTO.FileMst saveAppendFiles( NatlNewspaperRcvXmlDTO.AppendFileInfoDTO apndFileDTO, CtznSttemntDTO.CtznSttemntDetailDTO stmtDtlDTO, int index, @@ -448,7 +447,7 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService { throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, e.getMessage()); } - CmmFileMstDTO fileMstDTO = new CmmFileMstDTO(); + CmmFileDTO.FileMst fileMstDTO = new CmmFileDTO.FileMst(); fileMstDTO.setJobSeCode(FimsConst.FileJobSeCode.NATL_NEWS_PAPER_RCV.getCode()); fileMstDTO.setFileJobId(stmtDtlDTO.getInterfaceSeqN()+stmtDtlDTO.getCtznSttemntDetailSn()); fileMstDTO.setUploadeJobPath(uploadNewsPaperPath); @@ -457,10 +456,10 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService { return cmmFileService.saveFiles(fileMstDTO, mfList); } - private CmmFileMstDTO saveFstOverAppendFiles( + private CmmFileDTO.FileMst saveFstOverAppendFiles( final NatlNewspaperRcvXmlDTO.AppendFileInfoDTO apndFileDTO, final CtznSttemntDTO.CtznSttemntDetailDTO stmtDtlDTO, - final CmmFileDtlDTO pngFileDtlDto, + final CmmFileDTO.FileDtl pngFileDtlDto, int index) { // 첨부 파일 생성 @@ -521,7 +520,7 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService { } */ - CmmFileMstDTO fileMstDTO = new CmmFileMstDTO(); + CmmFileDTO.FileMst fileMstDTO = new CmmFileDTO.FileMst(); fileMstDTO.setJobSeCode(FimsConst.FileJobSeCode.NATL_NEWS_PAPER_RCV.getCode()); fileMstDTO.setFileJobId(stmtDtlDTO.getInterfaceSeqN()+stmtDtlDTO.getCtznSttemntDetailSn()); fileMstDTO.setUploadeJobPath(uploadNewsPaperPath); diff --git a/src/main/java/kr/xit/fims/biz/ec/service/IEcNatlNewspaperService.java b/src/main/java/kr/xit/fims/biz/ec/service/IEcNatlNewspaperService.java index 9c27ddbb..05d5bcd5 100644 --- a/src/main/java/kr/xit/fims/biz/ec/service/IEcNatlNewspaperService.java +++ b/src/main/java/kr/xit/fims/biz/ec/service/IEcNatlNewspaperService.java @@ -5,12 +5,12 @@ import java.util.Map; import org.apache.ibatis.session.RowBounds; -import kr.xit.fims.biz.ec.model.EcNatlNewspaperRcvReqDTO; +import kr.xit.fims.biz.ec.model.NatlNewspaperRcvReqDTO; import kr.xit.fims.biz.ec.model.NatlNewspaperRcvDTO; import kr.xit.framework.core.utils.XitCmmnUtil; public interface IEcNatlNewspaperService { - void saveEsbRvcParse(final EcNatlNewspaperRcvReqDTO dto); + void saveEsbRvcParse(final NatlNewspaperRcvReqDTO dto); List findNatlNewspaers(final Map paraMap, final RowBounds rowBounds); diff --git a/src/main/java/kr/xit/fims/biz/ec/web/EcNatlNewspaperController.java b/src/main/java/kr/xit/fims/biz/ec/web/EcNatlNewspaperController.java index 9cc2342e..81d6e5b0 100644 --- a/src/main/java/kr/xit/fims/biz/ec/web/EcNatlNewspaperController.java +++ b/src/main/java/kr/xit/fims/biz/ec/web/EcNatlNewspaperController.java @@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.ModelAndView; import kr.xit.fims.biz.FimsConst; -import kr.xit.fims.biz.ec.model.EcNatlNewspaperRcvReqDTO; +import kr.xit.fims.biz.ec.model.NatlNewspaperRcvReqDTO; import kr.xit.fims.biz.ec.service.IEcNatlNewspaperService; import kr.xit.framework.core.constants.FrameworkConstants; import kr.xit.framework.core.model.ResultResponse; @@ -62,7 +62,7 @@ public class EcNatlNewspaperController { } @PostMapping(value = "/saveNatlNewspaers") - public ModelAndView saveNatlNewspaer(@RequestBody final EcNatlNewspaperRcvReqDTO dto) { + public ModelAndView saveNatlNewspaer(@RequestBody final NatlNewspaperRcvReqDTO dto) { ModelAndView mav = new ModelAndView(FrameworkConstants.JSON_VIEW); service.saveEsbRvcParse(dto); diff --git a/src/main/java/kr/xit/framework/biz/cmm/mapper/ICmmFileDtlMapper.java b/src/main/java/kr/xit/framework/biz/cmm/mapper/ICmmFileDtlMapper.java index 4a018757..4a698e70 100644 --- a/src/main/java/kr/xit/framework/biz/cmm/mapper/ICmmFileDtlMapper.java +++ b/src/main/java/kr/xit/framework/biz/cmm/mapper/ICmmFileDtlMapper.java @@ -1,18 +1,18 @@ -package kr.xit.framework.biz.cmm.mapper; - -import java.util.Collection; -import java.util.Optional; - -import egovframework.rte.psl.dataaccess.mapper.Mapper; -import kr.xit.framework.biz.cmm.model.CmmFileDtlDTO; - -@Mapper -public interface ICmmFileDtlMapper { - Collection selectByFileMstId(String fileMstId); - - int insertCmmFileDtl(CmmFileDtlDTO cmmFileDtl); - - Optional selectByFileMstIdAndOrgFileNmIgnoreCase(String fileMstId, String orgFileNm); - - int deleteCmmFileDtlById(CmmFileDtlDTO cmmFileDtl); -} +// package kr.xit.framework.biz.cmm.mapper; +// +// import java.util.Collection; +// import java.util.Optional; +// +// import egovframework.rte.psl.dataaccess.mapper.Mapper; +// import kr.xit.framework.biz.cmm.model.CmmFileDtlDTO; +// +// @Mapper +// public interface ICmmFileDtlMapper { +// Collection selectByFileMstId(String fileMstId); +// +// int insertCmmFileDtl(CmmFileDtlDTO cmmFileDtl); +// +// Optional selectByFileMstIdAndOrgFileNmIgnoreCase(String fileMstId, String orgFileNm); +// +// int deleteCmmFileDtlById(CmmFileDtlDTO cmmFileDtl); +// } diff --git a/src/main/java/kr/xit/framework/biz/cmm/mapper/ICmmFileMapper.java b/src/main/java/kr/xit/framework/biz/cmm/mapper/ICmmFileMapper.java index 4a28f850..3e088a7f 100644 --- a/src/main/java/kr/xit/framework/biz/cmm/mapper/ICmmFileMapper.java +++ b/src/main/java/kr/xit/framework/biz/cmm/mapper/ICmmFileMapper.java @@ -1,14 +1,10 @@ package kr.xit.framework.biz.cmm.mapper; -import java.util.Collection; import java.util.List; import java.util.Optional; -import org.apache.poi.ss.formula.functions.T; - import egovframework.rte.psl.dataaccess.mapper.Mapper; -import kr.xit.framework.biz.cmm.model.CmmFileDtlDTO; -import kr.xit.framework.biz.cmm.model.CmmFileMstDTO; +import kr.xit.framework.biz.cmm.model.CmmFileDTO; @SuppressWarnings("MybatisXMapperMethodInspection") @Mapper @@ -16,9 +12,9 @@ public interface ICmmFileMapper { //------------------------------------------------------------- // CmmFileMaster //------------------------------------------------------------- - Optional selectCmmFileMastr(final String fileMstId); + Optional selectCmmFileMastr(final String fileMstId); - int insertCmmFileMastr(final CmmFileMstDTO cmmFileMst); + int insertCmmFileMastr(final CmmFileDTO.FileMst cmmFileMst); @@ -27,11 +23,11 @@ public interface ICmmFileMapper { //------------------------------------------------------------- - List selectCmmFileDetails(final String fileMstId); + List selectCmmFileDetails(final String fileMstId); - int insertCmmFileDetail(final CmmFileDtlDTO cmmFileDtl); + int insertCmmFileDetail(final CmmFileDTO.FileDtl cmmFileDtl); - Optional selectCmmFileDetail(final CmmFileDtlDTO dto); + Optional selectCmmFileDetail(final CmmFileDTO.FileDtl dto); /** *
@@ -42,8 +38,8 @@ public interface ICmmFileMapper {
      * @return List
      * 
*/ - List selectFilesByJobSeCodeAndJobId(final CmmFileMstDTO dto); + List selectFilesByJobSeCodeAndJobId(final CmmFileDTO.FileMst dto); - int deleteCmmFileDetail(final CmmFileDtlDTO cmmFileDtl); + int deleteCmmFileDetail(final CmmFileDTO.FileDtl cmmFileDtl); } diff --git a/src/main/java/kr/xit/framework/biz/cmm/mapper/ICmmFileMstMapper.java b/src/main/java/kr/xit/framework/biz/cmm/mapper/ICmmFileMstMapper.java index 51ffb7e0..afbe358e 100644 --- a/src/main/java/kr/xit/framework/biz/cmm/mapper/ICmmFileMstMapper.java +++ b/src/main/java/kr/xit/framework/biz/cmm/mapper/ICmmFileMstMapper.java @@ -1,31 +1,31 @@ -package kr.xit.framework.biz.cmm.mapper; - -import java.util.Collection; -import java.util.Optional; - -import egovframework.rte.psl.dataaccess.mapper.Mapper; -import kr.xit.framework.biz.cmm.model.CmmFileDtlDTO; -import kr.xit.framework.biz.cmm.model.CmmFileMstDTO; - -@Mapper -public interface ICmmFileMstMapper { - //------------------------------------------------------------- - // CmmFileMaster - //------------------------------------------------------------- - Optional selectByFileMstId(final String fileMstId); - - int insertCmmFileMst(CmmFileMstDTO cmmFileMst); - - - - //------------------------------------------------------------- - // CmmFileDtl - //------------------------------------------------------------- - //Collection selectByFileMstId(String fileMstId); - - int insertCmmFileDtl(CmmFileDtlDTO cmmFileDtl); - - Optional selectByFileMstIdAndOrgFileNmIgnoreCase(String fileMstId, String orgFileNm); - - int deleteCmmFileDtlById(CmmFileDtlDTO cmmFileDtl); -} +// package kr.xit.framework.biz.cmm.mapper; +// +// import java.util.Collection; +// import java.util.Optional; +// +// import egovframework.rte.psl.dataaccess.mapper.Mapper; +// import kr.xit.framework.biz.cmm.model.CmmFileDtlDTO; +// import kr.xit.framework.biz.cmm.model.CmmFileMstDTO; +// +// @Mapper +// public interface ICmmFileMstMapper { +// //------------------------------------------------------------- +// // CmmFileMaster +// //------------------------------------------------------------- +// Optional selectByFileMstId(final String fileMstId); +// +// int insertCmmFileMst(CmmFileMstDTO cmmFileMst); +// +// +// +// //------------------------------------------------------------- +// // CmmFileDtl +// //------------------------------------------------------------- +// //Collection selectByFileMstId(String fileMstId); +// +// int insertCmmFileDtl(CmmFileDtlDTO cmmFileDtl); +// +// Optional selectByFileMstIdAndOrgFileNmIgnoreCase(String fileMstId, String orgFileNm); +// +// int deleteCmmFileDtlById(CmmFileDtlDTO cmmFileDtl); +// } diff --git a/src/main/java/kr/xit/framework/biz/cmm/model/CmmFileDTO.java b/src/main/java/kr/xit/framework/biz/cmm/model/CmmFileDTO.java index 83d58db9..729e1edf 100644 --- a/src/main/java/kr/xit/framework/biz/cmm/model/CmmFileDTO.java +++ b/src/main/java/kr/xit/framework/biz/cmm/model/CmmFileDTO.java @@ -1,6 +1,8 @@ package kr.xit.framework.biz.cmm.model; import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; import org.springframework.web.multipart.MultipartFile; @@ -12,37 +14,131 @@ import lombok.NoArgsConstructor; import lombok.Setter; import lombok.ToString; -@Getter -@Setter -@NoArgsConstructor -@AllArgsConstructor // Builder 사용시 필요 -@EqualsAndHashCode -@Builder -@ToString -public class CmmFileDTO implements Serializable { - private static final long SerialVersionUID = 1L; - - /** - * 파일 마스터 ID(length = 40) - UUID로 생성 - */ - private String fileMastrId; - - /** - * 파일업무분류구분코드(ex. Board) - */ - private String jobSeCode; - - /** - * 파일업무ID(example = "BOARD001") - * DB pk값 - 파일분류구분코드 + 파일업무ID로 식별 가능 - */ - private String fileJobId; - - private String register; - - /** - * 업로드 파일 객체 - */ - private MultipartFile[] files; - //private List files; +public class CmmFileDTO { + + @Setter + @Getter + @NoArgsConstructor + @AllArgsConstructor + @EqualsAndHashCode + @Builder + @ToString + public static class FileMst implements Serializable { + private static final long serialVersionUID = 5741919760452445573L; + + /** + * 파일 마스터 ID(length = 40) - UUID로 생성 + */ + private String fileMastrId; + + /** + * 파일업무분류구분코드(ex. Board) + */ + private String jobSeCode; + + /** + * 파일업무ID(example = "BOARD001") + * DB pk값 - 파일분류구분코드 + 파일업무ID로 식별 가능 + */ + private String fileJobId; + + /** + * 업무별 업로드 Path : ex) board / natl-newspaper + * properties 설정해서 사용 할 것 + */ + private String uploadeJobPath; + + /** + * 업무명 아래의 경로를 세분화 할지 지정 + * Y:년 단위, M: 월, D: 일 + * 미지정시 uploadeJobPath 까지로 분류 + */ + private String fileDirPath; + private String register; + + private List cmmFileDtls = new ArrayList<>(); + } + + @Getter + @Setter + @NoArgsConstructor + @AllArgsConstructor + @EqualsAndHashCode + @Builder + @ToString + public static class FileDtl implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 파일 마스터 ID(length = 40) - UUID로 생성 + */ + private String fileMastrId; + + /** + * 파일 ID(length = 40) - UUID로 생성 + */ + private String fileId; + + /** + * 원본파일명 + */ + private String orginlFileNm; + + /** + * 파일콘텐츠타입 + */ + private String fileCntntsTy; + + /** + * 파일확장자 + */ + private String fileExtsn; + + /** + * 파일용량 + */ + private Long fileCpcty; + + /** + * 파일경로 + */ + private String fileCours; + + private String register; + } + + @Getter + @Setter + @NoArgsConstructor + @AllArgsConstructor + @EqualsAndHashCode + @Builder + @ToString + public static class Request implements Serializable { + private static final long SerialVersionUID = 1L; + + /** + * 파일 마스터 ID(length = 40) - UUID로 생성 + */ + private String fileMastrId; + + /** + * 파일업무분류구분코드(ex. Board) + */ + private String jobSeCode; + + /** + * 파일업무ID(example = "BOARD001") + * DB pk값 - 파일분류구분코드 + 파일업무ID로 식별 가능 + */ + private String fileJobId; + + private String register; + + /** + * 업로드 파일 객체 + */ + private MultipartFile[] files; + //private List files; + } } diff --git a/src/main/java/kr/xit/framework/biz/cmm/model/CmmFileDtlDTO.java b/src/main/java/kr/xit/framework/biz/cmm/model/CmmFileDtlDTO.java deleted file mode 100644 index ddc051a5..00000000 --- a/src/main/java/kr/xit/framework/biz/cmm/model/CmmFileDtlDTO.java +++ /dev/null @@ -1,59 +0,0 @@ -package kr.xit.framework.biz.cmm.model; - -import java.io.Serializable; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.ToString; - -@Getter -@Setter -@NoArgsConstructor -@AllArgsConstructor -@EqualsAndHashCode -@Builder -@ToString -public class CmmFileDtlDTO implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * 파일 마스터 ID(length = 40) - UUID로 생성 - */ - private String fileMastrId; - - /** - * 파일 ID(length = 40) - UUID로 생성 - */ - private String fileId; - - /** - * 원본파일명 - */ - private String orginlFileNm; - - /** - * 파일콘텐츠타입 - */ - private String fileCntntsTy; - - /** - * 파일확장자 - */ - private String fileExtsn; - - /** - * 파일용량 - */ - private Long fileCpcty; - - /** - * 파일경로 - */ - private String fileCours; - - private String register; -} diff --git a/src/main/java/kr/xit/framework/biz/cmm/model/CmmFileMstDTO.java b/src/main/java/kr/xit/framework/biz/cmm/model/CmmFileMstDTO.java deleted file mode 100644 index 16366b43..00000000 --- a/src/main/java/kr/xit/framework/biz/cmm/model/CmmFileMstDTO.java +++ /dev/null @@ -1,59 +0,0 @@ -package kr.xit.framework.biz.cmm.model; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.ToString; - -@Getter -@Setter -@NoArgsConstructor -@AllArgsConstructor -@EqualsAndHashCode -@Builder -@ToString -public class CmmFileMstDTO implements Serializable { - private static final long serialVersionUID = 5741919760452445573L; - - /** - * 파일 마스터 ID(length = 40) - UUID로 생성 - */ - private String fileMastrId; - - /** - * 파일업무분류구분코드(ex. Board) - */ - private String jobSeCode; - - /** - * 파일업무ID(example = "BOARD001") - * DB pk값 - 파일분류구분코드 + 파일업무ID로 식별 가능 - */ - private String fileJobId; - - private String register; - - /** - * 업무별 업로드 Path : ex) board / natl-newspaper - * properties 설정해서 사용 할 것 - */ - private String uploadeJobPath; - - /** - * 업무명 아래의 경로를 세분화 할지 지정 - * Y:년 단위, M: 월, D: 일 - * 미지정시 uploadeJobPath 까지로 분류 - */ - private String fileDirPath; - - private List cmmFileDtls = new ArrayList<>(); -} diff --git a/src/main/java/kr/xit/framework/biz/cmm/service/CmmFileService.java b/src/main/java/kr/xit/framework/biz/cmm/service/CmmFileService.java index 3ee522ba..1c66a0d6 100644 --- a/src/main/java/kr/xit/framework/biz/cmm/service/CmmFileService.java +++ b/src/main/java/kr/xit/framework/biz/cmm/service/CmmFileService.java @@ -15,8 +15,7 @@ import org.springframework.web.multipart.MultipartFile; import kr.xit.fims.biz.FimsConst; import kr.xit.framework.biz.cmm.mapper.ICmmFileMapper; -import kr.xit.framework.biz.cmm.model.CmmFileDtlDTO; -import kr.xit.framework.biz.cmm.model.CmmFileMstDTO; +import kr.xit.framework.biz.cmm.model.CmmFileDTO; import kr.xit.framework.support.exception.BizRuntimeException; import kr.xit.framework.support.util.Checks; import kr.xit.framework.support.util.CommUtils; @@ -46,10 +45,10 @@ public class CmmFileService implements ICmmFileService { @Override @Transactional(readOnly = true) - public CmmFileMstDTO findFiles(final String fileMstId) { + public CmmFileDTO.FileMst findFiles(final String fileMstId) { Assert.notNull(fileMstId, "대상 파일[fileMstId]을 선택해 주세요."); - CmmFileMstDTO cmmFileMst = mapper.selectCmmFileMastr(fileMstId).orElse(null); + CmmFileDTO.FileMst cmmFileMst = mapper.selectCmmFileMastr(fileMstId).orElse(null); // CmmFileDtlIds cmmFileDtlIds = new CmmFileDtlIds(); // cmmFileDtlIds.setFileMstId(cmmFileMst.getFileMstId()); @@ -59,7 +58,7 @@ public class CmmFileService implements ICmmFileService { @Override @Transactional - public CmmFileMstDTO saveFiles(final CmmFileMstDTO fileMstDTO, final List files) { + public CmmFileDTO.FileMst saveFiles(final CmmFileDTO.FileMst fileMstDTO, final List files) { Assert.notNull(fileMstDTO, "파일 정보가 존재하지 않습니다."); Assert.notNull(fileMstDTO.getJobSeCode(), "파일 구분 코드[fileCtgCd] 정보가 존재하지 않습니다."); Assert.notNull(fileMstDTO.getFileJobId(), "파일 업무 ID[fileBizId] 정보가 존재하지 않습니다."); @@ -91,13 +90,13 @@ public class CmmFileService implements ICmmFileService { File file = new File(fileUploadPath); if(!file.exists()) file.mkdirs(); - List cmmFileDtls = new ArrayList<>(); + List cmmFileDtls = new ArrayList<>(); for(MultipartFile mf : files){ if(!mf.isEmpty()) { String orgFileName = ""; try { orgFileName = StringUtils.cleanPath(Objects.requireNonNull(mf.getOriginalFilename())); - CmmFileDtlDTO fileDtlDTO = CmmFileDtlDTO.builder() + CmmFileDTO.FileDtl fileDtlDTO = CmmFileDTO.FileDtl.builder() .fileMastrId(fileMstDTO.getFileMastrId()) .fileId(CommUtils.getStringFromUUID()) .fileCours(makePath) @@ -151,7 +150,7 @@ public class CmmFileService implements ICmmFileService { @Override @Transactional - public CmmFileMstDTO saveCtznSttemntFiles(final CmmFileMstDTO fileMstDTO, final List files, final CmmFileDtlDTO pngFileDtlDto) { + public CmmFileDTO.FileMst saveCtznSttemntFiles(final CmmFileDTO.FileMst fileMstDTO, final List files, final CmmFileDTO.FileDtl pngFileDtlDto) { Assert.notNull(fileMstDTO, "파일 정보가 존재하지 않습니다."); Assert.notNull(fileMstDTO.getJobSeCode(), "파일 구분 코드[fileCtgCd] 정보가 존재하지 않습니다."); Assert.notNull(fileMstDTO.getFileJobId(), "파일 업무 ID[fileBizId] 정보가 존재하지 않습니다."); @@ -183,13 +182,13 @@ public class CmmFileService implements ICmmFileService { File file = new File(fileUploadPath); if(!file.exists()) file.mkdirs(); - List cmmFileDtls = new ArrayList<>(); + List cmmFileDtls = new ArrayList<>(); for(MultipartFile mf : files){ if(!mf.isEmpty()) { String orgFileName = ""; try { orgFileName = StringUtils.cleanPath(Objects.requireNonNull(mf.getOriginalFilename())); - CmmFileDtlDTO fileDtlDTO = CmmFileDtlDTO.builder() + CmmFileDTO.FileDtl fileDtlDTO = CmmFileDTO.FileDtl.builder() .fileMastrId(fileMstDTO.getFileMastrId()) .fileId(CommUtils.getStringFromUUID()) .fileCours(makePath) @@ -250,7 +249,7 @@ public class CmmFileService implements ICmmFileService { } @Transactional - public void removeExistsUploadFile(final CmmFileDtlDTO dtlDto){ + public void removeExistsUploadFile(final CmmFileDTO.FileDtl dtlDto){ mapper.selectCmmFileDetail(dtlDto) .ifPresent((dto)->{ mapper.deleteCmmFileDetail(dto); diff --git a/src/main/java/kr/xit/framework/biz/cmm/service/ICmmFileService.java b/src/main/java/kr/xit/framework/biz/cmm/service/ICmmFileService.java index a4e187e4..b7daa32f 100644 --- a/src/main/java/kr/xit/framework/biz/cmm/service/ICmmFileService.java +++ b/src/main/java/kr/xit/framework/biz/cmm/service/ICmmFileService.java @@ -4,8 +4,7 @@ import java.util.List; import org.springframework.web.multipart.MultipartFile; -import kr.xit.framework.biz.cmm.model.CmmFileDtlDTO; -import kr.xit.framework.biz.cmm.model.CmmFileMstDTO; +import kr.xit.framework.biz.cmm.model.CmmFileDTO; import kr.xit.framework.core.utils.XitCmmnUtil; /** @@ -13,13 +12,13 @@ import kr.xit.framework.core.utils.XitCmmnUtil; * @since 2021-07-16 */ public interface ICmmFileService { - CmmFileMstDTO findFiles(final String fileMstId); + CmmFileDTO.FileMst findFiles(final String fileMstId); @SuppressWarnings("UnusedReturnValue") - CmmFileMstDTO saveFiles(final CmmFileMstDTO fileMstDTO, final List files); + CmmFileDTO.FileMst saveFiles(final CmmFileDTO.FileMst fileMstDTO, final List files); @SuppressWarnings("UnusedReturnValue") - CmmFileMstDTO saveCtznSttemntFiles(final CmmFileMstDTO fileMstDTO, final List files, final CmmFileDtlDTO pngFileDtlDto); + CmmFileDTO.FileMst saveCtznSttemntFiles(final CmmFileDTO.FileMst fileMstDTO, final List files, final CmmFileDTO.FileDtl pngFileDtlDto); default String getUserUniqId(){ diff --git a/src/main/java/kr/xit/framework/biz/cmm/web/CmmFileMgtController.java b/src/main/java/kr/xit/framework/biz/cmm/web/CmmFileMgtController.java index 32a42f1f..20ebec8c 100644 --- a/src/main/java/kr/xit/framework/biz/cmm/web/CmmFileMgtController.java +++ b/src/main/java/kr/xit/framework/biz/cmm/web/CmmFileMgtController.java @@ -1,7 +1,20 @@ package kr.xit.framework.biz.cmm.web; +import java.io.File; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.Arrays; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.io.FileUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpHeaders; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -12,11 +25,12 @@ import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; import kr.xit.framework.biz.cmm.model.CmmFileDTO; -import kr.xit.framework.biz.cmm.model.CmmFileMstDTO; import kr.xit.framework.biz.cmm.service.ICmmFileService; +import kr.xit.framework.core.constants.ErrorCode; import kr.xit.framework.core.constants.FrameworkConstants; import kr.xit.framework.core.model.ResultResponse; import kr.xit.framework.support.exception.BizRuntimeException; +import kr.xit.framework.support.exception.CustomBaseException; import kr.xit.framework.support.util.AjaxMessageMapRenderer; import kr.xit.framework.support.util.Checks; import kr.xit.framework.support.util.constants.MessageKey; @@ -26,6 +40,8 @@ import lombok.RequiredArgsConstructor; @RequiredArgsConstructor @RequestMapping("/framework/biz/cmm/file") public class CmmFileMgtController { + @Value("#{prop['file.upload.root']}") + private String uploadRoot; private final ICmmFileService cmmFileService; @GetMapping("/{fileMstId}") @@ -35,13 +51,13 @@ public class CmmFileMgtController { } @PostMapping(value = "/upload", consumes = "multipart/form-data") - public ModelAndView saveFiles(final CmmFileDTO cmmFileDto) { + public ModelAndView saveFiles(final CmmFileDTO.Request cmmFileDto) { if(Checks.isEmpty(cmmFileDto)) throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, "파일 정보가 존재하지 않습니다."); if(Checks.isEmpty(cmmFileDto.getJobSeCode())) throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, "파일 구분 코드[fileCtgCd] 정보가 존재하지 않습니다."); if(Checks.isEmpty(cmmFileDto.getFileJobId())) throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, "파일 업무 ID[fileBizId] 정보가 존재하지 않습니다."); ModelAndView mav = new ModelAndView(FrameworkConstants.JSON_VIEW); - CmmFileMstDTO cmmFileMst = CmmFileMstDTO.builder() + CmmFileDTO.FileMst cmmFileMst = CmmFileDTO.FileMst.builder() .fileMastrId(cmmFileDto.getFileMastrId()) .jobSeCode(cmmFileDto.getJobSeCode()) .fileJobId(cmmFileDto.getFileJobId()) @@ -52,7 +68,7 @@ public class CmmFileMgtController { } @PostMapping(value = "/upload2", consumes = "multipart/form-data") - public ModelAndView saveFiles2(final CmmFileMstDTO cmmFileMst, @RequestParam("files") final MultipartFile[] files) { + public ModelAndView saveFiles2(final CmmFileDTO.FileMst cmmFileMst, @RequestParam("files") final MultipartFile[] files) { if(Checks.isEmpty(cmmFileMst)) throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, "파일 정보가 존재하지 않습니다."); if(Checks.isEmpty(cmmFileMst.getJobSeCode())) throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, "파일 구분 코드[fileCtgCd] 정보가 존재하지 않습니다."); if(Checks.isEmpty(cmmFileMst.getFileJobId())) throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, "파일 업무 ID[fileBizId] 정보가 존재하지 않습니다."); @@ -63,4 +79,70 @@ public class CmmFileMgtController { AjaxMessageMapRenderer.success(mav, MessageKey.CMM_INSERT_SUCCESS); return mav; } + + + @GetMapping("/download/{inCode}") + public void download(@PathVariable Long inCode, HttpServletResponse response) { + + + String absFile = ""; + + + download(absFile, "", response); + } + + @GetMapping("/download") + public void download(final String scDatagb, final Long scCode, String methodName, HttpServletResponse response) { + + + + String absFile = ""; + + + + download(absFile, "", response); + } + + private void download(String absFile, String fileName, HttpServletResponse response) { + + Path path = Paths.get(absFile); + String contentType = null; + long fileSize = 0L; + try { + contentType = Files.probeContentType(path); + fileSize = Files.size(path); + } catch (IOException e) { + //throw new CustomBaseException(ErrorCode.FILE_NOT_FOUND); + contentType = "application/octet-stream"; + //fileName = "FileNotFound"; + } + + File file = new File(absFile); + byte[] fileByte = new byte[0]; + try { + fileByte = FileUtils.readFileToByteArray(file); + } catch (IOException e) { + fileByte = new byte[0]; + //throw new CustomBaseException(ErrorCode.FILE_NOT_FOUND); + } + + response.setContentType(contentType); + response.setHeader(HttpHeaders.CONTENT_TYPE, contentType); + response.setHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS, "true"); + try { + response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + URLEncoder.encode(fileName, + String.valueOf(StandardCharsets.UTF_8)) + "\";"); + } catch (UnsupportedEncodingException e) { + throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, e.getMessage()); + } + //response.setHeader(HttpHeaders.CONTENT_ENCODING, "binary"); + response.setHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(fileSize)); + try { + response.getOutputStream().write(fileByte); + response.getOutputStream().flush(); + response.getOutputStream().close(); + } catch (IOException e) { + throw new CustomBaseException(ErrorCode.FILE_NOT_FOUND); + } + } } diff --git a/src/main/resources/sqlmapper/framework/cmm/cmm-file-mysql-mapper.xml b/src/main/resources/sqlmapper/framework/cmm/cmm-file-mysql-mapper.xml index a3c987ba..ca6dda49 100644 --- a/src/main/resources/sqlmapper/framework/cmm/cmm-file-mysql-mapper.xml +++ b/src/main/resources/sqlmapper/framework/cmm/cmm-file-mysql-mapper.xml @@ -6,7 +6,7 @@ - /* cmm-file-mysql-mapper|insertCmmFileMastr- 파일 마스터 정보 등록|julim */ SELECT file_mastr_id , job_se_code @@ -62,14 +62,14 @@ FROM tb_cmm_file_detail cfd - /* cmm-file-mysql-mapper|selectCmmFileDetails- 파일 상세 목록 조회|julim */ WHERE cfd.file_mastr_id = #{fileMastrId} - /* cmm-file-mysql-mapper|selectFilesByJobSeCodeAndJobId- 파일 상세 목록 조회:업무코드 and 업무아이디로|julim */ WHERE EXISTS ( @@ -82,7 +82,7 @@ - /* cmm-file-mysql-mapper|selectCmmFileDetail- 파일 상세 조회|julim */ WHERE cfd.file_mastr_id = #{fileMastrId}