From ea47f926be2d9aaeea7ad4db95b05f73d8f93514 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Fri, 30 Sep 2022 18:29:33 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E8=8E=B7=E5=8F=96=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E5=88=97=E8=A1=A8=EF=BC=9B=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E6=9C=BA=E6=9E=84=E6=8E=A5=E5=8F=A3=E8=B0=83=E6=95=B4=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rtss/services/org/OrgProjectService.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/org/OrgProjectService.java b/src/main/java/club/joylink/rtss/services/org/OrgProjectService.java index b228417a1..2dc342beb 100644 --- a/src/main/java/club/joylink/rtss/services/org/OrgProjectService.java +++ b/src/main/java/club/joylink/rtss/services/org/OrgProjectService.java @@ -63,15 +63,19 @@ public class OrgProjectService implements IOrgProjectService { } // 用户关联组织ID列表 List orgIdList = orgUserList.stream().map(OrgUser::getOrgId).distinct().collect(Collectors.toList()); - // 项目关联顶级组织ID - List orgTopIdList = orgProjectList.stream().map(OrgProject::getOrgId).distinct().collect(Collectors.toList()); // 用户关联组织信息 OrgExample orgExample = new OrgExample(); - orgExample.createCriteria().andStatusEqualTo(BusinessConsts.Org.Status.VALID).andIdIn(orgIdList).andRootIdIn(orgTopIdList); - List orgList = orgDAO.selectByExample(orgExample); - // 筛选出有权限的顶级组织 - orgIdList = orgList.stream().map(Org::getRootId).distinct().collect(Collectors.toList()); orgExample.createCriteria().andStatusEqualTo(BusinessConsts.Org.Status.VALID).andIdIn(orgIdList); + List orgList = orgDAO.selectByExample(orgExample); + if (CollectionUtils.isEmpty(orgUserList)) { + return List.of(); + } + List userOrgTopIdList = orgList.stream().map(Org::getRootId).distinct().collect(Collectors.toList()); + // 有权限的组织ID + List authOrgIdList = orgProjectList.stream().filter(orgProject -> userOrgTopIdList.contains(orgProject.getOrgId())) + .map(OrgProject::getOrgId).collect(Collectors.toList()); + orgExample = new OrgExample(); + orgExample.createCriteria().andStatusEqualTo(BusinessConsts.Org.Status.VALID).andIdIn(authOrgIdList); orgList = orgDAO.selectByExample(orgExample); return orgList.stream().map(OrgProjectVO::new).collect(Collectors.toList()); } @@ -89,14 +93,14 @@ public class OrgProjectService implements IOrgProjectService { orgExample.createCriteria().andStatusEqualTo(BusinessConsts.Org.Status.VALID).andRootIdEqualTo(orgId); List orgList = orgDAO.selectByExample(orgExample); // 没有顶级项目 - Org topOrg = orgList.stream().filter(o -> o.getId() == o.getRootId()).findFirst().orElse(null); + Org topOrg = orgList.stream().filter(o -> o.getId().equals(o.getRootId())).findFirst().orElse(null); if (topOrg == null) { throw new SimulationException(SimulationExceptionType.Illegal_Argument); } List orgIdList = orgList.stream().map(Org::getId).distinct().collect(Collectors.toList()); // 检验用户是否有组织信息 OrgUserExample example = new OrgUserExample(); - example.createCriteria().andUserIdEqualTo(loginInfo.getAccountVO().getId()).andIdIn(orgIdList); + example.createCriteria().andUserIdEqualTo(loginInfo.getAccountVO().getId()).andOrgIdIn(orgIdList); List orgUserList = orgUserDAO.selectByExample(example); if (CollectionUtils.isEmpty(orgUserList)) { throw new SimulationException(SimulationExceptionType.Illegal_Argument);