diff --git a/com.actionsoft.apps.coe.pal.cooperation/lib/com.actionsoft.apps.coe.pal.cooperation.jar b/com.actionsoft.apps.coe.pal.cooperation/lib/com.actionsoft.apps.coe.pal.cooperation.jar index 4035b812..9f69bfb6 100644 Binary files a/com.actionsoft.apps.coe.pal.cooperation/lib/com.actionsoft.apps.coe.pal.cooperation.jar and b/com.actionsoft.apps.coe.pal.cooperation/lib/com.actionsoft.apps.coe.pal.cooperation.jar differ 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 6ca85d07..d879f749 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 @@ -679,33 +679,76 @@ public class CooperationWeb extends ActionWeb { // 基础信息 String teamId = dataObj.getString("teamId"); JSONArray userIds = dataObj.getJSONArray("userIds"); - String roleId = dataObj.getString("roleId"); CoeCooperationAPIManager api = CoeCooperationAPIManager.getInstance(); CoeCooperationTeamModel team = api.queryCooperationTeamById(teamId); if (team == null) { return ResponseObject.newErrResponse("保存失败,小组不存在").toString(); } - // 查询当前设置的角色 - CoeCooperationRoleDao roleDao = new CoeCooperationRoleDao(); - CoeCooperationRoleModel role = roleDao.getInstance(roleId); - // 如果当前设置的角色不是管理员,查询其他用户是否有管理员角色,小组中必须有至少一位管理员用户 - if (role.getRoleType() != CoeCooperationConst.ROLE_TYPE_MANAGER) { - // 查询其他用户的角色是否有管理员 - boolean flag = false; - List adminUsers = api.queryCooperationAdminUsers(teamId); - for (String adminUser : adminUsers) { - if (!userIds.contains(adminUser)) { - flag = true; - break; + boolean isOlderVersion = SDK.getAppAPI().getPropertyBooleanValue("com.actionsoft.apps.coe.pal", "IsOlderVersion", true); + if (isOlderVersion){ + // 查询当前设置的角色 + String roleId = dataObj.getString("roleId"); + CoeCooperationRoleDao roleDao = new CoeCooperationRoleDao(); + CoeCooperationRoleModel role = roleDao.getInstance(roleId); + // 如果当前设置的角色不是管理员,查询其他用户是否有管理员角色,小组中必须有至少一位管理员用户 + if (role.getRoleType() != CoeCooperationConst.ROLE_TYPE_MANAGER) { + // 查询其他用户的角色是否有管理员 + boolean flag = false; + List adminUsers = api.queryCooperationAdminUsers(teamId); + for (String adminUser : adminUsers) { + if (!userIds.contains(adminUser)) { + flag = true; + break; + } + } + if (!flag) { + return ResponseObject.newErrResponse("不允许修改,小组中必须至少存在一位管理员用户").toString(); } } - if (!flag) { - return ResponseObject.newErrResponse("不允许修改,小组中必须至少存在一位管理员用户").toString(); + for (int i = 0; i < userIds.size(); i++) { + api.updateCooperationUserRole(teamId, userIds.getString(i), roleId, _uc.getUID()); + } + }else { + //设置多角色的校验 + JSONArray roleIds = dataObj.getJSONArray("roleId"); + CoeCooperationRoleDao roleDao = new CoeCooperationRoleDao(); + for (int i = 0; i < roleIds.size(); i++) { + String roleId = roleIds.getString(i); + CoeCooperationRoleModel role = roleDao.getInstance(roleId); + // 如果当前设置的角色不是管理员,查询其他用户是否有管理员角色,小组中必须有至少一位管理员用户 + if (role.getRoleType() != CoeCooperationConst.ROLE_TYPE_MANAGER) { + // 查询其他用户的角色是否有管理员 + boolean flag = false; + List adminUsers = api.queryCooperationAdminUsers(teamId); + for (String adminUser : adminUsers) { + if (!userIds.contains(adminUser)) { + flag = true; + break; + } + } + if (!flag) { + return ResponseObject.newErrResponse("不允许修改,小组中必须至少存在一位管理员用户").toString(); + } + } + } + //设置多角色 + Timestamp now = new Timestamp(System.currentTimeMillis()); + for (int i = 0; i < userIds.size(); i++) { + //删除原有角色 + api.removeCooperationMemeber(teamId,userIds.getString(i)); + + List memberList = new ArrayList<>(); + for (int j = 0; j < roleIds.size(); j++) { + String roleId = roleIds.getString(j); + CoeCooperationMemberModel memberModel = new CoeCooperationMemberModel(UUIDGener.getUUID(),teamId,userIds.getString(i),roleId,_uc.getUID(),now,_uc.getUID(),now); + memberList.add(memberModel); + } + //重新添加多角色 + api.createCooperationMemebers(memberList); } } - for (int i = 0; i < userIds.size(); i++) { - api.updateCooperationUserRole(teamId, userIds.getString(i), roleId, _uc.getUID()); - } + //更新用户权限缓存 + CooperationCache.updateTeamInfo(teamId); return ro.toString(); }