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