From e5a6df0110bc1b73ad68c58e433a52cd0d26685e Mon Sep 17 00:00:00 2001 From: CD <1103614279@qq.com> Date: Tue, 27 Sep 2022 17:34:12 +0800 Subject: [PATCH] bug59974 --- .../controller/ExtRepoFolderController.java | 22 ++++++--- .../service/IExtRepoFolderService.java | 10 ++++ .../impl/ExtRepoFolderServiceImpl.java | 46 ++++++++++++++++++- 3 files changed, 70 insertions(+), 8 deletions(-) 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 a77ed3230..4c6662775 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 @@ -13,10 +13,12 @@ import com.jero.modules.extRepo.service.IExtRepoFolderService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpSession; import java.util.List; @@ -47,7 +49,7 @@ public class ExtRepoFolderController extends JeroController queryList() { ERFTreeDataVO dataVO = new ERFTreeDataVO(); - dataVO.setManager(extRepoFolderService.isManager()); + dataVO.setManager(true); dataVO.setList(extRepoFolderService.queryTreeList()); return Result.OK(dataVO); } @@ -61,9 +63,11 @@ public class ExtRepoFolderController extends JeroController add(@Validated @RequestBody ExtRepoFolder extRepoFolder) { + public Result add(@Validated @RequestBody ExtRepoFolder extRepoFolder, HttpSession session) { Result result = new Result(); - if (extRepoFolderService.haveManageAuth(extRepoFolder.getSupFolder())) { + session.setAttribute("haveSuperiorManageAuth", false); + extRepoFolderService.haveSuperiorManageAuth(extRepoFolder.getSupFolder(),session); + if (ObjectUtils.isNotEmpty(session.getAttribute("haveSuperiorManageAuth"))&&(Boolean) session.getAttribute("haveSuperiorManageAuth")) { if (!extRepoFolder.isAddSub()) { //增加同级文件夹 ExtRepoFolder folder = extRepoFolderService.queryById(extRepoFolder.getSupFolder()); @@ -94,9 +98,11 @@ public class ExtRepoFolderController extends JeroController edit(@Validated @RequestBody ExtRepoFolder extRepoFolder) { + public Result edit(@Validated @RequestBody ExtRepoFolder extRepoFolder, HttpSession session) { Result result = new Result(); - if (extRepoFolderService.haveManageAuth(extRepoFolder.getId())) { + session.setAttribute("haveSuperiorManageAuth", false); + extRepoFolderService.haveSuperiorManageAuth(extRepoFolder.getSupFolder(),session); + if (ObjectUtils.isNotEmpty(session.getAttribute("haveSuperiorManageAuth"))&&(Boolean) session.getAttribute("haveSuperiorManageAuth")) { extRepoFolderService.editById(extRepoFolder); if (CutEnum.CN.getValue().equals(extRepoFolder.getCut())) { result.success("编辑成功!"); @@ -123,9 +129,11 @@ public class ExtRepoFolderController extends JeroController delete(@RequestParam(name = "id", required = true) String id, - @RequestParam(name = "cut", defaultValue = "cn") String cut) { + @RequestParam(name = "cut", defaultValue = "cn") String cut, HttpSession session) { Result result = new Result(); - if (extRepoFolderService.haveManageAuth(id)) { + session.setAttribute("haveSuperiorManageAuth", false); + extRepoFolderService.haveSuperiorManageAuth(id,session); + if (ObjectUtils.isNotEmpty(session.getAttribute("haveSuperiorManageAuth"))&&(Boolean) session.getAttribute("haveSuperiorManageAuth")) { List resList = extRepoFolderService.getListBySupFolder(id); if (resList.isEmpty()) { ExtRepoFolder erf = extRepoFolderService.queryById(id); diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/IExtRepoFolderService.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/IExtRepoFolderService.java index de4d4da8f..4a52b0959 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/IExtRepoFolderService.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/IExtRepoFolderService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.jero.modules.extRepo.entity.ERFTreeData; import com.jero.modules.extRepo.entity.ExtRepoFolder; +import javax.servlet.http.HttpSession; import java.util.List; /** @@ -91,4 +92,13 @@ public interface IExtRepoFolderService extends IService { * @return */ List getListBySupFolder(String supFolder); + + /** + * 判断上级是否有权限 + * @param supFolder + * @param session + * @return + */ + void haveSuperiorManageAuth(String supFolder, HttpSession session); + } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/impl/ExtRepoFolderServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/impl/ExtRepoFolderServiceImpl.java index 30df6c310..f9ad6ac17 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/impl/ExtRepoFolderServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/impl/ExtRepoFolderServiceImpl.java @@ -14,10 +14,12 @@ import com.jero.modules.extRepo.service.IExtRepoFolderService; import com.jero.modules.system.entity.SysUserRole; import com.jero.modules.system.service.ISysUserRoleService; import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.ObjectUtils; import org.apache.shiro.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.servlet.http.HttpSession; import java.util.*; import java.util.stream.Collectors; @@ -246,7 +248,7 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl(),childLevel)); date.sortChildren(); resList.add(date); } else { @@ -257,6 +259,28 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl subFolderTree(String folder,List childTree,int level) { + int childLevel = level + 1; + List listBySupFolder = getListBySupFolder(folder); + for (ExtRepoFolder extRepoFolder : listBySupFolder) { + ERFTreeData date = new ERFTreeData(extRepoFolder.getFolderName(), extRepoFolder.getId(), childLevel, extRepoFolder.getOrderId()); + date.setAuthManageIdsName(extRepoFolder.getAuthManageIdsName()); + date.setAuthManageIds(extRepoFolder.getAuthManageIds()); + date.setAuthViewIdsName(extRepoFolder.getAuthViewIdsName()); + date.setAuthViewIds(extRepoFolder.getAuthViewIds()); + date.setChildren(subFolderTree(extRepoFolder.getId(), new ArrayList(),childLevel)); + date.sortChildren(); + childTree.add(date); + } + return childTree; + } + private List getStringList(String listStr) { List res = new ArrayList<>(); if (null != listStr) { @@ -324,4 +348,24 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl