|
@@ -5,20 +5,28 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.dao.StudentDao;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.dao.SubjectDao;
|
|
import com.yonge.cooleshow.biz.dal.dao.TeacherDao;
|
|
import com.yonge.cooleshow.biz.dal.dao.TeacherDao;
|
|
import com.yonge.cooleshow.biz.dal.dao.UserBindingTeacherDao;
|
|
import com.yonge.cooleshow.biz.dal.dao.UserBindingTeacherDao;
|
|
import com.yonge.cooleshow.biz.dal.dto.search.QueryMyFollowSearch;
|
|
import com.yonge.cooleshow.biz.dal.dto.search.QueryMyFollowSearch;
|
|
import com.yonge.cooleshow.biz.dal.dto.search.StudentSearch;
|
|
import com.yonge.cooleshow.biz.dal.dto.search.StudentSearch;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.Student;
|
|
import com.yonge.cooleshow.biz.dal.entity.StudentTotal;
|
|
import com.yonge.cooleshow.biz.dal.entity.StudentTotal;
|
|
import com.yonge.cooleshow.biz.dal.entity.Subject;
|
|
import com.yonge.cooleshow.biz.dal.entity.Subject;
|
|
import com.yonge.cooleshow.biz.dal.entity.UserBindingTeacher;
|
|
import com.yonge.cooleshow.biz.dal.entity.UserBindingTeacher;
|
|
import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
|
|
import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.mapper.SysUserMapper;
|
|
import com.yonge.cooleshow.biz.dal.service.ImUserFriendService;
|
|
import com.yonge.cooleshow.biz.dal.service.ImUserFriendService;
|
|
-import com.yonge.cooleshow.biz.dal.service.TeacherService;
|
|
|
|
-import com.yonge.cooleshow.common.enums.CacheNameEnum;
|
|
|
|
|
|
+import com.yonge.cooleshow.biz.dal.service.StudentService;
|
|
import com.yonge.cooleshow.biz.dal.service.StudentTotalService;
|
|
import com.yonge.cooleshow.biz.dal.service.StudentTotalService;
|
|
-import com.yonge.cooleshow.biz.dal.vo.*;
|
|
|
|
|
|
+import com.yonge.cooleshow.biz.dal.vo.MyFollow;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.vo.StudentHomeVo;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.vo.StudentVo;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.vo.TeacherVo;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.wrapper.StudentWrapper;
|
|
import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
|
+import com.yonge.cooleshow.common.enums.CacheNameEnum;
|
|
import com.yonge.cooleshow.common.enums.UserLockFlag;
|
|
import com.yonge.cooleshow.common.enums.UserLockFlag;
|
|
import com.yonge.toolset.base.util.StringUtil;
|
|
import com.yonge.toolset.base.util.StringUtil;
|
|
import com.yonge.toolset.utils.date.DateUtil;
|
|
import com.yonge.toolset.utils.date.DateUtil;
|
|
@@ -28,13 +36,17 @@ import org.redisson.api.RedissonClient;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
-import com.yonge.cooleshow.biz.dal.entity.Student;
|
|
|
|
-import com.yonge.cooleshow.biz.dal.dao.StudentDao;
|
|
|
|
-import com.yonge.cooleshow.biz.dal.service.StudentService;
|
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.text.MessageFormat;
|
|
import java.text.MessageFormat;
|
|
-import java.util.*;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.HashSet;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.Objects;
|
|
|
|
+import java.util.Set;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
@@ -48,10 +60,12 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
|
|
private ImUserFriendService imUserFriendService;
|
|
private ImUserFriendService imUserFriendService;
|
|
@Resource
|
|
@Resource
|
|
private UserBindingTeacherDao userBindingTeacherDao;
|
|
private UserBindingTeacherDao userBindingTeacherDao;
|
|
- @Autowired
|
|
|
|
- private StudentService studentService;
|
|
|
|
@Resource
|
|
@Resource
|
|
private TeacherDao teacherDao;
|
|
private TeacherDao teacherDao;
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysUserMapper sysUserMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private SubjectDao subjectDao;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public StudentVo detail(Long userId) {
|
|
public StudentVo detail(Long userId) {
|
|
@@ -165,7 +179,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
|
|
}
|
|
}
|
|
resMap.put("old", old);
|
|
resMap.put("old", old);
|
|
|
|
|
|
- StudentVo studentVo = studentService.detailByPhone(phone);
|
|
|
|
|
|
+ StudentVo studentVo = detailByPhone(phone);
|
|
|
|
|
|
if (null == studentVo) {
|
|
if (null == studentVo) {
|
|
return HttpResponseResult.failed("未找到用户信息");
|
|
return HttpResponseResult.failed("未找到用户信息");
|
|
@@ -202,4 +216,112 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
|
|
return HttpResponseResult.succeed(resMap);
|
|
return HttpResponseResult.succeed(resMap);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 学生帐号关联
|
|
|
|
+ *
|
|
|
|
+ * @param info StudentWrapper.UnionStudent
|
|
|
|
+ * @return StudentWrapper.UnionStudentResp
|
|
|
|
+ */
|
|
|
|
+ @Transactional
|
|
|
|
+ @Override
|
|
|
|
+ public StudentWrapper.UnionStudentResp unionStudent(StudentWrapper.UnionStudent info) {
|
|
|
|
+
|
|
|
|
+ // 帐号关联响应数据
|
|
|
|
+ StudentWrapper.UnionStudentResp studentResp = StudentWrapper.UnionStudentResp
|
|
|
|
+ .builder()
|
|
|
|
+ .unionId(info.getUnionId())
|
|
|
|
+ .mobile(info.getMobile())
|
|
|
|
+ .updateFlag(false)
|
|
|
|
+ .build();
|
|
|
|
+
|
|
|
|
+ // 手机号查询用户信息
|
|
|
|
+ StudentVo studentVo = detailByPhone(info.getMobile());
|
|
|
|
+ if (Objects.isNull(studentVo)) {
|
|
|
|
+
|
|
|
|
+ com.yonge.cooleshow.biz.dal.entity.SysUser sysUser = sysUserMapper.selectOne(Wrappers.<com.yonge.cooleshow.biz.dal.entity.SysUser>lambdaQuery()
|
|
|
|
+ .eq(com.yonge.cooleshow.biz.dal.entity.SysUser::getPhone, info.getMobile()));
|
|
|
|
+
|
|
|
|
+ if (Objects.isNull(sysUser)) {
|
|
|
|
+
|
|
|
|
+ // 自动注册创建用户
|
|
|
|
+ com.yonge.cooleshow.biz.dal.entity.SysUser user = new com.yonge.cooleshow.biz.dal.entity.SysUser();
|
|
|
|
+ user.setUsername(info.getUsername());
|
|
|
|
+ user.setPhone(info.getMobile());
|
|
|
|
+ user.setLockFlag(0);
|
|
|
|
+ user.setGender(info.getGender());
|
|
|
|
+ sysUserMapper.insert(user);
|
|
|
|
+
|
|
|
|
+ String subjectId = null;
|
|
|
|
+ // 学生声部
|
|
|
|
+ Subject subject = subjectDao.getSubjectMatchByName(info.getSubjectName());
|
|
|
|
+ if (Objects.nonNull(subject)) {
|
|
|
|
+ subjectId = String.valueOf(subject.getId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 添加学生帐号
|
|
|
|
+ Student student = new Student();
|
|
|
|
+ student.setUserId(user.getId());
|
|
|
|
+ student.setSubjectId(subjectId);
|
|
|
|
+ student.setUnionId(info.getUnionId());
|
|
|
|
+ save(student);
|
|
|
|
+
|
|
|
|
+ // 更新标识
|
|
|
|
+ studentResp.setUpdateFlag(true);
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ com.yonge.cooleshow.biz.dal.entity.SysUser updateEntity = new com.yonge.cooleshow.biz.dal.entity.SysUser();
|
|
|
|
+ updateEntity.setId(sysUser.getId());
|
|
|
|
+ updateEntity.setDelFlag(0); // 激活帐号
|
|
|
|
+ // 激活帐号
|
|
|
|
+ sysUserMapper.updateById(updateEntity);
|
|
|
|
+
|
|
|
|
+ studentResp.username(sysUser.getUsername()).userId(sysUser.getId());
|
|
|
|
+
|
|
|
|
+ Student student = lambdaQuery().eq(Student::getUserId, sysUser.getId()).one();
|
|
|
|
+
|
|
|
|
+ // 更新学生关联帐号
|
|
|
|
+ updateStudentUnionStatus(info, studentResp, student);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ studentResp.username(studentVo.getUsername()).userId(studentVo.getUserId());
|
|
|
|
+
|
|
|
|
+ Student student = lambdaQuery().eq(Student::getUserId, studentVo.getUserId()).one();
|
|
|
|
+
|
|
|
|
+ // 更新学生关联帐号
|
|
|
|
+ updateStudentUnionStatus(info, studentResp, student);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return studentResp;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 更新学生关联帐号
|
|
|
|
+ * @param info StudentWrapper.UnionStudent
|
|
|
|
+ * @param studentResp StudentWrapper.UnionStudentResp
|
|
|
|
+ * @param student Student
|
|
|
|
+ */
|
|
|
|
+ private void updateStudentUnionStatus(StudentWrapper.UnionStudent info,
|
|
|
|
+ StudentWrapper.UnionStudentResp studentResp, Student student) {
|
|
|
|
+
|
|
|
|
+ if (Objects.nonNull(student)) {
|
|
|
|
+
|
|
|
|
+ if (Objects.isNull(student.getUnionId())) {
|
|
|
|
+
|
|
|
|
+ // 更新学生关联Id
|
|
|
|
+ lambdaUpdate()
|
|
|
|
+ .eq(Student::getUserId, student.getUserId())
|
|
|
|
+ .set(Student::getUnionId, info.getUnionId())
|
|
|
|
+ .update();
|
|
|
|
+ } else {
|
|
|
|
+ studentResp.setUnionId(student.getUnionId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 更新标识
|
|
|
|
+ studentResp.setUpdateFlag(true);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|