小组权限,新建小组时补充隐藏角色的新建
This commit is contained in:
parent
03f0114f75
commit
13bbd9ecb7
Binary file not shown.
@ -205,6 +205,8 @@ public class CooperationWeb extends ActionWeb {
|
||||
// 小组权限信息
|
||||
JSONArray repositoryVerIds = dataObj.getJSONArray("repositorys");
|
||||
CoeCooperationAPIManager api = CoeCooperationAPIManager.getInstance();
|
||||
//新权限标志
|
||||
boolean isOlderVersion = SDK.getAppAPI().getPropertyBooleanValue("com.actionsoft.apps.coe.pal", "IsOlderVersion", true);
|
||||
if (UtilString.isEmpty(teamId)) {// 新建
|
||||
Timestamp nowTime = new Timestamp(System.currentTimeMillis());
|
||||
teamId = UUIDGener.getUUID();
|
||||
@ -216,7 +218,25 @@ public class CooperationWeb extends ActionWeb {
|
||||
msg = "保存小组信息";
|
||||
if (isOk) {
|
||||
// 创建默认角色信息
|
||||
isOk = api.createCooperationDefaultRole(teamId, _uc.getUID());
|
||||
if (isOlderVersion){
|
||||
isOk = api.createCooperationDefaultRole(teamId, _uc.getUID());
|
||||
}else {
|
||||
isOk = api.createCooperationDefaultRoleNewPerm(teamId, _uc.getUID());
|
||||
if (isOk){
|
||||
//创建默认用户权限
|
||||
List<CoeCooperationRoleModel> roleList = new ArrayList<>();
|
||||
Timestamp now = new Timestamp(System.currentTimeMillis());
|
||||
for (int i = 0; i < adminArr.size(); i++) {
|
||||
String adminId = adminArr.getString(i);
|
||||
CoeCooperationRoleModel roleModel = new CoeCooperationRoleModel(UUIDGener.getUUID(), teamId, adminId,
|
||||
"", 3, "", "", "", _uc.getUID(), now, _uc.getUID(), now,1);
|
||||
roleList.add(roleModel);
|
||||
}
|
||||
//批量插入用户隐藏角色
|
||||
api.createCooperationRoles(roleList);
|
||||
}
|
||||
}
|
||||
|
||||
msg = "创建默认角色信息";
|
||||
if (isOk) {
|
||||
// 查询管理员角色ID
|
||||
@ -246,6 +266,10 @@ public class CooperationWeb extends ActionWeb {
|
||||
if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) {
|
||||
CoEOpLogAPI.auditOkOp(_uc, CoEOpLogConst.MODULE_CATEGORY_COOPERATION, CoEOpLogConst.OP_CREATE, CoEOpLogConst.INFO_COOPERATION_CREATE);
|
||||
}
|
||||
if (!isOlderVersion){
|
||||
//更新用户权限缓存
|
||||
CooperationCache.updateTeamInfo(teamId);
|
||||
}
|
||||
return ResponseObject.newOkResponse().toString();
|
||||
} else {
|
||||
return ResponseObject.newErrResponse(msg + ",保存失败").toString();
|
||||
@ -257,6 +281,13 @@ public class CooperationWeb extends ActionWeb {
|
||||
if (isOk) {
|
||||
// 删除该管理员角色下的所有成员
|
||||
api.removeCooperationMemebers(teamId, CoeCooperationConst.ROLE_TYPE_MANAGER);
|
||||
if (!isOlderVersion){
|
||||
//删除小组下所有管理员的隐藏角色-用户权限
|
||||
for (int i = 0; i < adminArr.size(); i++) {
|
||||
String userId = adminArr.getString(i);
|
||||
api.removeCooperationMemebersHideRole(teamId,userId);
|
||||
}
|
||||
}
|
||||
// 查询管理员角色ID
|
||||
CoeCooperationRoleModel role = api.queryCooperationRoleByType(teamId, CoeCooperationConst.ROLE_TYPE_MANAGER).get(0);
|
||||
// 创建管理员信息
|
||||
@ -269,6 +300,19 @@ public class CooperationWeb extends ActionWeb {
|
||||
members.add(member);
|
||||
}
|
||||
isOk = api.createCooperationMemebers(members);
|
||||
if (isOk && !isOlderVersion){
|
||||
//重新创建默认用户权限
|
||||
List<CoeCooperationRoleModel> roleList = new ArrayList<>();
|
||||
Timestamp now = new Timestamp(System.currentTimeMillis());
|
||||
for (int i = 0; i < adminArr.size(); i++) {
|
||||
String adminId = adminArr.getString(i);
|
||||
CoeCooperationRoleModel roleModel = new CoeCooperationRoleModel(UUIDGener.getUUID(), teamId, adminId,
|
||||
"", 3, "", "", "", _uc.getUID(), now, _uc.getUID(), now,1);
|
||||
roleList.add(roleModel);
|
||||
}
|
||||
//批量插入用户隐藏角色
|
||||
api.createCooperationRoles(roleList);
|
||||
}
|
||||
msg = "更新小组管理员信息";
|
||||
if (isOk) {
|
||||
api.removeCooperationTeamPerms(teamId);
|
||||
@ -291,6 +335,10 @@ public class CooperationWeb extends ActionWeb {
|
||||
if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) {
|
||||
CoEOpLogAPI.auditOkOp(_uc, CoEOpLogConst.MODULE_CATEGORY_COOPERATION, CoEOpLogConst.OP_UPDATE, CoEOpLogConst.INFO_COOPERATION_UPDATE);
|
||||
}
|
||||
if (!isOlderVersion){
|
||||
//更新用户权限缓存
|
||||
CooperationCache.updateTeamInfo(teamId);
|
||||
}
|
||||
return ResponseObject.newOkResponse().toString();
|
||||
} else {
|
||||
return ResponseObject.newErrResponse(msg + ",更新失败").toString();
|
||||
|
||||
Binary file not shown.
@ -208,6 +208,27 @@ public class CoeCooperationAPIManager {
|
||||
return new CoeCooperationRoleDao().batchInsert(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新小组权限创建默认角色
|
||||
* @param teamId
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
public boolean createCooperationDefaultRoleNewPerm(String teamId, String userId) {
|
||||
Timestamp nowTime = new Timestamp(System.currentTimeMillis());
|
||||
// 全部数据权限、全部操作权限、全部应用权限、小组信息权限
|
||||
CoeCooperationRoleModel role1 = new CoeCooperationRoleModel(UUIDGener.getUUID(), teamId, "管理员", "拥有小组的管理权限,可以对小组信息和小组成员进行管理。", CoeCooperationConst.ROLE_TYPE_MANAGER, CoeCooperationConst.PERM_ALL, CoeCooperationConst.ACTION_CREATE_PROCESS + "," + CoeCooperationConst.ACTION_BATCH , CoeCooperationConst.PERM_ALL, userId, nowTime, userId, nowTime);
|
||||
// 全部数据权限、全部操作权限、全部应用权限
|
||||
CoeCooperationRoleModel role2 = new CoeCooperationRoleModel(UUIDGener.getUUID(), teamId, "设计成员", "拥有小组所有数据和功能权限,可以对小组内的资产进行管理。", CoeCooperationConst.ROLE_TYPE_DESIGNER, CoeCooperationConst.PERM_ALL, CoeCooperationConst.ACTION_CREATE_PROCESS + "," + CoeCooperationConst.ACTION_BATCH , CoeCooperationConst.PERM_ALL, userId, nowTime, userId, nowTime);
|
||||
// 全部数据权限、无操作权限、无流程梳理以外应用权限
|
||||
CoeCooperationRoleModel role3 = new CoeCooperationRoleModel(UUIDGener.getUUID(), teamId, "浏览成员", "拥有小组内所有数据的浏览权限", CoeCooperationConst.ROLE_TYPE_VISITOR, "", "", CoeCooperationConst.PERM_ALL, userId, nowTime, userId, nowTime);
|
||||
List<CoeCooperationRoleModel> list = new ArrayList<>();
|
||||
list.add(role1);
|
||||
list.add(role2);
|
||||
list.add(role3);
|
||||
return new CoeCooperationRoleDao().batchInsert(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量创建小组角色
|
||||
* @param list
|
||||
@ -339,6 +360,19 @@ public class CoeCooperationAPIManager {
|
||||
new CoeCooperationMemberDao().remove(teamId, role.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除小组下指定角色类型的隐藏角色-用户权限
|
||||
* @param teamId
|
||||
* @param roleType
|
||||
*/
|
||||
public void removeCooperationMemebersHideRole(String teamId, String userid) {
|
||||
CoeCooperationRoleDao roleDao = new CoeCooperationRoleDao();
|
||||
CoeCooperationRoleModel hideRole = roleDao.getCooperationHideRoleByRoleName(teamId, userid);
|
||||
if (null != hideRole){
|
||||
roleDao.remove(teamId,hideRole.getId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除某个具体角色下的所有成员
|
||||
* @param teamId
|
||||
|
||||
Loading…
Reference in New Issue
Block a user