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 d2152186..d97cebc8 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 601e7906..c640fa33 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 @@ -694,22 +694,12 @@ public class CooperationWeb extends ActionWeb { if (team == null) { return ResponseObject.newErrResponse("保存失败,小组不存在").toString(); } - Timestamp now = new Timestamp(System.currentTimeMillis()); - List memberList = new ArrayList<>(); boolean isOlderVersion = SDK.getAppAPI().getPropertyBooleanValue("com.actionsoft.apps.coe.pal", "IsOlderVersion", true); - JSONArray roleIds = new JSONArray(); if (isOlderVersion){ // 查询当前设置的角色 String roleId = dataObj.getString("roleId"); - roleIds.add(roleId); - }else { - roleIds = dataObj.getJSONArray("roleId"); - } - //多角色的校验 - CoeCooperationRoleDao roleDao = new CoeCooperationRoleDao(); - for (int i = 0; i < roleIds.size(); i++) { - String roleId = roleIds.getString(i); + CoeCooperationRoleDao roleDao = new CoeCooperationRoleDao(); CoeCooperationRoleModel role = roleDao.getInstance(roleId); // 如果当前设置的角色不是管理员,查询其他用户是否有管理员角色,小组中必须有至少一位管理员用户 if (role.getRoleType() != CoeCooperationConst.ROLE_TYPE_MANAGER) { @@ -725,18 +715,46 @@ public class CooperationWeb extends ActionWeb { if (!flag) { return ResponseObject.newErrResponse("不允许修改,小组中必须至少存在一位管理员用户").toString(); } - }else { - break; } - } - //设置多角色 - for (int i = 0; i < userIds.size(); i++) { - //删除原有角色 - api.removeCooperationMemeber(teamId,userIds.getString(i)); - 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); + 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(); + } + }else { + break; + } + } + //设置多角色 + Timestamp now = new Timestamp(System.currentTimeMillis()); + List memberList = new ArrayList<>(); + for (int i = 0; i < userIds.size(); i++) { + //删除原有角色 + api.removeCooperationMemeber(teamId,userIds.getString(i)); + 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);