|  | @@ -34,19 +34,12 @@ import com.yonge.cooleshow.biz.dal.wrapper.im.ImGroupWrapper;
 | 
	
		
			
				|  |  |  import com.yonge.toolset.base.exception.BizException;
 | 
	
		
			
				|  |  |  import com.yonge.toolset.mybatis.support.PageUtil;
 | 
	
		
			
				|  |  |  import lombok.extern.slf4j.Slf4j;
 | 
	
		
			
				|  |  | +import org.apache.commons.collections.CollectionUtils;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -import java.util.ArrayList;
 | 
	
		
			
				|  |  | -import java.util.Arrays;
 | 
	
		
			
				|  |  | -import java.util.Collections;
 | 
	
		
			
				|  |  | -import java.util.HashMap;
 | 
	
		
			
				|  |  | -import java.util.HashSet;
 | 
	
		
			
				|  |  | -import java.util.List;
 | 
	
		
			
				|  |  | -import java.util.Map;
 | 
	
		
			
				|  |  | -import java.util.Optional;
 | 
	
		
			
				|  |  | -import java.util.Set;
 | 
	
		
			
				|  |  | +import java.util.*;
 | 
	
		
			
				|  |  |  import java.util.stream.Collectors;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
	
		
			
				|  | @@ -106,8 +99,20 @@ public class TenantGroupServiceImpl extends ServiceImpl<TenantGroupMapper, Tenan
 | 
	
		
			
				|  |  |              Map<Long, Integer> groupBy =
 | 
	
		
			
				|  |  |                      userCounts.stream().collect(Collectors.toMap(StudentWrapper.UserCount::getTenantGroupId
 | 
	
		
			
				|  |  |                              , StudentWrapper.UserCount::getCount));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            List<String> imGroupId = records.stream().map(TenantGroupWrapper.TenantGroup::getImGroupId)
 | 
	
		
			
				|  |  | +                    .filter(Objects::nonNull).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +            List<String> existImgGroupIds = new ArrayList<>();
 | 
	
		
			
				|  |  | +            if (imGroupId.isEmpty()) {
 | 
	
		
			
				|  |  | +                List<String> imgGroupIds = imGroupService.lambdaQuery()
 | 
	
		
			
				|  |  | +                        .in(ImGroup::getId, imGroupId)
 | 
	
		
			
				|  |  | +                        .list().stream().map(ImGroup::getId).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +                existImgGroupIds.addAll(imgGroupIds);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              for (TenantGroupWrapper.TenantGroup record : records) {
 | 
	
		
			
				|  |  |                  record.setGroupUserCount(groupBy.getOrDefault(record.getId(), 0));
 | 
	
		
			
				|  |  | +                record.setImGroupExist(existImgGroupIds.contains(record.getImGroupId()));
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return iPage;
 | 
	
	
		
			
				|  | @@ -131,9 +136,8 @@ public class TenantGroupServiceImpl extends ServiceImpl<TenantGroupMapper, Tenan
 | 
	
		
			
				|  |  |              throw new BizException("小组名称已存在");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          this.save(entity);
 | 
	
		
			
				|  |  | -        List<Long> userIds = tenantGroup.getUserIds();
 | 
	
		
			
				|  |  | -        // 有群成员才建立机构小组群
 | 
	
		
			
				|  |  | -        if (!userIds.isEmpty()) {
 | 
	
		
			
				|  |  | +        Long adminId = tenantGroup.getAdminId();
 | 
	
		
			
				|  |  | +        if (adminId != null) {
 | 
	
		
			
				|  |  |              // 建群
 | 
	
		
			
				|  |  |              try {
 | 
	
		
			
				|  |  |                  ImGroupWrapper.ImGroup imGroup = new ImGroupWrapper.ImGroup();
 | 
	
	
		
			
				|  | @@ -149,16 +153,19 @@ public class TenantGroupServiceImpl extends ServiceImpl<TenantGroupMapper, Tenan
 | 
	
		
			
				|  |  |                  throw new BizException("创建机构小组群失败");
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              // 加群成员
 | 
	
		
			
				|  |  | -            try {
 | 
	
		
			
				|  |  | -                imGroupService.addGroupMember(entity.getImGroupId(), new HashSet<>(userIds));
 | 
	
		
			
				|  |  | -            } catch (Exception e) {
 | 
	
		
			
				|  |  | -                log.error("加入机构小组群失败", e);
 | 
	
		
			
				|  |  | -                throw new BizException("加入机构小组群失败");
 | 
	
		
			
				|  |  | +            List<Long> userIds = tenantGroup.getUserIds();
 | 
	
		
			
				|  |  | +            if (CollectionUtils.isNotEmpty(userIds)) {
 | 
	
		
			
				|  |  | +                try {
 | 
	
		
			
				|  |  | +                    imGroupService.addGroupMember(entity.getImGroupId(), new HashSet<>(userIds));
 | 
	
		
			
				|  |  | +                } catch (Exception e) {
 | 
	
		
			
				|  |  | +                    log.error("加入机构小组群失败", e);
 | 
	
		
			
				|  |  | +                    throw new BizException("加入机构小组群失败");
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                studentDao.update(null, Wrappers.<Student>lambdaUpdate()
 | 
	
		
			
				|  |  | +                        .in(Student::getUserId, userIds)
 | 
	
		
			
				|  |  | +                        .eq(Student::getTenantId, tenantGroup.getTenantId())
 | 
	
		
			
				|  |  | +                        .set(Student::getTenantGroupId, entity.getId()));
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            studentDao.update(null, Wrappers.<Student>lambdaUpdate()
 | 
	
		
			
				|  |  | -                    .in(Student::getUserId, userIds)
 | 
	
		
			
				|  |  | -                    .eq(Student::getTenantId, tenantGroup.getTenantId())
 | 
	
		
			
				|  |  | -                    .set(Student::getTenantGroupId, entity.getId()));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return true;
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -171,7 +178,7 @@ public class TenantGroupServiceImpl extends ServiceImpl<TenantGroupMapper, Tenan
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | -    public Boolean update(TenantGroupWrapper.TenantGroup tenantGroup) {
 | 
	
		
			
				|  |  | +    public Boolean update(TenantGroupWrapper.TenantGroup tenantGroup, Boolean imGroupCreate) {
 | 
	
		
			
				|  |  |          TenantGroup oldGroup = this.getById(tenantGroup.getId());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          Integer count = this.lambdaQuery()
 | 
	
	
		
			
				|  | @@ -184,48 +191,20 @@ public class TenantGroupServiceImpl extends ServiceImpl<TenantGroupMapper, Tenan
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          TenantGroup entity = JSON.parseObject(tenantGroup.jsonString(), TenantGroup.class);
 | 
	
		
			
				|  |  | -        // 修改小组负责人,调整群主,更换群主需要新的群主为该群成员
 | 
	
		
			
				|  |  | -        if (oldGroup.getImGroupId() != null && !oldGroup.getAdminId().equals(entity.getAdminId())) {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            // 如果新负责人不在群,先加入群
 | 
	
		
			
				|  |  | -            Integer toAdminInThisGroup = imGroupMemberService.lambdaQuery()
 | 
	
		
			
				|  |  | -                    .eq(ImGroupMember::getGroupId, oldGroup.getImGroupId())
 | 
	
		
			
				|  |  | -                    .eq(ImGroupMember::getUserId, entity.getAdminId())
 | 
	
		
			
				|  |  | -                    .count();
 | 
	
		
			
				|  |  | -            if (toAdminInThisGroup == 0) {
 | 
	
		
			
				|  |  | -                // 新负责人加入群
 | 
	
		
			
				|  |  | -                try {
 | 
	
		
			
				|  |  | -                    SysUser newTeacher = sysUserService.getByUserId(entity.getAdminId());
 | 
	
		
			
				|  |  | -                    ImGroupMember imGroupMember = new ImGroupMember();
 | 
	
		
			
				|  |  | -                    imGroupMember.setGroupId(oldGroup.getImGroupId());
 | 
	
		
			
				|  |  | -                    imGroupMember.setUserId(entity.getAdminId());
 | 
	
		
			
				|  |  | -                    imGroupMember.setRoleType(ImGroupMemberRoleType.TEACHER);
 | 
	
		
			
				|  |  | -                    imGroupMember.setAvatar(newTeacher.getAvatar());
 | 
	
		
			
				|  |  | -                    imGroupMember.setNickname(newTeacher.getUsername());
 | 
	
		
			
				|  |  | -                    imGroupMember.setIsAdmin(false);
 | 
	
		
			
				|  |  | -                    imGroupMember.setRoleType(ImGroupMemberRoleType.TEACHER);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                    imGroupMemberService.join(Collections.singletonList(imGroupMember), oldGroup.getImGroupId());
 | 
	
		
			
				|  |  | -                } catch (Exception e) {
 | 
	
		
			
				|  |  | -                    log.error("负责人加入群失败", e);
 | 
	
		
			
				|  |  | -                    throw new BizException("负责人加入群失败");
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            ImGroup oldImGroup = imGroupService.getById(oldGroup.getImGroupId());
 | 
	
		
			
				|  |  | -            if (oldImGroup != null) {
 | 
	
		
			
				|  |  | -                try {
 | 
	
		
			
				|  |  | -                    imGroupCoreService.changeGroupOwner(oldGroup.getImGroupId(),
 | 
	
		
			
				|  |  | -                            String.valueOf(tenantGroup.getAdminId()),
 | 
	
		
			
				|  |  | -                            String.valueOf(oldGroup.getAdminId()));
 | 
	
		
			
				|  |  | -                    imGroupCoreService.groupQuit(oldGroup.getAdminId(), ClientEnum.TEACHER.getCode(),
 | 
	
		
			
				|  |  | -                            oldGroup.getImGroupId(), true);
 | 
	
		
			
				|  |  | -                } catch (Exception e) {
 | 
	
		
			
				|  |  | -                    log.error("更换群主失败", e);
 | 
	
		
			
				|  |  | -                    throw new BizException("更换群主失败");
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | +        entity.setImGroupId(oldGroup.getImGroupId());
 | 
	
		
			
				|  |  | +        // 是否建群
 | 
	
		
			
				|  |  | +        if (Boolean.TRUE.equals(imGroupCreate)) {
 | 
	
		
			
				|  |  | +            String oldImGroupId = Optional.ofNullable(oldGroup.getImGroupId()).orElse("-1");
 | 
	
		
			
				|  |  | +            ImGroup imGroup = imGroupService.getById(oldImGroupId);
 | 
	
		
			
				|  |  | +            // 群被删除过,并且需要重新建群
 | 
	
		
			
				|  |  | +            if (imGroup == null) {
 | 
	
		
			
				|  |  | +                SysUser sysUser = sysUserService.getByUserId(entity.getAdminId());
 | 
	
		
			
				|  |  | +                String imGroupId = createImGroup(entity.getAdminId(), sysUser.getUsername());
 | 
	
		
			
				|  |  | +                entity.setImGroupId(imGroupId);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        // 修改小组负责人,调整群主,更换群主需要新的群主为该群成员
 | 
	
		
			
				|  |  | +        changeGroupOwner(tenantGroup, oldGroup, entity);
 | 
	
		
			
				|  |  |          QueryWrapper<Student> queryWrapper = new QueryWrapper<>();
 | 
	
		
			
				|  |  |          queryWrapper.lambda()
 | 
	
		
			
				|  |  |                  .eq(Student::getTenantId, tenantGroup.getTenantId())
 | 
	
	
		
			
				|  | @@ -238,15 +217,19 @@ public class TenantGroupServiceImpl extends ServiceImpl<TenantGroupMapper, Tenan
 | 
	
		
			
				|  |  |          List<Long> removeGroupUsers = oldGroupUsers.stream()
 | 
	
		
			
				|  |  |                  .filter(next -> !newGroupUsers.contains(next)).collect(Collectors.toList());
 | 
	
		
			
				|  |  |          // 移除的群成员,退群
 | 
	
		
			
				|  |  | +        ImGroup imGroup = imGroupService.getById(Optional.ofNullable(entity.getImGroupId()).orElse("-1"));
 | 
	
		
			
				|  |  |          if (!removeGroupUsers.isEmpty()) {
 | 
	
		
			
				|  |  | -            try {
 | 
	
		
			
				|  |  | -                for (Long removeUserId : removeGroupUsers) {
 | 
	
		
			
				|  |  | -                    imGroupCoreService.groupQuit(removeUserId, ClientEnum.STUDENT.getCode(), oldGroup.getImGroupId(),
 | 
	
		
			
				|  |  | -                            true);
 | 
	
		
			
				|  |  | +            if (imGroup != null) {
 | 
	
		
			
				|  |  | +                try {
 | 
	
		
			
				|  |  | +                    for (Long removeUserId : removeGroupUsers) {
 | 
	
		
			
				|  |  | +                        imGroupCoreService.groupQuit(removeUserId, ClientEnum.STUDENT.getCode(),
 | 
	
		
			
				|  |  | +                                oldGroup.getImGroupId(),
 | 
	
		
			
				|  |  | +                                true);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                } catch (Exception e) {
 | 
	
		
			
				|  |  | +                    log.error("群成员移出群失败", e);
 | 
	
		
			
				|  |  | +                    throw new BizException("群成员移出群失败");
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | -            } catch (Exception e) {
 | 
	
		
			
				|  |  | -                log.error("群成员移出群失败", e);
 | 
	
		
			
				|  |  | -                throw new BizException("群成员移出群失败");
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              studentDao.update(null, Wrappers.<Student>lambdaUpdate()
 | 
	
		
			
				|  |  |                      .in(Student::getUserId, removeGroupUsers)
 | 
	
	
		
			
				|  | @@ -258,11 +241,13 @@ public class TenantGroupServiceImpl extends ServiceImpl<TenantGroupMapper, Tenan
 | 
	
		
			
				|  |  |                  .collect(Collectors.toList());
 | 
	
		
			
				|  |  |          if (!newAddGroupUsers.isEmpty()) {
 | 
	
		
			
				|  |  |              // 加群成员
 | 
	
		
			
				|  |  | -            try {
 | 
	
		
			
				|  |  | -                imGroupService.addGroupMember(oldGroup.getImGroupId(), new HashSet<>(newAddGroupUsers));
 | 
	
		
			
				|  |  | -            } catch (Exception e) {
 | 
	
		
			
				|  |  | -                log.error("加入机构小组群失败", e);
 | 
	
		
			
				|  |  | -                throw new BizException("加入机构小组群失败");
 | 
	
		
			
				|  |  | +            if (imGroup != null) {
 | 
	
		
			
				|  |  | +                try {
 | 
	
		
			
				|  |  | +                    imGroupService.addGroupMember(oldGroup.getImGroupId(), new HashSet<>(newAddGroupUsers));
 | 
	
		
			
				|  |  | +                } catch (Exception e) {
 | 
	
		
			
				|  |  | +                    log.error("加入机构小组群失败", e);
 | 
	
		
			
				|  |  | +                    throw new BizException("加入机构小组群失败");
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              studentDao.update(null, Wrappers.<Student>lambdaUpdate()
 | 
	
		
			
				|  |  |                      .in(Student::getUserId, newAddGroupUsers)
 | 
	
	
		
			
				|  | @@ -279,6 +264,11 @@ public class TenantGroupServiceImpl extends ServiceImpl<TenantGroupMapper, Tenan
 | 
	
		
			
				|  |  |          if (group == null) {
 | 
	
		
			
				|  |  |              throw new BizException("机构小组不存在");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        List<Student> students = this.queryStudent(group.getTenantId(), group.getId());
 | 
	
		
			
				|  |  | +        if (!students.isEmpty()) {
 | 
	
		
			
				|  |  | +            throw new BizException("小组内存在学生");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          String imGroupId = group.getImGroupId();
 | 
	
		
			
				|  |  |          if (imGroupId != null) {
 | 
	
		
			
				|  |  |              ImGroup imGroup = imGroupService.getById(imGroupId);
 | 
	
	
		
			
				|  | @@ -405,7 +395,7 @@ public class TenantGroupServiceImpl extends ServiceImpl<TenantGroupMapper, Tenan
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  this.lambdaUpdate()
 | 
	
		
			
				|  |  |                          .set(TenantGroup::getAdminId, toTeacher)
 | 
	
		
			
				|  |  | -                        .set(imGroup == null, TenantGroup::getImGroupId, "-1")
 | 
	
		
			
				|  |  | +                        .set(imGroup == null, TenantGroup::getImGroupId, null)
 | 
	
		
			
				|  |  |                          .eq(TenantGroup::getId, detail.getTenantGroupId())
 | 
	
		
			
				|  |  |                          .update();
 | 
	
		
			
				|  |  |              } else if (Boolean.TRUE.equals(detail.getDismiss())) {
 | 
	
	
		
			
				|  | @@ -418,9 +408,86 @@ public class TenantGroupServiceImpl extends ServiceImpl<TenantGroupMapper, Tenan
 | 
	
		
			
				|  |  |                          throw new BizException("解散群失败");
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | -                this.removeById(detail.getTenantGroupId());
 | 
	
		
			
				|  |  | +                this.lambdaUpdate()
 | 
	
		
			
				|  |  | +                        .set(TenantGroup::getAdminId, toTeacher)
 | 
	
		
			
				|  |  | +                        .set(TenantGroup::getImGroupId, null)
 | 
	
		
			
				|  |  | +                        .eq(TenantGroup::getId, detail.getTenantGroupId())
 | 
	
		
			
				|  |  | +                        .update();
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return true;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public String createImGroup(Long groupAdmin, String userName) {
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            ImGroupWrapper.ImGroup imGroup = new ImGroupWrapper.ImGroup();
 | 
	
		
			
				|  |  | +            imGroup.setId(IdWorker.getId());
 | 
	
		
			
				|  |  | +            imGroup.setCreateBy(groupAdmin);
 | 
	
		
			
				|  |  | +            imGroup.setType(ImGroupType.ORG.getCode());
 | 
	
		
			
				|  |  | +            imGroup.setName(userName);
 | 
	
		
			
				|  |  | +            return imGroupService.create(imGroup);
 | 
	
		
			
				|  |  | +        } catch (Exception e) {
 | 
	
		
			
				|  |  | +            log.error("创建机构小组群失败", e);
 | 
	
		
			
				|  |  | +            throw new BizException("创建机构小组群失败");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private void changeGroupOwner(TenantGroupWrapper.TenantGroup tenantGroup, TenantGroup oldGroup,
 | 
	
		
			
				|  |  | +                                  TenantGroup newGroup) {
 | 
	
		
			
				|  |  | +        if (newGroup.getAdminId() == null || newGroup.getAdminId().equals(oldGroup.getAdminId())) {
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        String imGroupId = Optional.ofNullable(newGroup.getImGroupId()).orElse("-1");
 | 
	
		
			
				|  |  | +        ImGroup imGroup = imGroupService.getById(imGroupId);
 | 
	
		
			
				|  |  | +        if (imGroup == null) {
 | 
	
		
			
				|  |  | +            // 群不存在
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        // 如果新负责人不在群,先加入群
 | 
	
		
			
				|  |  | +        ImGroupMember groupMember = imGroupMemberService.lambdaQuery()
 | 
	
		
			
				|  |  | +                .eq(ImGroupMember::getGroupId, oldGroup.getImGroupId())
 | 
	
		
			
				|  |  | +                .eq(ImGroupMember::getRoleType, ImGroupMemberRoleType.TEACHER)
 | 
	
		
			
				|  |  | +                .eq(ImGroupMember::getUserId, newGroup.getAdminId())
 | 
	
		
			
				|  |  | +                .eq(ImGroupMember::getIsAdmin, true)
 | 
	
		
			
				|  |  | +                .last("limit 1").one();
 | 
	
		
			
				|  |  | +        if (groupMember != null) {
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        // 新负责人加入群
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            SysUser newTeacher = sysUserService.getByUserId(newGroup.getAdminId());
 | 
	
		
			
				|  |  | +            ImGroupMember imGroupMember = new ImGroupMember();
 | 
	
		
			
				|  |  | +            imGroupMember.setGroupId(oldGroup.getImGroupId());
 | 
	
		
			
				|  |  | +            imGroupMember.setUserId(newGroup.getAdminId());
 | 
	
		
			
				|  |  | +            imGroupMember.setRoleType(ImGroupMemberRoleType.TEACHER);
 | 
	
		
			
				|  |  | +            imGroupMember.setAvatar(newTeacher.getAvatar());
 | 
	
		
			
				|  |  | +            imGroupMember.setNickname(newTeacher.getUsername());
 | 
	
		
			
				|  |  | +            imGroupMember.setIsAdmin(false);
 | 
	
		
			
				|  |  | +            imGroupMember.setRoleType(ImGroupMemberRoleType.TEACHER);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            imGroupMemberService.join(Collections.singletonList(imGroupMember), oldGroup.getImGroupId());
 | 
	
		
			
				|  |  | +        } catch (Exception e) {
 | 
	
		
			
				|  |  | +            log.error("负责人加入群失败", e);
 | 
	
		
			
				|  |  | +            throw new BizException("负责人加入群失败");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            imGroupCoreService.changeGroupOwner(oldGroup.getImGroupId(),
 | 
	
		
			
				|  |  | +                    String.valueOf(tenantGroup.getAdminId()),
 | 
	
		
			
				|  |  | +                    String.valueOf(oldGroup.getAdminId()));
 | 
	
		
			
				|  |  | +            imGroupCoreService.groupQuit(oldGroup.getAdminId(), ClientEnum.TEACHER.getCode(),
 | 
	
		
			
				|  |  | +                    oldGroup.getImGroupId(), true);
 | 
	
		
			
				|  |  | +        } catch (Exception e) {
 | 
	
		
			
				|  |  | +            log.error("更换群主失败", e);
 | 
	
		
			
				|  |  | +            throw new BizException("更换群主失败");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public List<Student> queryStudent(Long tenantId, Long tenantGroupId) {
 | 
	
		
			
				|  |  | +        QueryWrapper<Student> queryWrapper = new QueryWrapper<>();
 | 
	
		
			
				|  |  | +        queryWrapper.lambda()
 | 
	
		
			
				|  |  | +                .eq(Student::getTenantId, tenantId)
 | 
	
		
			
				|  |  | +                .eq(Student::getTenantGroupId, tenantGroupId);
 | 
	
		
			
				|  |  | +        return studentDao.selectList(queryWrapper);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 |