|  | @@ -25,6 +25,7 @@ import com.yonge.cooleshow.biz.dal.mapper.SysUserMapper;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumMapper;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumRefMapper;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.mapper.TenantGroupMapper;
 | 
	
		
			
				|  |  | +import com.yonge.cooleshow.biz.dal.mapper.UserTenantBindRecordMapper;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.service.*;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.service.im.ImGroupCoreService;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.vo.MyFollow;
 | 
	
	
		
			
				|  | @@ -125,6 +126,8 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private TenantGroupMapper tenantGroupMapper;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private UserTenantBindRecordMapper userTenantBindRecordMapper;
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public StudentVo detail(Long userId) {
 | 
	
		
			
				|  |  |          return baseMapper.detail(userId);
 | 
	
	
		
			
				|  | @@ -582,6 +585,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
 | 
	
		
			
				|  |  |  //             删除好友
 | 
	
		
			
				|  |  |              imUserFriendService.delTeacherFriendByTenantId(student.getTenantId(), student.getUserId(),
 | 
	
		
			
				|  |  |                      ClientEnum.STUDENT.getCode());
 | 
	
		
			
				|  |  | +            addBindUnBindRecord(student.getUserId(),student.getTenantId(),false);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if (toTenantId != null && toTenantId != -1L) {
 | 
	
		
			
				|  |  |              // 加好友
 | 
	
	
		
			
				|  | @@ -593,6 +597,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
 | 
	
		
			
				|  |  |                  studentIds.add(student.getUserId());
 | 
	
		
			
				|  |  |                  imUserFriendService.saveUserFriend(teacher.getUserId(), studentIds);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | +            addBindUnBindRecord(student.getUserId(),student.getTenantId(),true);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          this.lambdaUpdate().set(Student::getTenantId, toTenantId)
 | 
	
		
			
				|  |  |                  .set(Student::getTenantGroupId, -1L)
 | 
	
	
		
			
				|  | @@ -672,6 +677,8 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
 | 
	
		
			
				|  |  |              imUserFriendService.delTeacherFriendByTenantId(student.getTenantId(), student.getUserId(),
 | 
	
		
			
				|  |  |                      ClientEnum.STUDENT.getCode());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +            addBindUnBindRecord(student.getUserId(),student.getTenantId(),false);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              // 加好友
 | 
	
		
			
				|  |  |              QueryWrapper<Teacher> query = new QueryWrapper<>();
 | 
	
		
			
				|  |  |              query.lambda().eq(Teacher::getTenantId, newTenantId);
 | 
	
	
		
			
				|  | @@ -682,6 +689,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
 | 
	
		
			
				|  |  |                  imUserFriendService.saveUserFriend(teacher.getUserId(), studentIds);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +            addBindUnBindRecord(student.getUserId(),studentInfo.getTenantId(),true);
 | 
	
		
			
				|  |  |              sendStudentTenantChange(student,newTenantId);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -837,6 +845,8 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
 | 
	
		
			
				|  |  |              List<Teacher> teacherList = teacherDao.selectList(queryWrapper);
 | 
	
		
			
				|  |  |              teacherList.forEach(next -> imUserFriendService.saveUserFriend(next.getUserId(),
 | 
	
		
			
				|  |  |                      new HashSet<>(ImmutableList.of(sysUser.getId()))));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            addBindUnBindRecord(student.getUserId(), student.getTenantId(), true);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          //  与随机一个客服建立好友
 | 
	
	
		
			
				|  | @@ -938,4 +948,14 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    private void addBindUnBindRecord(Long studentId, Long tenantId, Boolean bind) {
 | 
	
		
			
				|  |  | +        UserTenantBindRecord bindRecord = new UserTenantBindRecord();
 | 
	
		
			
				|  |  | +        bindRecord.setUserId(studentId);
 | 
	
		
			
				|  |  | +        bindRecord.setUserType("STUDENT");
 | 
	
		
			
				|  |  | +        bindRecord.setTenantId(tenantId);
 | 
	
		
			
				|  |  | +        bindRecord.setBindStatus(bind);
 | 
	
		
			
				|  |  | +        bindRecord.setBindTime(new Date());
 | 
	
		
			
				|  |  | +        userTenantBindRecordMapper.add(bindRecord);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  }
 |