diff --git a/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/CooperationQueryAPIManager.java b/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/CooperationQueryAPIManager.java index ac468beb..20e9cd96 100644 --- a/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/CooperationQueryAPIManager.java +++ b/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/CooperationQueryAPIManager.java @@ -5,10 +5,7 @@ import com.actionsoft.apps.coe.pal.constant.CoEConstant; import com.actionsoft.apps.coe.pal.cooperation.aslp.ListApps; import com.actionsoft.apps.coe.pal.cooperation.cache.model.TeamInfo; import com.actionsoft.apps.coe.pal.cooperation.cache.model.UserInfo; -import com.actionsoft.apps.coe.pal.cooperation.dao.CoeCooperationMemberDao; -import com.actionsoft.apps.coe.pal.cooperation.dao.CoeCooperationRoleDao; -import com.actionsoft.apps.coe.pal.cooperation.dao.CoeCooperationRolePermDao; -import com.actionsoft.apps.coe.pal.cooperation.dao.CoeCooperationTeamDao; +import com.actionsoft.apps.coe.pal.cooperation.dao.*; import com.actionsoft.apps.coe.pal.cooperation.extend.CooperationAppManager; import com.actionsoft.apps.coe.pal.cooperation.extend.CooperationAppProfile; import com.actionsoft.apps.coe.pal.cooperation.model.CoeCooperationMemberModel; @@ -153,6 +150,10 @@ public class CooperationQueryAPIManager { teamInfo.setTeamId(teamModel.getId()); List userInfos = this.getUserInfoByTeamId(teamModel.getId()); teamInfo.setUsers(userInfos); + + List permVerIds = new CoeCooperationTeamPermDao().getCooperationTeamPermVerIds(teamModel.getId()); + teamInfo.getVersionIds().addAll(permVerIds); + list.add(teamInfo); } return list; @@ -161,41 +162,104 @@ public class CooperationQueryAPIManager { public List getUserInfoByTeamId(String teamId){ List list = new ArrayList<>(); + Map userMap = new HashMap<>(); List memberModels = new CoeCooperationMemberDao().queryUserListByTeam(teamId); for (CoeCooperationMemberModel memberModel : memberModels) { - UserInfo userInfo = new UserInfo(); - userInfo.setUserid(memberModel.getUserId()); - userInfo.getRoleIds().add(memberModel.getRoleId()); - - //获取角色信息,设置全局权限 - CoeCooperationRoleModel roleModel = new CoeCooperationRoleDao().queryById(memberModel.getRoleId()); - userInfo.setAppPermission( roleModel.getAppPerm()); - List actionPermList = Arrays.stream(roleModel.getActionPerm().split(",")).collect(Collectors.toList()); - userInfo.getOperatePermission().addAll(actionPermList); - //设置全部数据权限 - userInfo.setIsAllDataPermission(roleModel.getDataPerm().equals("all")); - - if (!userInfo.getIsAllDataPermission()){ - //获取角色下数据权限,设置数据权限 - List rolePerms = new CoeCooperationRolePermDao().getRolePermByTeamIdAndRoleId(teamId, memberModel.getRoleId()); - for (CoeCooperationRolePermModel rolePerm : rolePerms) { - Set dataPerm = userInfo.getDataPermission().get(rolePerm.getPalVersionId()); - if (null == dataPerm){ - dataPerm = new HashSet<>(); - } - if (StringUtils.isNotEmpty(rolePerm.getActionPerm())){ - dataPerm.addAll(Arrays.asList(rolePerm.getActionPerm().split(",").clone())); - } - userInfo.getDataPermission().put(rolePerm.getPalVersionId(), dataPerm); - } + UserInfo userInfo = userMap.get(memberModel.getUserId()); + if (null == userInfo){ + userInfo = new UserInfo(); + userInfo.setUserid(memberModel.getUserId()); + userInfo.getRoleIds().add(memberModel.getRoleId()); + }else { + userInfo.getRoleIds().add(memberModel.getRoleId()); } - - list.add(userInfo); + userMap.put(memberModel.getUserId(),userInfo); } + for (UserInfo userInfo : userMap.values()) { + List roleIds = userInfo.getRoleIds(); + Set appPerm = this.getAppPerm(roleIds); + userInfo.setAppPermission(appPerm); + + Set actionPerm = this.getActionPerm(roleIds); + userInfo.setOperatePermission(actionPerm); + + boolean allDataPerm = this.isAllDataPerm(roleIds); + userInfo.setIsAllDataPermission(allDataPerm); + + if (!allDataPerm){ + Map> dataPerm = this.getDataPerm(teamId, roleIds); + userInfo.setDataPermission(dataPerm); + } + } + + list.addAll(userMap.values()); return list; } + private Set getAppPerm(List roleIds){ + Set set = new HashSet<>(); + for (String roleId : roleIds) { + CoeCooperationRoleModel roleModel = new CoeCooperationRoleDao().queryById(roleId); + if (null == roleModel){ + continue; + } + //设置全局app权限 + List appPerm = Arrays.stream(roleModel.getAppPerm().split(",")).collect(Collectors.toList()); + set.addAll(appPerm); + } + return set; + } + + private Set getActionPerm(List roleIds){ + Set set = new HashSet<>(); + for (String roleId : roleIds) { + CoeCooperationRoleModel roleModel = new CoeCooperationRoleDao().queryById(roleId); + if (null == roleModel){ + continue; + } + //设置全局操作权限 + List actionPermList = Arrays.stream(roleModel.getActionPerm().split(",")).collect(Collectors.toList()); + set.addAll(actionPermList); + } + return set; + } + + private boolean isAllDataPerm(List roleIds){ + for (String roleId : roleIds) { + CoeCooperationRoleModel roleModel = new CoeCooperationRoleDao().queryById(roleId); + if (null == roleModel){ + continue; + } + if (roleModel.getDataPerm().equals("all")){ + return true; + } + } + return false; + } + + private Map> getDataPerm(String teamId,List roleIds){ + Map> map = new HashMap<>(); + for (String roleId : roleIds) { + CoeCooperationRoleModel roleModel = new CoeCooperationRoleDao().queryById(roleId); + if (null == roleModel) { + continue; + } + //获取角色下数据权限,设置数据权限 + List rolePerms = new CoeCooperationRolePermDao().getRolePermByTeamIdAndRoleId(teamId, roleId); + for (CoeCooperationRolePermModel rolePerm : rolePerms) { + Set dataPerm = map.get(rolePerm.getPalVersionId()); + if (null == dataPerm){ + dataPerm = new HashSet<>(); + } + if (StringUtils.isNotEmpty(rolePerm.getActionPerm())){ + dataPerm.addAll(Arrays.asList(rolePerm.getActionPerm().split(",").clone())); + } + map.put(rolePerm.getPalVersionId(), dataPerm); + } + } + return map; + } /** * 根据父节点获取权限范围内的子流程(小组权限范围内) diff --git a/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/cache/CooperationCache.java b/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/cache/CooperationCache.java index 1247ee21..0237ca20 100644 --- a/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/cache/CooperationCache.java +++ b/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/cache/CooperationCache.java @@ -3,6 +3,7 @@ package com.actionsoft.apps.coe.pal.cooperation.cache; import com.actionsoft.apps.coe.pal.cooperation.CooperationQueryAPIManager; import com.actionsoft.apps.coe.pal.cooperation.cache.model.TeamInfo; import com.actionsoft.apps.coe.pal.cooperation.cache.model.UserInfo; +import com.actionsoft.apps.coe.pal.cooperation.constant.CoeCooperationConst; import com.actionsoft.apps.coe.pal.cooperation.constant.Constant; import com.actionsoft.apps.coe.pal.cooperation.extend.CooperationAppManager; import com.actionsoft.apps.coe.pal.cooperation.extend.CooperationAppProfile; @@ -120,8 +121,8 @@ public class CooperationCache extends Cache { if (null == userInfo){ return new HashSet<>(); } - String appPerm = userInfo.getAppPermission(); - if ("all".equals(appPerm)){ + Set appPermission = userInfo.getAppPermission(); + if (appPermission.contains("all")){ Set set = new HashSet<>(); List appProfiles = CooperationAppManager.getList(); for (CooperationAppProfile profile : appProfiles) { @@ -129,7 +130,7 @@ public class CooperationCache extends Cache { } return set; } - return Arrays.stream(appPerm.split(",")).collect(Collectors.toSet()); + return appPermission; } /** @@ -143,6 +144,10 @@ public class CooperationCache extends Cache { if (null == userInfo){ return new HashSet<>(); } + if (userInfo.getIsAllDataPermission()){ + TeamInfo teamInfo = CooperationCache.getTeamInfo(teamId); + return teamInfo.getVersionIds(); + } return userInfo.getDataPermission().keySet(); } @@ -158,6 +163,9 @@ public class CooperationCache extends Cache { if (null == userInfo){ return new HashSet<>(); } + if (userInfo.getIsAllDataPermission()){ + return Arrays.stream(new String [] {CoeCooperationConst.ACTION_WRITE,CoeCooperationConst.ACTION_DELETE,CoeCooperationConst.ACTION_VERSION}).collect(Collectors.toSet()); + } return userInfo.getDataPermission().get(versionId); } diff --git a/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/cache/model/TeamInfo.java b/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/cache/model/TeamInfo.java index eac713f5..fd6585fb 100644 --- a/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/cache/model/TeamInfo.java +++ b/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/cache/model/TeamInfo.java @@ -1,7 +1,9 @@ package com.actionsoft.apps.coe.pal.cooperation.cache.model; import java.io.Serializable; +import java.util.HashSet; import java.util.List; +import java.util.Set; public class TeamInfo implements Serializable { private static final long serialVersionUID = 1L; @@ -10,6 +12,8 @@ public class TeamInfo implements Serializable { private List users; + private Set versionIds = new HashSet<>(); + public TeamInfo() {} public String getTeamId() { @@ -27,4 +31,12 @@ public class TeamInfo implements Serializable { public void setUsers(List users) { this.users = users; } + + public Set getVersionIds() { + return versionIds; + } + + public void setVersionIds(Set versionIds) { + this.versionIds = versionIds; + } } diff --git a/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/cache/model/UserInfo.java b/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/cache/model/UserInfo.java index b79e5b16..fde1e912 100644 --- a/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/cache/model/UserInfo.java +++ b/com.actionsoft.apps.coe.pal.cooperation/src/com/actionsoft/apps/coe/pal/cooperation/cache/model/UserInfo.java @@ -9,7 +9,7 @@ public class UserInfo implements Serializable { private String userid; private List roleIds = new ArrayList<>(); private Set operatePermission = new HashSet<>(); - private String appPermission ; + private Set appPermission = new HashSet<>(); private Map> dataPermission = new HashMap<>(); private boolean isAllDataPermission; @@ -40,11 +40,11 @@ public class UserInfo implements Serializable { this.operatePermission = operatePermission; } - public String getAppPermission() { + public Set getAppPermission() { return appPermission; } - public void setAppPermission(String appPermission) { + public void setAppPermission(Set appPermission) { this.appPermission = appPermission; } @@ -52,7 +52,7 @@ public class UserInfo implements Serializable { return dataPermission; } - public void setIsDataPermission(Map> dataPermission) { + public void setDataPermission(Map> dataPermission) { this.dataPermission = dataPermission; } diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/constant/CoeCooperationConst.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/constant/CoeCooperationConst.java index abdcf7c3..bfacb990 100644 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/constant/CoeCooperationConst.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/cooperation/constant/CoeCooperationConst.java @@ -61,4 +61,14 @@ public class CoeCooperationConst { */ public static final String ACTION_VERSION = "v"; + /** + * 新版角色操作权限:新建流程 + */ + public static final String ACTION_CREATE_PROCESS = "createProcess"; + + /** + * 新版角色操作权限:新建流程 + */ + public static final String ACTION_BATCH = "batch"; + }