diff --git a/bonus-business/src/main/java/com/bonus/business/controller/DocumentScreenController.java b/bonus-business/src/main/java/com/bonus/business/controller/DocumentScreenController.java index 890b1df..02940d9 100644 --- a/bonus-business/src/main/java/com/bonus/business/controller/DocumentScreenController.java +++ b/bonus-business/src/main/java/com/bonus/business/controller/DocumentScreenController.java @@ -91,6 +91,12 @@ public class DocumentScreenController extends BaseController { return service.addDocument(vo); } + @PostMapping("/addLookNum") + public AjaxResult addLookNum(@RequestBody TbFolderFileVo vo) { + return service.addLookNum(vo); + } + + /** * 新增文档 * @param vo diff --git a/bonus-business/src/main/java/com/bonus/business/mapper/DocumentScreenMapper.java b/bonus-business/src/main/java/com/bonus/business/mapper/DocumentScreenMapper.java index 6dcc16b..b8edaf7 100644 --- a/bonus-business/src/main/java/com/bonus/business/mapper/DocumentScreenMapper.java +++ b/bonus-business/src/main/java/com/bonus/business/mapper/DocumentScreenMapper.java @@ -190,4 +190,11 @@ public interface DocumentScreenMapper { * @return */ int cancelShare(TbFolderFileVo vo); + + /** + * 查询是否是上级节点 + * @param vo + * @return + */ + Integer getPublicFolderNum(TbFolderFileVo vo); } diff --git a/bonus-business/src/main/java/com/bonus/business/service/DocumentScreenService.java b/bonus-business/src/main/java/com/bonus/business/service/DocumentScreenService.java index 79e6cc3..787e5c4 100644 --- a/bonus-business/src/main/java/com/bonus/business/service/DocumentScreenService.java +++ b/bonus-business/src/main/java/com/bonus/business/service/DocumentScreenService.java @@ -91,4 +91,11 @@ public interface DocumentScreenService { * @return */ AjaxResult cancelShare(TbFolderFileVo vo); + + /** + * 增加文件查看次数 + * @param vo + * @return + */ + AjaxResult addLookNum(TbFolderFileVo vo); } diff --git a/bonus-business/src/main/java/com/bonus/business/service/impl/DocumentScreenImpl.java b/bonus-business/src/main/java/com/bonus/business/service/impl/DocumentScreenImpl.java index 39a6b7a..817105b 100644 --- a/bonus-business/src/main/java/com/bonus/business/service/impl/DocumentScreenImpl.java +++ b/bonus-business/src/main/java/com/bonus/business/service/impl/DocumentScreenImpl.java @@ -40,6 +40,10 @@ public class DocumentScreenImpl implements DocumentScreenService { private MinioUtil minioUtil; + @Autowired + public FileServiceUtils fileServiceUtils; + + protected String dataIds=",companyDocument,myShare,otherShare,share,"; protected String day= DateUtils.getCurrentDay(); @@ -126,6 +130,8 @@ public class DocumentScreenImpl implements DocumentScreenService { return AjaxResult.error("取消失败"); } + + /** * 新建文件夹 * @param vo @@ -300,8 +306,14 @@ public class DocumentScreenImpl implements DocumentScreenService { List ids=Arrays.asList(vo.getLabelIds().split(",")); vo.setLabelIdList(ids); } - List list=mapper.getFileFolderList(vo); + for (TbFolderFileVo tbFolderFileVo : list) { + if("1".equals(tbFolderFileVo.getFileType()) && StringUtils.isNotEmpty(tbFolderFileVo.getFilePath())){ + String path = fileServiceUtils.getFileUrl(tbFolderFileVo.getFilePath(),null); + tbFolderFileVo.setFilePath(path); + } + + } //进行数据查看进行插入数据 Integer num=mapper.getLookNum(vo); if (num==null){ @@ -316,7 +328,27 @@ public class DocumentScreenImpl implements DocumentScreenService { } return Collections.emptyList(); } + @Override + public AjaxResult addLookNum(TbFolderFileVo vo) { + try{ + if(vo.getId().split("_").length==3){ + vo.setId(vo.getId().split("_")[2]); + } + vo.setParentId(vo.getId()); + vo.setType("2"); + Integer num=mapper.getLookNum(vo); + if (num==null){ + num=0; + } + num++; + vo.setReadNum(num+""); + mapper.updateLookNum(vo); + }catch (Exception e){ + log.error(e.toString(),e); + } + return AjaxResult.success(); + } /** * 移动文件/文件夹 * @param vo @@ -352,22 +384,25 @@ public class DocumentScreenImpl implements DocumentScreenService { if("companyDocument".equals(vo.getNewParentId()) || "myShare".equals(vo.getNewParentId()) || "otherShare".equals(vo.getNewParentId())){ return AjaxResult.error("目标文件夹没有权限"); } - TbFolderFileVo data=mapper.getDocumentRealData(vo); - if(data==null || !"1".equals(data.getDataType())){ - return AjaxResult.error("共享及分享的文件夹不允许移动"); - } + //验证目标文件夹名称 String name=mapper.getNowName(vo); + Integer publicFolderNum= mapper.getPublicFolderNum(vo); + if(publicFolderNum==null){ + publicFolderNum=0; + } //如果是初始化节点 if ("0".equals(vo.getParentId())) { + TbFolderFileVo data=mapper.getDocumentRealData(vo); TbDocumentFolder documentFolder = getTbDocumentFolder(vo, data); //目标不是文档中心 if("userDocument".equals(vo.getNewParentId())) { - mapper.deleteDocumentReal(data); + int num=mapper.getToName(name,vo.getPublicFolderId()); if(num>0){ return AjaxResult.error("目标文件夹名称已存在"); } + mapper.deleteDocumentReal(data); mapper.addDocumentRealUser(documentFolder); }else{ @@ -378,11 +413,12 @@ public class DocumentScreenImpl implements DocumentScreenService { if(isChiild){ return AjaxResult.error("目标文件夹不能是自己子文件夹"); } - mapper.deleteDocumentReal(data); + int num=mapper.getToName2(name,vo.getNewParentId()); if(num>0){ return AjaxResult.error("目标文件夹名称已存在"); } + mapper.deleteDocumentReal(data); if("3".equals(vo.getToType())){ vo.setToType("3"); }else{ @@ -392,15 +428,12 @@ public class DocumentScreenImpl implements DocumentScreenService { } }else{ //非初始化节点 查询全部子数据 - - - if("3".equals(vo.getToType())){ vo.setToType("3"); }else{ vo.setToType(null); } - if("userDocument".equals(vo.getNewParentId())) { + if("userDocument".equals(vo.getNewParentId()) || publicFolderNum>0) { TbDocumentFolder documentFolder =new TbDocumentFolder(); documentFolder.setPublicFolderId(vo.getNewParentId()); documentFolder.setAuthType("1"); @@ -466,6 +499,9 @@ public class DocumentScreenImpl implements DocumentScreenService { public AjaxResult delete(TbFolderFileVo vo) { try{ + if(dataIds.contains(vo.getParentId())){ + return AjaxResult.error("当前文件夹不允许删除"); + } //父节点更新 String userId=SecurityUtils.getUserId().toString(); vo.setUserId(userId); @@ -484,9 +520,9 @@ public class DocumentScreenImpl implements DocumentScreenService { //如果是初始化节点 if ("0".equals(vo.getParentId())) { TbFolderFileVo data=mapper.getDocumentRealData(vo); - if(!"1".equals(data.getDataType())){ - return AjaxResult.success("共享及分享的文件夹不允许删除"); - } +// if(!"1".equals(data.getDataType())){ +// return AjaxResult.success("共享及分享的文件夹不允许删除"); +// } int num= mapper.deleteDocumentReal(data); }else{ @@ -569,6 +605,7 @@ public class DocumentScreenImpl implements DocumentScreenService { if(dataIds.contains(vo.getId())){ return AjaxResult.error("当前文件夹不允许重命名"); } + //父节点更新 String userId=SecurityUtils.getUserId().toString(); vo.setUserId(userId); @@ -661,8 +698,8 @@ public class DocumentScreenImpl implements DocumentScreenService { } //全部数据集合--treeList 需要创建文件夹及文件 long timestamp1 = System.currentTimeMillis(); - String dir="F:\\download\\"+timestamp1; - String downloadPath="F:\\downZip\\"+timestamp1+"\\"; + String dir=getDownloadPath()+timestamp1; + String downloadPath=getZipPath()+timestamp1+"\\"; boolean success =createDirectories(downloadPath); //创建文件夹 downloadFiles(treeList1,dir); @@ -682,8 +719,8 @@ public class DocumentScreenImpl implements DocumentScreenService { } //全部数据集合--treeList 需要创建文件夹及文件 long timestamp1 = System.currentTimeMillis(); - String dir="F:\\download\\"+timestamp1; - String downloadPath="F:\\downZip\\"+timestamp1+"\\"; + String dir=getDownloadPath()+timestamp1; + String downloadPath=getZipPath()+timestamp1+"\\"; boolean success =createDirectories(downloadPath); //创建文件夹 downloadFiles(treeList,dir); @@ -698,6 +735,30 @@ public class DocumentScreenImpl implements DocumentScreenService { } } +public static String getDownloadPath(){ + String osName = System.getProperty("os.name").toLowerCase(); + if (osName.contains("win")) { + return "F:\\download\\"; + } else if (osName.contains("nix") || osName.contains("nux") || osName.contains("aix")) { + return "/data/local/tmp/"; + } else { + return "/data/local/tmp/"; + } + +} +public static String getZipPath(){ + String osName = System.getProperty("os.name").toLowerCase(); + if (osName.contains("win")) { + return "F:\\downZip\\"; + } else if (osName.contains("nix") || osName.contains("nux") || osName.contains("aix")) { + return "/data/local/tmp/"; + } else { + return "/data/local/tmp/"; + } + +} + + public HttpServletResponse download(String path, HttpServletResponse response) { try { @@ -792,20 +853,8 @@ public class DocumentScreenImpl implements DocumentScreenService { } return false; } - public static void main(String[] args) { - String path = "F:\\HAHAH\\DD\\PPP"; - Path dir = Paths.get(path); - try { - boolean success = Files.createDirectories(dir).isAbsolute(); - } catch (IOException e) { - throw new RuntimeException(e); - } - String sourceDirPath = "F:\\新建文件夹"; // 指定源目录路径 - String zipFilePath = "F:\\files\\test.zip"; // 指定输出ZIP文件的路径 - zipDirectory(sourceDirPath, zipFilePath); - System.out.println("Directory zipped successfully."); - } + public static void deleteDirectoryContents(String path) { try { Path directory = Paths.get(path); @@ -1015,12 +1064,13 @@ public class DocumentScreenImpl implements DocumentScreenService { // String[] ids=files.getLabelIds().split(","); String[] name= files.getLabels().split(","); - TbUserLabel vo=new TbUserLabel(); + for (MultipartFile file: multipartFileList) { List list=new ArrayList<>(); String documentId=StringUtils.randomUUID(); documentFolder.setId(documentId); for (int i = 0; i select count(1) from tb_document_files_label - where label_id = #{id} + where lable_id = #{id} \ No newline at end of file diff --git a/bonus-business/src/main/resources/mapper/business/DocumentScreenMapper.xml b/bonus-business/src/main/resources/mapper/business/DocumentScreenMapper.xml index 06b7cf9..8f283dc 100644 --- a/bonus-business/src/main/resources/mapper/business/DocumentScreenMapper.xml +++ b/bonus-business/src/main/resources/mapper/business/DocumentScreenMapper.xml @@ -163,7 +163,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -337,6 +336,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" from tb_user_document_folder where file_type=0 + diff --git a/bonus-system/src/main/resources/mapper/system/SysDeptMapper.xml b/bonus-system/src/main/resources/mapper/system/SysDeptMapper.xml index 6be823b..b79bcb4 100644 --- a/bonus-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/bonus-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -47,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" GROUP BY d.dept_id - ${params.dataScope} + -- ${params.dataScope} order by d.parent_id, d.order_num