Index: pom.xml =================================================================== diff -u -r87c53bcbb66be4a7a54b0df81410f2e7404e42f8 -r8b191f4ce87e9bde997c6caf2232d468eb1061d3 --- pom.xml (.../pom.xml) (revision 87c53bcbb66be4a7a54b0df81410f2e7404e42f8) +++ pom.xml (.../pom.xml) (revision 8b191f4ce87e9bde997c6caf2232d468eb1061d3) @@ -10,7 +10,7 @@ 4.0.0 313devgrp java-service-tree-framework-backend-server - 22.11.21 + 22.11.22 pom java-service-tree-framework Index: web-module/pom.xml =================================================================== diff -u -r87c53bcbb66be4a7a54b0df81410f2e7404e42f8 -r8b191f4ce87e9bde997c6caf2232d468eb1061d3 --- web-module/pom.xml (.../pom.xml) (revision 87c53bcbb66be4a7a54b0df81410f2e7404e42f8) +++ web-module/pom.xml (.../pom.xml) (revision 8b191f4ce87e9bde997c6caf2232d468eb1061d3) @@ -7,7 +7,7 @@ 313devgrp java-service-tree-framework-backend-server - 22.11.21 + 22.11.22 ../pom.xml @@ -17,7 +17,7 @@ Web Project by 313 DEV GRP - 22.12.18 + 23.01.03 Index: web-module/src/main/java/egovframework/api/arms/module_filerepository/service/FileRepository.java =================================================================== diff -u -rf41ba65b84ac704a0b3c88ac2094e32539165890 -r8b191f4ce87e9bde997c6caf2232d468eb1061d3 --- web-module/src/main/java/egovframework/api/arms/module_filerepository/service/FileRepository.java (.../FileRepository.java) (revision f41ba65b84ac704a0b3c88ac2094e32539165890) +++ web-module/src/main/java/egovframework/api/arms/module_filerepository/service/FileRepository.java (.../FileRepository.java) (revision 8b191f4ce87e9bde997c6caf2232d468eb1061d3) @@ -12,9 +12,9 @@ package egovframework.api.arms.module_filerepository.service; import egovframework.com.ext.jstree.springHibernate.core.service.JsTreeHibernateService; +import egovframework.com.ext.jstree.springHibernate.core.vo.JsTreeHibernateSearchDTO; public interface FileRepository extends JsTreeHibernateService { - - + public T addNodeWithRef(T jsTreeHibernateDTO) throws Exception; } \ No newline at end of file Index: web-module/src/main/java/egovframework/api/arms/module_filerepository/service/FileRepositoryImpl.java =================================================================== diff -u -rf41ba65b84ac704a0b3c88ac2094e32539165890 -r8b191f4ce87e9bde997c6caf2232d468eb1061d3 --- web-module/src/main/java/egovframework/api/arms/module_filerepository/service/FileRepositoryImpl.java (.../FileRepositoryImpl.java) (revision f41ba65b84ac704a0b3c88ac2094e32539165890) +++ web-module/src/main/java/egovframework/api/arms/module_filerepository/service/FileRepositoryImpl.java (.../FileRepositoryImpl.java) (revision 8b191f4ce87e9bde997c6caf2232d468eb1061d3) @@ -11,12 +11,72 @@ */ package egovframework.api.arms.module_filerepository.service; +import egovframework.com.ext.jstree.springHibernate.core.dao.JsTreeHibernateDao; import egovframework.com.ext.jstree.springHibernate.core.service.JsTreeHibernateServiceImpl; +import egovframework.com.ext.jstree.springHibernate.core.vo.JsTreeHibernateSearchDTO; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Isolation; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; + @Service("fileRepository") public class FileRepositoryImpl extends JsTreeHibernateServiceImpl implements FileRepository{ + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + @SuppressWarnings("rawtypes") + @Resource(name = "jsTreeHibernateDao") + private JsTreeHibernateDao jsTreeHibernateDao; + @SuppressWarnings("unchecked") + @Override + @Transactional(rollbackFor = { Exception.class }, isolation = Isolation.SERIALIZABLE) + public T addNodeWithRef(T jsTreeHibernateDTO) throws Exception { + + jsTreeHibernateDao.setClazz(jsTreeHibernateDTO.getClass()); + if (jsTreeHibernateDTO.getRef() < 0) { + throw new RuntimeException("ref is minus"); + } else { + T nodeByRef = (T) jsTreeHibernateDao.getUnique(jsTreeHibernateDTO.getRef()); + + if ("default".equals(nodeByRef.getC_type())) { + throw new RuntimeException("nodeByRef is default Type"); + } + + nodeByRef.setWhere("c_parentid", nodeByRef.getC_id()); + final long lastPosiotionOfNodeByRef = jsTreeHibernateDao.getCount(nodeByRef); + + jsTreeHibernateDTO.setC_position(lastPosiotionOfNodeByRef); + + long rightPointFromNodeByRef = nodeByRef.getC_right(); + rightPointFromNodeByRef = Math.max(rightPointFromNodeByRef, 1); + + long spaceOfTargetNode = 2; + + this.stretchLeftRightForMyselfFromJstree(spaceOfTargetNode, rightPointFromNodeByRef, + jsTreeHibernateDTO.getCopy(), null, jsTreeHibernateDTO); + + long targetNodeLevel = jsTreeHibernateDTO.getRef() == 0 ? 0 : nodeByRef.getC_level() + 1; + + jsTreeHibernateDTO.setC_parentid(jsTreeHibernateDTO.getRef()); + jsTreeHibernateDTO.setC_left(rightPointFromNodeByRef); + jsTreeHibernateDTO.setC_right(rightPointFromNodeByRef + 1); + jsTreeHibernateDTO.setC_level(targetNodeLevel); + + long insertSeqResult = (long) jsTreeHibernateDao.insert(jsTreeHibernateDTO); + if (insertSeqResult > 0) { + final long SUCCESS = 1; + jsTreeHibernateDTO.setStatus(SUCCESS); + jsTreeHibernateDTO.setId(insertSeqResult); + } else { + throw new RuntimeException("심각한 오류 발생 - 삽입 노드"); + } + } + return jsTreeHibernateDTO; + } + } \ No newline at end of file Index: web-module/src/main/java/egovframework/api/arms/module_pdservice/controller/UserPdServiceController.java =================================================================== diff -u -rb739d89bcd3300b6a61d1d7d3acffbc057caa1e2 -r8b191f4ce87e9bde997c6caf2232d468eb1061d3 --- web-module/src/main/java/egovframework/api/arms/module_pdservice/controller/UserPdServiceController.java (.../UserPdServiceController.java) (revision b739d89bcd3300b6a61d1d7d3acffbc057caa1e2) +++ web-module/src/main/java/egovframework/api/arms/module_pdservice/controller/UserPdServiceController.java (.../UserPdServiceController.java) (revision 8b191f4ce87e9bde997c6caf2232d468eb1061d3) @@ -44,10 +44,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.sql.DataSource; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.NoSuchElementException; +import java.util.*; @Slf4j @Controller @@ -175,41 +172,46 @@ long maxFileSize = new Long(313); List list = EgovFileUploadUtil.uploadFiles(multiRequest, uploadDir, maxFileSize); - for ( EgovFormBasedFileVo egovFormBasedFileVo : list) { - FileRepositoryDTO fileRepositoryDTO = new FileRepositoryDTO(); - fileRepositoryDTO.setFileName(egovFormBasedFileVo.getFileName()); - fileRepositoryDTO.setContentType(egovFormBasedFileVo.getContentType()); - fileRepositoryDTO.setServerSubPath(egovFormBasedFileVo.getServerSubPath()); - fileRepositoryDTO.setPhysicalName(egovFormBasedFileVo.getPhysicalName()); - fileRepositoryDTO.setSize(egovFormBasedFileVo.getSize()); - fileRepositoryDTO.setName(egovFormBasedFileVo.getName()); + EgovFormBasedFileVo egovFormBasedFileVo = list.get(0); - fileRepositoryDTO.setUrl(egovFormBasedFileVo.getUrl()); - //TODO: 썸네일 개발 필요 - fileRepositoryDTO.setThumbnailUrl(egovFormBasedFileVo.getThumbnailUrl()); + FileRepositoryDTO fileRepositoryDTO = new FileRepositoryDTO(); - fileRepositoryDTO.setDelete_url(egovFormBasedFileVo.getDelete_url()); - fileRepositoryDTO.setDelete_type(egovFormBasedFileVo.getDelete_type()); - fileRepositoryDTO.setFileIdLink(fileIdLink); + fileRepositoryDTO.setFileName(egovFormBasedFileVo.getFileName()); + fileRepositoryDTO.setContentType(egovFormBasedFileVo.getContentType()); + fileRepositoryDTO.setServerSubPath(egovFormBasedFileVo.getServerSubPath()); + fileRepositoryDTO.setPhysicalName(egovFormBasedFileVo.getPhysicalName()); + fileRepositoryDTO.setSize(egovFormBasedFileVo.getSize()); + fileRepositoryDTO.setName(egovFormBasedFileVo.getName()); - fileRepositoryDTO.setRef(new Long(2)); - fileRepositoryDTO.setC_title("pdService"); - fileRepositoryDTO.setC_type("default"); + fileRepositoryDTO.setUrl(egovFormBasedFileVo.getUrl()); + //TODO: 썸네일 개발 필요 + fileRepositoryDTO.setThumbnailUrl(egovFormBasedFileVo.getThumbnailUrl()); - FileRepositoryDTO returnFileRepositoryDTO = fileRepository.addNode(fileRepositoryDTO); - //delete 파라미터인 id 값을 업데이트 치기 위해서. - fileRepositoryDTO.setUrl("/auth-user/api/arms/fileRepository" + "/downloadFileByNode/" + returnFileRepositoryDTO.getId()); - fileRepositoryDTO.setThumbnailUrl("/auth-user/api/arms/fileRepository" + "/thumbnailUrlFileToNode/" + returnFileRepositoryDTO.getId()); - fileRepositoryDTO.setDelete_url("/auth-user/api/arms/fileRepository" + "/deleteFileByNode/" + returnFileRepositoryDTO.getId()); + fileRepositoryDTO.setDelete_url(egovFormBasedFileVo.getDelete_url()); + fileRepositoryDTO.setDelete_type(egovFormBasedFileVo.getDelete_type()); + fileRepositoryDTO.setFileIdLink(fileIdLink); - fileRepository.updateNode(fileRepositoryDTO); + fileRepositoryDTO.setRef(new Long(2)); + fileRepositoryDTO.setC_title("pdService"); + fileRepositoryDTO.setC_type("default"); - egovFormBasedFileVo.setUrl("/auth-user/api/arms/fileRepository" + "/downloadFileByNode/" + returnFileRepositoryDTO.getId()); - egovFormBasedFileVo.setThumbnailUrl("/auth-user/api/arms/fileRepository" + "/thumbnailUrlFileToNode/" + returnFileRepositoryDTO.getId()); - egovFormBasedFileVo.setDelete_url("/auth-user/api/arms/fileRepository" + "/deleteFileByNode/" + returnFileRepositoryDTO.getId()); - + FileRepositoryDTO returnFileRepositoryDTO = fileRepository.addNodeWithRef(fileRepositoryDTO); + if(returnFileRepositoryDTO.getStatus() == 1L){ + logger.info("returnFileRepositoryDTO => " + returnFileRepositoryDTO.getC_id()); } + logger.info("fileRepository.getNode(returnFileRepositoryDTO).getC_id() ==> " + fileRepository.getNode(returnFileRepositoryDTO).getC_id()); + //delete 파라미터인 id 값을 업데이트 치기 위해서. + fileRepositoryDTO.setUrl("/auth-user/api/arms/fileRepository" + "/downloadFileByNode/" + returnFileRepositoryDTO.getId()); + fileRepositoryDTO.setThumbnailUrl("/auth-user/api/arms/fileRepository" + "/thumbnailUrlFileToNode/" + returnFileRepositoryDTO.getId()); + fileRepositoryDTO.setDelete_url("/auth-user/api/arms/fileRepository" + "/deleteFileByNode/" + returnFileRepositoryDTO.getId()); + + fileRepository.updateNode(fileRepositoryDTO); + + egovFormBasedFileVo.setUrl("/auth-user/api/arms/fileRepository" + "/downloadFileByNode/" + returnFileRepositoryDTO.getId()); + egovFormBasedFileVo.setThumbnailUrl("/auth-user/api/arms/fileRepository" + "/thumbnailUrlFileToNode/" + returnFileRepositoryDTO.getId()); + egovFormBasedFileVo.setDelete_url("/auth-user/api/arms/fileRepository" + "/deleteFileByNode/" + returnFileRepositoryDTO.getId()); + HashMap> map = new HashMap(); map.put("files", list); ModelAndView modelAndView = new ModelAndView("jsonView");