diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/controller/ExtRepoDataController.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/controller/ExtRepoDataController.java index c459fcc97..0fec9671c 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/controller/ExtRepoDataController.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/controller/ExtRepoDataController.java @@ -11,7 +11,6 @@ import com.jero.common.system.vo.LoginUser; import com.jero.common.util.oss.CosBootUtil; import com.jero.modules.extRepo.entity.ExtRepoData; import com.jero.modules.extRepo.entity.ExtRepoDataPage; -import com.jero.modules.extRepo.entity.ExtRepoFolder; import com.jero.modules.extRepo.service.IExtRepoDataService; import com.jero.modules.extRepo.service.IExtRepoFolderService; import io.swagger.annotations.Api; @@ -185,29 +184,20 @@ public class ExtRepoDataController extends JeroController result = new Result(); ExtRepoData erd = extRepoDataService.queryById(id); if (null != erd) { - int count = getRootFolderCount(); - if (erd.getSupFolder().equals("root") && count <= 1) { + LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + if (extRepoFolderService.isManager() || sysUser.getUsername().equals(erd.getCreateBy())) { + extRepoDataService.deleteById(id); + CosBootUtil.delete(erd.getFileKey()); if (CutEnum.CN.getValue().equals(cut)) { - result.error500("此文件夹不可删除!"); + result.success("删除成功!"); } else { - result.error500("This folder cannot be deleted!"); + result.success("Data deletion successfully!"); } } else { - LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - if (sysUser.getUsername().equals(erd.getCreateBy())) { - extRepoDataService.deleteById(id); - CosBootUtil.delete(erd.getFileKey()); - if (CutEnum.CN.getValue().equals(cut)) { - result.success("删除成功!"); - } else { - result.success("Data deletion successfully!"); - } + if (CutEnum.CN.getValue().equals(cut)) { + result.error500("没有权限!"); } else { - if (CutEnum.CN.getValue().equals(cut)) { - result.error500("没有权限!"); - } else { - result.error500("You do not have permission!"); - } + result.error500("You do not have permission!"); } } } else { @@ -220,11 +210,6 @@ public class ExtRepoDataController extends JeroController queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(ExtRepoFolder::getSupFolder, "root"); - return extRepoFolderService.count(queryWrapper); - } /** * 批量删除 diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/controller/ExtRepoFolderController.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/controller/ExtRepoFolderController.java index 37be9b9e1..a77ed3230 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/controller/ExtRepoFolderController.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/controller/ExtRepoFolderController.java @@ -1,5 +1,6 @@ package com.jero.modules.extRepo.controller; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.jero.common.api.vo.Result; import com.jero.common.aspect.annotation.AutoLog; import com.jero.common.constant.enums.CutEnum; @@ -63,6 +64,11 @@ public class ExtRepoFolderController extends JeroController add(@Validated @RequestBody ExtRepoFolder extRepoFolder) { Result result = new Result(); if (extRepoFolderService.haveManageAuth(extRepoFolder.getSupFolder())) { + if (!extRepoFolder.isAddSub()) { + //增加同级文件夹 + ExtRepoFolder folder = extRepoFolderService.queryById(extRepoFolder.getSupFolder()); + extRepoFolder.setSupFolder(folder.getSupFolder()); + } extRepoFolderService.add(extRepoFolder); if (CutEnum.CN.getValue().equals(extRepoFolder.getCut())) { result.success("添加成功!"); @@ -122,15 +128,25 @@ public class ExtRepoFolderController extends JeroController resList = extRepoFolderService.getListBySupFolder(id); if (resList.isEmpty()) { - List erdList = extRepoDataService.queryByFolder(id); - for (ExtRepoData erd : erdList) { - extRepoDataService.deleteById(erd.getId()); - } - extRepoFolderService.deleteById(id); - if (CutEnum.CN.getValue().equals(cut)) { - result.success("删除成功!"); + ExtRepoFolder erf = extRepoFolderService.queryById(id); + int count = getRootFolderCount(); + if (erf.getSupFolder().equals("root") && count <= 1) { + if (CutEnum.CN.getValue().equals(cut)) { + result.error500("此文件夹不可删除!"); + } else { + result.error500("This folder cannot be deleted!"); + } } else { - result.success("Data deletion successfully!"); + List erdList = extRepoDataService.queryByFolder(id); + for (ExtRepoData erd : erdList) { + extRepoDataService.deleteById(erd.getId()); + } + extRepoFolderService.deleteById(id); + if (CutEnum.CN.getValue().equals(cut)) { + result.success("删除成功!"); + } else { + result.success("Data deletion successfully!"); + } } } else { if (CutEnum.CN.getValue().equals(cut)) { @@ -149,6 +165,13 @@ public class ExtRepoFolderController extends JeroController queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(ExtRepoFolder::getSupFolder, "root"); + return extRepoFolderService.count(queryWrapper); + } + /** * 通过id查询 * diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/entity/ExtRepoFolder.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/entity/ExtRepoFolder.java index c34293c87..a99d600d7 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/entity/ExtRepoFolder.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/entity/ExtRepoFolder.java @@ -96,4 +96,7 @@ public class ExtRepoFolder implements Serializable { @TableField(exist = false) private String cut; + + @TableField(exist = false) + private boolean addSub; }