|
@@ -1,8 +1,21 @@
|
|
|
package com.yonge.cooleshow.biz.dal.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
|
|
|
+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.entity.Student;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.Subject;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.Teacher;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.StudentService;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.TeacherService;
|
|
|
+import com.yonge.toolset.base.exception.BizException;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -11,6 +24,10 @@ import com.yonge.cooleshow.biz.dal.wrapper.TenantUnbindRecordWrapper;
|
|
|
import com.yonge.cooleshow.biz.dal.mapper.TenantUnbindRecordMapper;
|
|
|
import com.yonge.cooleshow.biz.dal.service.TenantUnbindRecordService;
|
|
|
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
+
|
|
|
/**
|
|
|
* 机构解绑申请记录
|
|
|
* 2023-07-21 17:32:49
|
|
@@ -19,6 +36,28 @@ import com.yonge.cooleshow.biz.dal.service.TenantUnbindRecordService;
|
|
|
@Service
|
|
|
public class TenantUnbindRecordServiceImpl extends ServiceImpl<TenantUnbindRecordMapper, TenantUnbindRecord> implements TenantUnbindRecordService {
|
|
|
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TeacherDao teacherDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private StudentDao studentDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SubjectDao subjectDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TenantUnbindRecordService tenantUnbindRecordService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysUserFeignService sysUserFeignService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private StudentService studentService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TeacherService teacherService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询详情
|
|
|
* @param id 详情ID
|
|
@@ -38,8 +77,83 @@ public class TenantUnbindRecordServiceImpl extends ServiceImpl<TenantUnbindRecor
|
|
|
*/
|
|
|
@Override
|
|
|
public IPage<TenantUnbindRecordWrapper.TenantUnbindRecord> selectPage(IPage<TenantUnbindRecordWrapper.TenantUnbindRecord> page, TenantUnbindRecordWrapper.TenantUnbindRecordQuery query) {
|
|
|
-
|
|
|
- return page.setRecords(baseMapper.selectPage(page, query));
|
|
|
+
|
|
|
+ List<TenantUnbindRecordWrapper.TenantUnbindRecord> records = baseMapper.selectPage(page, query);
|
|
|
+ if(records.isEmpty()){
|
|
|
+ return page.setRecords(records);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, List<TenantUnbindRecordWrapper.TenantUnbindRecord>> gropuByUserType = records.stream().collect(Collectors.groupingBy(TenantUnbindRecordWrapper.TenantUnbindRecord::getUserType));
|
|
|
+
|
|
|
+ List<Long> teacherIds = new ArrayList<>();
|
|
|
+ List<Long> studentIds = new ArrayList<>();
|
|
|
+
|
|
|
+ for (Map.Entry<String, List<TenantUnbindRecordWrapper.TenantUnbindRecord>> entry : gropuByUserType.entrySet()) {
|
|
|
+ if("TEACHER".equals(entry.getKey())){
|
|
|
+ teacherIds.addAll(entry.getValue().stream().map(TenantUnbindRecordWrapper.TenantUnbindRecord::getUserId).collect(Collectors.toList()));
|
|
|
+ }else{
|
|
|
+ studentIds.addAll(entry.getValue().stream().map(TenantUnbindRecordWrapper.TenantUnbindRecord::getUserId).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ List<Teacher> teachers = new ArrayList<>();
|
|
|
+ List<Teacher> students = new ArrayList<>();
|
|
|
+ List<Teacher> users = new ArrayList<>();
|
|
|
+ if(!teacherIds.isEmpty()){
|
|
|
+ QueryWrapper<Teacher>
|
|
|
+ objectQueryWrapper = new QueryWrapper<>();
|
|
|
+ objectQueryWrapper.lambda()
|
|
|
+ .in(Teacher::getUserId,teacherIds);
|
|
|
+ teachers = teacherDao.selectList(objectQueryWrapper);
|
|
|
+ }else {
|
|
|
+ QueryWrapper<Student>
|
|
|
+ objectQueryWrapper = new QueryWrapper<>();
|
|
|
+ objectQueryWrapper.lambda()
|
|
|
+ .in(Student::getUserId,studentIds);
|
|
|
+ List<Student> studentList = studentDao.selectList(objectQueryWrapper);
|
|
|
+ students =studentList.stream().map(next->{
|
|
|
+ Teacher teacher = new Teacher();
|
|
|
+ teacher.setUserId(next.getUserId());
|
|
|
+ teacher.setSubject(next.getSubjectId());
|
|
|
+ return teacher;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ users.addAll(students);
|
|
|
+ users.addAll(teachers);
|
|
|
+
|
|
|
+ List<Long> subjectIdList = users.stream().map(next -> {
|
|
|
+ List<Long > list = new ArrayList<>();
|
|
|
+ String subjectId = next.getSubjectId();
|
|
|
+ if (StringUtils.isEmpty(subjectId)) {
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+ return Arrays.stream(next.getSubjectId().split(",")).map(Long::valueOf).collect(Collectors.toList());
|
|
|
+ }).flatMap(Collection::stream).collect(Collectors.toList());
|
|
|
+
|
|
|
+ Map<Long,String> userIdSubjectNameMap = new HashMap<>();
|
|
|
+ if(!subjectIdList.isEmpty()){
|
|
|
+ List<Subject> subjectList = subjectDao.findBySubjectIds(subjectIdList);
|
|
|
+ Map<Long, String> idNameMap = subjectList.stream().collect(Collectors.toMap(Subject::getId, Subject::getName));
|
|
|
+
|
|
|
+ for (Teacher user : users) {
|
|
|
+ String subjectId = user.getSubjectId();
|
|
|
+ if(StringUtils.isEmpty(subjectId)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<String> names = Arrays.stream(subjectId.split(",")).map(next ->
|
|
|
+ idNameMap.getOrDefault(Long.valueOf(next), "")).collect(Collectors.toList());
|
|
|
+ userIdSubjectNameMap.put(user.getUserId(),String.join(",",names));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (TenantUnbindRecordWrapper.TenantUnbindRecord record : records) {
|
|
|
+ record.setSubjectName(userIdSubjectNameMap.getOrDefault(record.getUserId(),""));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return page.setRecords(records);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -63,4 +177,32 @@ public class TenantUnbindRecordServiceImpl extends ServiceImpl<TenantUnbindRecor
|
|
|
|
|
|
return this.updateById(JSON.parseObject(tenantUnbindRecord.jsonString(), TenantUnbindRecord.class));
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean entry(TenantUnbindRecordWrapper.Audio audio) {
|
|
|
+ boolean update = tenantUnbindRecordService.lambdaUpdate()
|
|
|
+ .set(TenantUnbindRecord::getStatus, audio.getStatus() ? "PASS" : "UNPASS")
|
|
|
+ .set(TenantUnbindRecord::getReason, audio.getReason())
|
|
|
+ .set(TenantUnbindRecord::getVerifyUserId, sysUserFeignService.queryUserInfo().getId())
|
|
|
+ .eq(TenantUnbindRecord::getId, audio.getId())
|
|
|
+ .eq(TenantUnbindRecord::getStatus, "DOING").update();
|
|
|
+ if (!update) {
|
|
|
+ throw new BizException("审核失败,请刷新后重试");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (audio.getStatus()) {
|
|
|
+ TenantUnbindRecord unbindRecord = tenantUnbindRecordService.getById(audio.getId());
|
|
|
+ String userType = unbindRecord.getUserType();
|
|
|
+ if ("STUDENT".equals(userType)) {
|
|
|
+ studentService.lambdaUpdate()
|
|
|
+ .set(Student::getTenantId, -1L)
|
|
|
+ .eq(Student::getUserId, unbindRecord.getUserId()).update();
|
|
|
+ } else if ("TEACHER".equals(userType)) {
|
|
|
+ teacherService.lambdaUpdate()
|
|
|
+ .set(Teacher::getTenantId, -1L)
|
|
|
+ .eq(Teacher::getUserId, unbindRecord.getUserId()).update();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|