新版权限小组角色新增与更新前置获取数据方法与保存小组权限接口内容调整

This commit is contained in:
anhc 2022-07-04 17:46:53 +08:00
parent 5b93fc8fa4
commit d0cf8ac517

View File

@ -3,6 +3,8 @@ package com.actionsoft.apps.coe.pal.cooperation.web;
import com.actionsoft.apps.coe.pal.constant.CoEConstant; import com.actionsoft.apps.coe.pal.constant.CoEConstant;
import com.actionsoft.apps.coe.pal.cooperation.CoeCooperationAPIManager; import com.actionsoft.apps.coe.pal.cooperation.CoeCooperationAPIManager;
import com.actionsoft.apps.coe.pal.cooperation.CooperationQueryAPIManager; import com.actionsoft.apps.coe.pal.cooperation.CooperationQueryAPIManager;
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.constant.CoeCooperationConst;
import com.actionsoft.apps.coe.pal.cooperation.constant.Constant; import com.actionsoft.apps.coe.pal.cooperation.constant.Constant;
import com.actionsoft.apps.coe.pal.cooperation.dao.CoeCooperationMemberDao; import com.actionsoft.apps.coe.pal.cooperation.dao.CoeCooperationMemberDao;
@ -725,6 +727,8 @@ public class CooperationWeb extends ActionWeb {
boolean isAllDataPerm = false;// 是否有全部数据权限 boolean isAllDataPerm = false;// 是否有全部数据权限
List<String> dataPerm = new ArrayList<>();// 数据权限 List<String> dataPerm = new ArrayList<>();// 数据权限
Map<String,List<String>> dataActionPerm = new HashMap<>(); //数据操作权限
JSONArray dataActionPermOpts = new JSONArray();// 操作权限选项
List<String> dataPermTextList = new ArrayList<>();// 数据权限文字用于界面显示 List<String> dataPermTextList = new ArrayList<>();// 数据权限文字用于界面显示
boolean isAllAppPerm = false;// 是否有全部应用权限 boolean isAllAppPerm = false;// 是否有全部应用权限
List<String> appPerm = new ArrayList<>();// 应用权限 List<String> appPerm = new ArrayList<>();// 应用权限
@ -739,18 +743,45 @@ public class CooperationWeb extends ActionWeb {
appPermOpts.add(appObj); appPermOpts.add(appObj);
} }
// 获取操作权限选项 // 获取操作权限选项
JSONObject actionObj1 = new JSONObject(); boolean isOlderVersion = SDK.getAppAPI().getPropertyBooleanValue("com.actionsoft.apps.coe.pal", "IsOlderVersion", true);
actionObj1.put("value", "新增、修改"); if (isOlderVersion){
actionObj1.put("label", CoeCooperationConst.ACTION_WRITE); JSONObject actionObj1 = new JSONObject();
JSONObject actionObj2 = new JSONObject(); actionObj1.put("value", "新增、修改");
actionObj2.put("value", "删除"); actionObj1.put("label", CoeCooperationConst.ACTION_WRITE);
actionObj2.put("label", CoeCooperationConst.ACTION_DELETE); JSONObject actionObj2 = new JSONObject();
JSONObject actionObj3 = new JSONObject(); actionObj2.put("value", "删除");
actionObj3.put("value", "版本管理"); actionObj2.put("label", CoeCooperationConst.ACTION_DELETE);
actionObj3.put("label", CoeCooperationConst.ACTION_VERSION); JSONObject actionObj3 = new JSONObject();
actionPermOpts.add(actionObj1); actionObj3.put("value", "版本管理");
actionPermOpts.add(actionObj2); actionObj3.put("label", CoeCooperationConst.ACTION_VERSION);
actionPermOpts.add(actionObj3); actionPermOpts.add(actionObj1);
actionPermOpts.add(actionObj2);
actionPermOpts.add(actionObj3);
}else {
JSONObject actionObj1 = new JSONObject();
actionObj1.put("value", "新增、修改");
actionObj1.put("label", CoeCooperationConst.ACTION_CREATE_PROCESS);
JSONObject actionObj2 = new JSONObject();
actionObj2.put("value", "批量创建/替换");
actionObj2.put("label", CoeCooperationConst.ACTION_BATCH);
actionPermOpts.add(actionObj1);
actionPermOpts.add(actionObj2);
JSONObject actionObj3 = new JSONObject();
actionObj1.put("value", "编辑");
actionObj1.put("label", CoeCooperationConst.ACTION_WRITE);
JSONObject actionObj4 = new JSONObject();
actionObj2.put("value", "删除");
actionObj2.put("label", CoeCooperationConst.ACTION_DELETE);
JSONObject actionObj5 = new JSONObject();
actionObj3.put("value", "版本管理");
actionObj3.put("label", CoeCooperationConst.ACTION_VERSION);
dataActionPermOpts.add(actionObj3);
dataActionPermOpts.add(actionObj4);
dataActionPermOpts.add(actionObj5);
}
// 3.修改新建差异数据查询 // 3.修改新建差异数据查询
if (UtilString.isEmpty(roleId)) { if (UtilString.isEmpty(roleId)) {
@ -783,6 +814,14 @@ public class CooperationWeb extends ActionWeb {
} }
} }
} }
if (!isOlderVersion){
//新版权限具体文件的操作权限
List<CoeCooperationRolePermModel> rolePermModels = api.queryCooperationRoleDataPermList(teamId, roleId);
for (CoeCooperationRolePermModel rolePermModel : rolePermModels) {
dataActionPerm.put(rolePermModel.getPalVersionId(), Arrays.asList(rolePermModel.getActionPerm().split(",").clone()));
}
}
} }
// 获取应用权限数据 // 获取应用权限数据
isAllAppPerm = CoeCooperationConst.PERM_ALL.equalsIgnoreCase(role.getAppPerm()); isAllAppPerm = CoeCooperationConst.PERM_ALL.equalsIgnoreCase(role.getAppPerm());
@ -808,6 +847,8 @@ public class CooperationWeb extends ActionWeb {
ro.put("isAllDataPerm", isAllDataPerm); ro.put("isAllDataPerm", isAllDataPerm);
ro.put("isAllAppPerm", isAllAppPerm); ro.put("isAllAppPerm", isAllAppPerm);
ro.put("dataPerm", dataPerm); ro.put("dataPerm", dataPerm);
ro.put("dataActionPerm", dataActionPerm);
ro.put("dataActionPermOpts", dataActionPermOpts);
ro.put("appPerm", appPerm); ro.put("appPerm", appPerm);
ro.put("actionPerm", actionPerm); ro.put("actionPerm", actionPerm);
ro.put("dataPermText", StringUtils.join(dataPermTextList, ",")); ro.put("dataPermText", StringUtils.join(dataPermTextList, ","));
@ -1021,10 +1062,21 @@ public class CooperationWeb extends ActionWeb {
String dataPermStr = "all"; String dataPermStr = "all";
List<CoeCooperationRolePermModel> rolePermList = new ArrayList<>(); List<CoeCooperationRolePermModel> rolePermList = new ArrayList<>();
boolean isOlderVersion = SDK.getAppAPI().getPropertyBooleanValue("com.actionsoft.apps.coe.pal", "IsOlderVersion", true);
if (!isAllDataPerm) { if (!isAllDataPerm) {
for (int i = 0; i < dataPerm.size(); i++) { if (isOlderVersion){
if (dataPerm.getString(i).length() >= 36) { for (int i = 0; i < dataPerm.size(); i++) {
CoeCooperationRolePermModel model = new CoeCooperationRolePermModel(UUIDGener.getUUID(), teamId, newRoleId, dataPerm.getString(i)); if (dataPerm.getString(i).length() >= 36) {
CoeCooperationRolePermModel model = new CoeCooperationRolePermModel(UUIDGener.getUUID(), teamId, newRoleId, dataPerm.getString(i));
rolePermList.add(model);
}
}
}else {
for (int i = 0; i < dataPerm.size(); i++) {
JSONObject dataPermObj = dataPerm.getJSONObject(i);
String versionId = dataPermObj.getString("id");
String perm = dataPermObj.getString("actionPerm");
CoeCooperationRolePermModel model = new CoeCooperationRolePermModel(UUIDGener.getUUID(), teamId, newRoleId, versionId,perm);
rolePermList.add(model); rolePermList.add(model);
} }
} }
@ -1033,6 +1085,7 @@ public class CooperationWeb extends ActionWeb {
Timestamp now = new Timestamp(System.currentTimeMillis()); Timestamp now = new Timestamp(System.currentTimeMillis());
CoeCooperationRoleModel roleModel = new CoeCooperationRoleModel(newRoleId, teamId, roleName, roleDesc, roleType, appPermStr, actionPermStr, dataPermStr, _uc.getUID(), now, _uc.getUID(), now); CoeCooperationRoleModel roleModel = new CoeCooperationRoleModel(newRoleId, teamId, roleName, roleDesc, roleType, appPermStr, actionPermStr, dataPermStr, _uc.getUID(), now, _uc.getUID(), now);
roleModel.setIsUser(0);
boolean isSuccess = false; boolean isSuccess = false;
if (UtilString.isEmpty(roleId)) {// 新增 if (UtilString.isEmpty(roleId)) {// 新增
isSuccess = api.createCooperationRole(roleModel); isSuccess = api.createCooperationRole(roleModel);
@ -1048,6 +1101,11 @@ public class CooperationWeb extends ActionWeb {
} }
if (!isSuccess) { if (!isSuccess) {
return ResponseObject.newErrResponse("保存角色数据权限失败").toString(); return ResponseObject.newErrResponse("保存角色数据权限失败").toString();
}else {
if (StringUtils.isNotEmpty(roleId)){
//更新用户角色权限缓存
CooperationCache.updateTeamInfo(teamId);
}
} }
} else { } else {
return ResponseObject.newErrResponse("保存角色失败").toString(); return ResponseObject.newErrResponse("保存角色失败").toString();
@ -1102,6 +1160,7 @@ public class CooperationWeb extends ActionWeb {
roleOpts.add(obj); roleOpts.add(obj);
} }
ro.put("roleOpts", JSON.toJSON(roleOpts)); ro.put("roleOpts", JSON.toJSON(roleOpts));
ro.put("isOlderVersion", SDK.getAppAPI().getPropertyBooleanValue("com.actionsoft.apps.coe.pal", "IsOlderVersion", true));
return ro.toString(); return ro.toString();
} }