diff --git a/com.actionsoft.apps.coe.pal.cooperation/lib/com.actionsoft.apps.coe.pal.cooperation.jar b/com.actionsoft.apps.coe.pal.cooperation/lib/com.actionsoft.apps.coe.pal.cooperation.jar index af4ff5f8..12a703c7 100644 Binary files a/com.actionsoft.apps.coe.pal.cooperation/lib/com.actionsoft.apps.coe.pal.cooperation.jar and b/com.actionsoft.apps.coe.pal.cooperation/lib/com.actionsoft.apps.coe.pal.cooperation.jar differ diff --git a/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/web/CooperationWeb.java b/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/web/CooperationWeb.java index 1e90c9ee..0ff09d2f 100644 --- a/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/web/CooperationWeb.java +++ b/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/web/CooperationWeb.java @@ -283,10 +283,22 @@ public class CooperationWeb extends ActionWeb { msg = "保存小组管理员信息"; if (isOk && repositoryVerIds.size() > 0) { // 创建权限信息 + Set toBeInsertPermIds = new HashSet<>(); List perms = new ArrayList<>(); for (int i = 0; i < repositoryVerIds.size(); i++) { CoeCooperationTeamPermModel perm = new CoeCooperationTeamPermModel(UUIDGener.getUUID(), teamId, repositoryVerIds.getString(i)); perms.add(perm); + + // 将当前数据的所有直接父级也加权限 + PALRepositoryModel repositoryModel = PALRepositoryCache.getCache().get(repositoryVerIds.getString(i)); + if (repositoryModel == null) continue; + String parentId = repositoryModel.getParentId(); + recursionLookUp(parentId, toBeInsertPermIds); + } + + for (String permId : toBeInsertPermIds) { + CoeCooperationTeamPermModel perm = new CoeCooperationTeamPermModel(UUIDGener.getUUID(), teamId, permId); + perms.add(perm); } isOk = api.createCooperationTeamPerms(perms); msg = "保存小组数据权限信息"; @@ -377,11 +389,24 @@ public class CooperationWeb extends ActionWeb { if (repositoryVerIds.size() > 0) { // 创建权限信息 + Set toBeInsertPermIds = new HashSet<>(); List perms = new ArrayList<>(); for (int i = 0; i < repositoryVerIds.size(); i++) { CoeCooperationTeamPermModel perm = new CoeCooperationTeamPermModel(UUIDGener.getUUID(), teamId, repositoryVerIds.getString(i)); perms.add(perm); + + // 将当前数据的所有直接父级也加权限 + PALRepositoryModel repositoryModel = PALRepositoryCache.getCache().get(repositoryVerIds.getString(i)); + if (repositoryModel == null) continue; + String parentId = repositoryModel.getParentId(); + recursionLookUp(parentId, toBeInsertPermIds); } + + for (String permId : toBeInsertPermIds) { + CoeCooperationTeamPermModel perm = new CoeCooperationTeamPermModel(UUIDGener.getUUID(), teamId, permId); + perms.add(perm); + } + isOk = api.createCooperationTeamPerms(perms); msg = "更新小组数据权限信息"; @@ -412,11 +437,22 @@ public class CooperationWeb extends ActionWeb { * @param toBeInsertPermIds */ private void recursionLookUp(String targetId, Set toBeInsertPermIds){ - if (targetId.length() < 36) return; + if (targetId == null || targetId.isEmpty()) { + return; + } toBeInsertPermIds.add(targetId); - PALRepositoryModel targetModel = PALRepositoryCache.getCache().get(targetId); - String parentId = targetModel.getParentId(); - recursionLookUp(parentId, toBeInsertPermIds); + while (targetId.length() == 36){ + PALRepositoryModel targetModel = PALRepositoryCache.getCache().get(targetId); + if (targetModel == null) { + break; + } + String parentId = targetModel.getParentId(); + if (parentId == null || parentId.isEmpty()) { + break; + } + toBeInsertPermIds.add(parentId); + targetId = parentId; + } } /** diff --git a/com.actionsoft.apps.coe.pal/lib/com.actionsoft.apps.coe.pal.jar b/com.actionsoft.apps.coe.pal/lib/com.actionsoft.apps.coe.pal.jar index 41847454..7bb2d31e 100644 Binary files a/com.actionsoft.apps.coe.pal/lib/com.actionsoft.apps.coe.pal.jar and b/com.actionsoft.apps.coe.pal/lib/com.actionsoft.apps.coe.pal.jar differ diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/CoeCooperationAPIManager.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/CoeCooperationAPIManager.java index 7e6e6680..f8a6e0ec 100644 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/CoeCooperationAPIManager.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/CoeCooperationAPIManager.java @@ -588,6 +588,39 @@ public class CoeCooperationAPIManager { return true; } + /** + * 向小组及其下的非隐藏角色的权限数据中添加数据 + * @param teamId + * @param palVersionId + */ + public void addRepositoryToTeamAndRolePerm(String teamId, String palVersionId){ + // 1、向小组权限中添加数据 + List teamPermList = queryCooperationTeamPermVerIds(teamId); + // 获取现有数据权限,判断是否已存在 + if (!teamPermList.contains(palVersionId)) { + // 添加 + CoeCooperationTeamPermModel teamPerm = new CoeCooperationTeamPermModel(UUIDGener.getUUID(), teamId, palVersionId); + new CoeCooperationTeamPermDao().insert(teamPerm); + } + + // 2、获取小组下非隐藏角色(用户权限)的角色 + List coeCooperationRoleModels = queryCooperationRoleList(teamId); + for (CoeCooperationRoleModel roleModel : coeCooperationRoleModels) { + // 判断是否设定的默认全部权限 + if (!CoeCooperationConst.PERM_ALL.equals(roleModel.getDataPerm())) { + // 获取现有角色数据权限,判断是否已存在 + List rolePermList = new CoeCooperationRolePermDao().getRolePermListByRole(teamId, roleModel.getId()); + if (!rolePermList.contains(palVersionId)){ + CoeCooperationRolePermModel rolePerm = new CoeCooperationRolePermModel(UUIDGener.getUUID(), teamId, roleModel.getId(), palVersionId); + new CoeCooperationRolePermDao().insert(rolePerm); + } + } + } + + //更新用户权限缓存 + CooperationCache.updateTeamInfo(teamId); + } + /** * 查询用户在指定小组中的角色 * @param teamId diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/web/CoeProcessLevelWeb.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/web/CoeProcessLevelWeb.java index 252db6c7..c3ffb8ce 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/web/CoeProcessLevelWeb.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/web/CoeProcessLevelWeb.java @@ -4,6 +4,7 @@ import com.actionsoft.apps.AppPlatformConfig; import com.actionsoft.apps.AppsConst; import com.actionsoft.apps.coe.pal.cooperation.CoeCooperationAPIManager; import com.actionsoft.apps.coe.pal.cooperation.cache.CooperationCache; +import com.actionsoft.apps.coe.pal.cooperation.cache.model.TeamInfo; import com.actionsoft.apps.coe.pal.cooperation.constant.CoeCooperationConst; import com.actionsoft.apps.coe.pal.cooperation.model.CoeCooperationMemberModel; import com.actionsoft.apps.coe.pal.cooperation.model.CoeCooperationTeamModel; @@ -8357,6 +8358,17 @@ public class CoeProcessLevelWeb extends ActionWeb { CoeCooperationAPIManager.getInstance().addRepositoryToTeamAndRolePerm(_uc, teamId, model.getVersionId(), true, true); } + // 新增的架构或者文件夹 自动加权 遍历所有小组 判断父级文件夹/架构是否在该小组下是否有权限 + if (UtilString.isNotEmpty(parentId) && parentId.length() == 36){ + List allTeamInfo = CoeCooperationAPIManager.getInstance().getAllTeamInfo(); + allTeamInfo.parallelStream().forEach(teamInfo -> { + boolean isPerm = teamInfo.getVersionIds().stream().anyMatch(teamPermId -> teamPermId.equals(parentId)); + if (isPerm){ + CoeCooperationAPIManager.getInstance().addRepositoryToTeamAndRolePerm(teamInfo.getTeamId(), model.getVersionId()); + } + }); + } + // 操作行为日志记录 if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { CoEOpLogAPI.auditOkOp(_uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_CREATE, CoEOpLogConst.INFO_REPOSITORY_CREATE); @@ -8454,6 +8466,17 @@ public class CoeProcessLevelWeb extends ActionWeb { CoeCooperationAPIManager.getInstance().addRepositoryToTeamAndRolePerm(_uc, teamId, model.getVersionId(), true, true); } + // 新增的架构或者文件夹 自动加权 遍历所有小组 判断父级文件夹/架构是否在该小组下是否有权限 + if (UtilString.isNotEmpty(parentId) && parentId.length() == 36){ + List allTeamInfo = CoeCooperationAPIManager.getInstance().getAllTeamInfo(); + allTeamInfo.parallelStream().forEach(teamInfo -> { + boolean isPerm = teamInfo.getVersionIds().stream().anyMatch(teamPermId -> teamPermId.equals(parentId)); + if (isPerm){ + CoeCooperationAPIManager.getInstance().addRepositoryToTeamAndRolePerm(teamInfo.getTeamId(), model.getVersionId()); + } + }); + } + ro.put("id", id); // 操作行为日志记录 if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { @@ -8600,6 +8623,17 @@ public class CoeProcessLevelWeb extends ActionWeb { CoeCooperationAPIManager.getInstance().addRepositoryToTeamAndRolePerm(_uc, teamId, model.getVersionId(), true, true); } + // 新增的架构或者文件夹 自动加权 遍历所有小组 判断父级文件夹/架构是否在该小组下是否有权限 + if (UtilString.isNotEmpty(parentId) && parentId.length() == 36){ + List allTeamInfo = CoeCooperationAPIManager.getInstance().getAllTeamInfo(); + allTeamInfo.parallelStream().forEach(teamInfo -> { + boolean isPerm = teamInfo.getVersionIds().stream().anyMatch(teamPermId -> teamPermId.equals(parentId)); + if (isPerm){ + CoeCooperationAPIManager.getInstance().addRepositoryToTeamAndRolePerm(teamInfo.getTeamId(), model.getVersionId()); + } + }); + } + ro.put("id", id); // 操作行为日志记录 if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { @@ -11001,6 +11035,17 @@ public String deleteReply(String replyid, String messageid) { CoEOpLogAPI.auditOkOp(_uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_UPDATE, CoEOpLogConst.INFO_REPOSITORY_MOVE_UPDATE); } + // 移动的文件/文件夹/架构 只要有一个在当前小组数据权限中 则 目标文件/文件夹/架构及所有直接父级都放入小组权限中 + List allTeamInfo = CoeCooperationAPIManager.getInstance().getAllTeamInfo(); + allTeamInfo.parallelStream().forEach(teamInfo -> { + boolean isPerm = teamInfo.getVersionIds().stream().anyMatch(verId -> sourceList.stream().anyMatch(palRepositoryModel -> palRepositoryModel.getVersionId().equals(verId))); + if (isPerm){ + Set toBeInsertPermIds = new HashSet<>(); + recursionLookUp(targetId, toBeInsertPermIds); + toBeInsertPermIds.forEach(permId -> CoeCooperationAPIManager.getInstance().addRepositoryToTeamAndRolePerm(teamInfo.getTeamId(), permId)); + } + }); + /** * by bzp */ @@ -11015,11 +11060,22 @@ public String deleteReply(String replyid, String messageid) { * @param toBeInsertPermIds */ private void recursionLookUp(String targetId, Set toBeInsertPermIds){ - if (targetId.length() < 36) return; + if (targetId == null || targetId.isEmpty()) { + return; + } toBeInsertPermIds.add(targetId); - PALRepositoryModel targetModel = PALRepositoryCache.getCache().get(targetId); - String parentId = targetModel.getParentId(); - recursionLookUp(parentId, toBeInsertPermIds); + while (targetId.length() == 36){ + PALRepositoryModel targetModel = PALRepositoryCache.getCache().get(targetId); + if (targetModel == null) { + break; + } + String parentId = targetModel.getParentId(); + if (parentId == null || parentId.isEmpty()) { + break; + } + toBeInsertPermIds.add(parentId); + targetId = parentId; + } } /**