Browse Source

添加成员限制超管,批量添加校验

Bob 2 years ago
parent
commit
d7f5469b91

+ 19 - 5
pdf-tech-core/src/main/java/cn/kdan/pdf/tech/core/service/impl/VppRTeamMemberRoleServiceImpl.java

@@ -129,9 +129,9 @@ public class VppRTeamMemberRoleServiceImpl implements VppRTeamMemberRoleService
             if (!CollectionUtils.isEmpty(vppRTeamMemberRoles)) {
                 throw new BackendRuntimeException(VppMemberConstant.MEMBEU_HAS_JOINED);
             }
-            // 查询是否为本团队管理员
+            // 查询是否为本团队管理员或超管
             VppRTeamMemberRoleExample example1 = new VppRTeamMemberRoleExample();
-            example1.createCriteria().andMemberIdEqualTo(byAccount.getId()).andTeamIdEqualTo(dto.getTeamId()).andRoleIdLike("2");
+            example1.createCriteria().andMemberIdEqualTo(byAccount.getId()).andTeamIdEqualTo(dto.getTeamId()).andRoleIdIn(Arrays.asList("1", "2"));
             List<VppRTeamMemberRole> vppRTeamMemberRoles1 = vppRTeamMemberRoleMapper.selectByExample(example1);
             if (!CollectionUtils.isEmpty(vppRTeamMemberRoles1)) {
                 throw new BackendRuntimeException(VppMemberConstant.MEMBEU_HAS_ADMIN);
@@ -203,14 +203,28 @@ public class VppRTeamMemberRoleServiceImpl implements VppRTeamMemberRoleService
                 }
                 // 查询用户是否已存在
                 VppMember vppMember = vppMemberService.getByAccount(memberEmail);
-                // 如果成员存在
+                // 如果成员存在,校验数据
                 if (null != vppMember) {
-                    // 校验数据,查询用户是否已存在在团队中
+                    // 判断是否存在于其他公司
+                    if (!vppMember.getCompanyId().equals(user.getCompanyId())) {
+                        continue;
+//                        throw new BackendRuntimeException(VppMemberConstant.MEMBEU_HAS_JOINED);
+                    }
+                    // 查询用户是否已存在其他团队中
                     VppRTeamMemberRoleExample example = new VppRTeamMemberRoleExample();
-                    example.createCriteria().andMemberIdEqualTo(vppMember.getId()).andRoleIdLike("3");
+                    example.createCriteria().andMemberIdEqualTo(vppMember.getId()).andTeamIdNotEqualTo(vppTeam.getId()).andRoleIdLike("3");
                     List<VppRTeamMemberRole> vppRTeamMemberRoles = vppRTeamMemberRoleMapper.selectByExample(example);
                     if (!CollectionUtils.isEmpty(vppRTeamMemberRoles)) {
                         continue;
+//                        throw new BackendRuntimeException(VppMemberConstant.MEMBEU_HAS_JOINED);
+                    }
+                    // 查询是否为本团队管理员或超管
+                    VppRTeamMemberRoleExample example1 = new VppRTeamMemberRoleExample();
+                    example1.createCriteria().andMemberIdEqualTo(vppMember.getId()).andTeamIdEqualTo(vppTeam.getId()).andRoleIdIn(Arrays.asList("1", "2"));
+                    List<VppRTeamMemberRole> vppRTeamMemberRoles1 = vppRTeamMemberRoleMapper.selectByExample(example1);
+                    if (!CollectionUtils.isEmpty(vppRTeamMemberRoles1)) {
+                        continue;
+//                        throw new BackendRuntimeException(VppMemberConstant.MEMBEU_HAS_ADMIN);
                     }
                 }