|  | @@ -1,15 +1,19 @@
 | 
	
		
			
				|  |  |  package com.yonge.cooleshow.biz.dal.service.impl;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.metadata.IPage;
 | 
	
		
			
				|  |  | +import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.auth.api.entity.SysUser;
 | 
	
		
			
				|  |  | +import com.yonge.cooleshow.biz.dal.dao.TeacherDao;
 | 
	
		
			
				|  |  | +import com.yonge.cooleshow.biz.dal.dao.UserBindingTeacherDao;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.dto.search.StudentSearch;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.entity.StudentTotal;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.entity.Subject;
 | 
	
		
			
				|  |  | +import com.yonge.cooleshow.biz.dal.entity.UserBindingTeacher;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.enums.CacheNameEnum;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.service.StudentTotalService;
 | 
	
		
			
				|  |  | -import com.yonge.cooleshow.biz.dal.support.WrapperUtil;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.vo.*;
 | 
	
		
			
				|  |  | +import com.yonge.cooleshow.common.entity.HttpResponseResult;
 | 
	
		
			
				|  |  |  import com.yonge.toolset.utils.date.DateUtil;
 | 
	
		
			
				|  |  |  import com.yonge.toolset.utils.string.ValueUtil;
 | 
	
		
			
				|  |  |  import org.apache.commons.beanutils.BeanUtils;
 | 
	
	
		
			
				|  | @@ -28,9 +32,14 @@ import java.util.concurrent.TimeUnit;
 | 
	
		
			
				|  |  |  public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> implements StudentService {
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private RedissonClient redissonClient;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private StudentTotalService totalService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private UserBindingTeacherDao userBindingTeacherDao;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private StudentService studentService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private TeacherDao teacherDao;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public StudentVo detail(Long userId) {
 | 
	
	
		
			
				|  | @@ -38,6 +47,11 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | +    public StudentVo detailByPhone(String phone) {
 | 
	
		
			
				|  |  | +        return baseMapper.detailByPhone(phone);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  |      public IPage<StudentVo> selectPage(IPage<StudentVo> page, StudentSearch studentSearch) {
 | 
	
		
			
				|  |  |          return page.setRecords(baseMapper.selectPage(page, studentSearch));
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -95,4 +109,44 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
 | 
	
		
			
				|  |  |          return page.setRecords(teacherVos);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public HttpResponseResult<Map<String, TeacherVo>> bindTeacher(String phone, Long userId, Boolean isUpdate) {
 | 
	
		
			
				|  |  | +        Map<String, TeacherVo> resMap = new HashMap<>();
 | 
	
		
			
				|  |  | +        TeacherVo old = userBindingTeacherDao.getBindTeacherByPhone(phone);
 | 
	
		
			
				|  |  | +        if (null != old) {
 | 
	
		
			
				|  |  | +            //身份证号、手机号脱敏
 | 
	
		
			
				|  |  | +            old.setIdCardNo(ValueUtil.fuzzyIdCard(old.getIdCardNo()));
 | 
	
		
			
				|  |  | +            old.setPhone(ValueUtil.fuzzyMobile(old.getPhone()));
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        resMap.put("old", old);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        StudentVo studentVo = studentService.detailByPhone(phone);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (null == studentVo) {
 | 
	
		
			
				|  |  | +            return HttpResponseResult.failed("未找到用户信息");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        TeacherVo detail = teacherDao.detail(userId);
 | 
	
		
			
				|  |  | +        if (null != detail) {
 | 
	
		
			
				|  |  | +            //身份证号、手机号脱敏
 | 
	
		
			
				|  |  | +            detail.setIdCardNo(ValueUtil.fuzzyIdCard(detail.getIdCardNo()));
 | 
	
		
			
				|  |  | +            detail.setPhone(ValueUtil.fuzzyMobile(detail.getPhone()));
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (null == detail) {
 | 
	
		
			
				|  |  | +            return HttpResponseResult.failed("未找老师信息");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (null == old || (null != isUpdate && isUpdate)) {
 | 
	
		
			
				|  |  | +            //更新
 | 
	
		
			
				|  |  | +            //删除用户绑定
 | 
	
		
			
				|  |  | +            userBindingTeacherDao.delete(Wrappers.<UserBindingTeacher>lambdaQuery()
 | 
	
		
			
				|  |  | +                    .eq(UserBindingTeacher::getStudentId, studentVo.getUserId()));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            UserBindingTeacher userBindingTeacher = new UserBindingTeacher();
 | 
	
		
			
				|  |  | +            userBindingTeacher.setTeacherId(userId);
 | 
	
		
			
				|  |  | +            userBindingTeacher.setStudentId(studentVo.getUserId());
 | 
	
		
			
				|  |  | +            userBindingTeacherDao.insert(userBindingTeacher);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        resMap.put("now", detail);
 | 
	
		
			
				|  |  | +        return HttpResponseResult.succeed(resMap);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  }
 |