小组应用小组用户权限缓存应用权限调整
This commit is contained in:
parent
5fcbd9bfaa
commit
6da183ea67
@ -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<UserInfo> userInfos = this.getUserInfoByTeamId(teamModel.getId());
|
||||
teamInfo.setUsers(userInfos);
|
||||
|
||||
List<String> permVerIds = new CoeCooperationTeamPermDao().getCooperationTeamPermVerIds(teamModel.getId());
|
||||
teamInfo.getVersionIds().addAll(permVerIds);
|
||||
|
||||
list.add(teamInfo);
|
||||
}
|
||||
return list;
|
||||
@ -161,41 +162,104 @@ public class CooperationQueryAPIManager {
|
||||
public List<UserInfo> getUserInfoByTeamId(String teamId){
|
||||
List<UserInfo> list = new ArrayList<>();
|
||||
|
||||
Map<String,UserInfo> userMap = new HashMap<>();
|
||||
List<CoeCooperationMemberModel> 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<String> actionPermList = Arrays.stream(roleModel.getActionPerm().split(",")).collect(Collectors.toList());
|
||||
userInfo.getOperatePermission().addAll(actionPermList);
|
||||
//设置全部数据权限
|
||||
userInfo.setIsAllDataPermission(roleModel.getDataPerm().equals("all"));
|
||||
|
||||
if (!userInfo.getIsAllDataPermission()){
|
||||
//获取角色下数据权限,设置数据权限
|
||||
List<CoeCooperationRolePermModel> rolePerms = new CoeCooperationRolePermDao().getRolePermByTeamIdAndRoleId(teamId, memberModel.getRoleId());
|
||||
for (CoeCooperationRolePermModel rolePerm : rolePerms) {
|
||||
Set<String> 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<String> roleIds = userInfo.getRoleIds();
|
||||
Set<String> appPerm = this.getAppPerm(roleIds);
|
||||
userInfo.setAppPermission(appPerm);
|
||||
|
||||
Set<String> actionPerm = this.getActionPerm(roleIds);
|
||||
userInfo.setOperatePermission(actionPerm);
|
||||
|
||||
boolean allDataPerm = this.isAllDataPerm(roleIds);
|
||||
userInfo.setIsAllDataPermission(allDataPerm);
|
||||
|
||||
if (!allDataPerm){
|
||||
Map<String, Set<String>> dataPerm = this.getDataPerm(teamId, roleIds);
|
||||
userInfo.setDataPermission(dataPerm);
|
||||
}
|
||||
}
|
||||
|
||||
list.addAll(userMap.values());
|
||||
return list;
|
||||
}
|
||||
|
||||
private Set<String> getAppPerm(List<String> roleIds){
|
||||
Set<String> set = new HashSet<>();
|
||||
for (String roleId : roleIds) {
|
||||
CoeCooperationRoleModel roleModel = new CoeCooperationRoleDao().queryById(roleId);
|
||||
if (null == roleModel){
|
||||
continue;
|
||||
}
|
||||
//设置全局app权限
|
||||
List<String> appPerm = Arrays.stream(roleModel.getAppPerm().split(",")).collect(Collectors.toList());
|
||||
set.addAll(appPerm);
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
private Set<String> getActionPerm(List<String> roleIds){
|
||||
Set<String> set = new HashSet<>();
|
||||
for (String roleId : roleIds) {
|
||||
CoeCooperationRoleModel roleModel = new CoeCooperationRoleDao().queryById(roleId);
|
||||
if (null == roleModel){
|
||||
continue;
|
||||
}
|
||||
//设置全局操作权限
|
||||
List<String> actionPermList = Arrays.stream(roleModel.getActionPerm().split(",")).collect(Collectors.toList());
|
||||
set.addAll(actionPermList);
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
private boolean isAllDataPerm(List<String> 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<String,Set<String>> getDataPerm(String teamId,List<String> roleIds){
|
||||
Map<String,Set<String>> map = new HashMap<>();
|
||||
for (String roleId : roleIds) {
|
||||
CoeCooperationRoleModel roleModel = new CoeCooperationRoleDao().queryById(roleId);
|
||||
if (null == roleModel) {
|
||||
continue;
|
||||
}
|
||||
//获取角色下数据权限,设置数据权限
|
||||
List<CoeCooperationRolePermModel> rolePerms = new CoeCooperationRolePermDao().getRolePermByTeamIdAndRoleId(teamId, roleId);
|
||||
for (CoeCooperationRolePermModel rolePerm : rolePerms) {
|
||||
Set<String> 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据父节点获取权限范围内的子流程(小组权限范围内)
|
||||
|
||||
@ -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<String, TeamInfo> {
|
||||
if (null == userInfo){
|
||||
return new HashSet<>();
|
||||
}
|
||||
String appPerm = userInfo.getAppPermission();
|
||||
if ("all".equals(appPerm)){
|
||||
Set<String> appPermission = userInfo.getAppPermission();
|
||||
if (appPermission.contains("all")){
|
||||
Set<String> set = new HashSet<>();
|
||||
List<CooperationAppProfile> appProfiles = CooperationAppManager.getList();
|
||||
for (CooperationAppProfile profile : appProfiles) {
|
||||
@ -129,7 +130,7 @@ public class CooperationCache extends Cache<String, TeamInfo> {
|
||||
}
|
||||
return set;
|
||||
}
|
||||
return Arrays.stream(appPerm.split(",")).collect(Collectors.toSet());
|
||||
return appPermission;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -143,6 +144,10 @@ public class CooperationCache extends Cache<String, TeamInfo> {
|
||||
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<String, TeamInfo> {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@ -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<UserInfo> users;
|
||||
|
||||
private Set<String> versionIds = new HashSet<>();
|
||||
|
||||
public TeamInfo() {}
|
||||
|
||||
public String getTeamId() {
|
||||
@ -27,4 +31,12 @@ public class TeamInfo implements Serializable {
|
||||
public void setUsers(List<UserInfo> users) {
|
||||
this.users = users;
|
||||
}
|
||||
|
||||
public Set<String> getVersionIds() {
|
||||
return versionIds;
|
||||
}
|
||||
|
||||
public void setVersionIds(Set<String> versionIds) {
|
||||
this.versionIds = versionIds;
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ public class UserInfo implements Serializable {
|
||||
private String userid;
|
||||
private List<String> roleIds = new ArrayList<>();
|
||||
private Set<String> operatePermission = new HashSet<>();
|
||||
private String appPermission ;
|
||||
private Set<String> appPermission = new HashSet<>();
|
||||
private Map<String,Set<String>> dataPermission = new HashMap<>();
|
||||
private boolean isAllDataPermission;
|
||||
|
||||
@ -40,11 +40,11 @@ public class UserInfo implements Serializable {
|
||||
this.operatePermission = operatePermission;
|
||||
}
|
||||
|
||||
public String getAppPermission() {
|
||||
public Set<String> getAppPermission() {
|
||||
return appPermission;
|
||||
}
|
||||
|
||||
public void setAppPermission(String appPermission) {
|
||||
public void setAppPermission(Set<String> appPermission) {
|
||||
this.appPermission = appPermission;
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ public class UserInfo implements Serializable {
|
||||
return dataPermission;
|
||||
}
|
||||
|
||||
public void setIsDataPermission(Map<String, Set<String>> dataPermission) {
|
||||
public void setDataPermission(Map<String, Set<String>> dataPermission) {
|
||||
this.dataPermission = dataPermission;
|
||||
}
|
||||
|
||||
|
||||
@ -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";
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user