|
@@ -17,11 +17,11 @@ import com.ym.mec.education.resp.TeacherResp;
|
|
import com.ym.mec.education.resp.VipGroupClassResp;
|
|
import com.ym.mec.education.resp.VipGroupClassResp;
|
|
import com.ym.mec.education.service.*;
|
|
import com.ym.mec.education.service.*;
|
|
import com.ym.mec.education.utils.DateUtil;
|
|
import com.ym.mec.education.utils.DateUtil;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
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 org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
-import org.springframework.util.StringUtils;
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -82,7 +82,6 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherMapper, Teacher> impl
|
|
public PageResponse teacherList(TeacherReq req) {
|
|
public PageResponse teacherList(TeacherReq req) {
|
|
PageResponse response = new PageResponse();
|
|
PageResponse response = new PageResponse();
|
|
QueryWrapper<SysUser> userQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<SysUser> userQueryWrapper = new QueryWrapper<>();
|
|
- List<SysUser> userList = null;
|
|
|
|
if (Objects.isNull(req.getUserId())) {
|
|
if (Objects.isNull(req.getUserId())) {
|
|
return PageResponse.errorParam();
|
|
return PageResponse.errorParam();
|
|
}
|
|
}
|
|
@@ -90,60 +89,57 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherMapper, Teacher> impl
|
|
if (Objects.isNull(teacher)) {
|
|
if (Objects.isNull(teacher)) {
|
|
return PageResponse.noDataExists();
|
|
return PageResponse.noDataExists();
|
|
}
|
|
}
|
|
- if (req != null && StringUtils.isEmpty(req.getName())) {
|
|
|
|
|
|
+ if (req != null && StringUtils.isNotBlank(req.getName())) {
|
|
userQueryWrapper.like("real_name_", req.getName());
|
|
userQueryWrapper.like("real_name_", req.getName());
|
|
- userList = sysUserService.list(userQueryWrapper);
|
|
|
|
}
|
|
}
|
|
|
|
+ List<SysUser> userList = sysUserService.list(userQueryWrapper);
|
|
QueryWrapper<Teacher> queryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<Teacher> queryWrapper = new QueryWrapper<>();
|
|
- List<Integer> userIds = null;
|
|
|
|
|
|
+ List<TeacherResp> teacherRespList = new ArrayList<>();
|
|
|
|
+ List<Integer> userIds;
|
|
|
|
+ IPage<Teacher> teacherIPage = new Page<>();
|
|
if (!CollectionUtils.isEmpty(userList)) {
|
|
if (!CollectionUtils.isEmpty(userList)) {
|
|
userIds = userList.stream().map(SysUser::getId).collect(Collectors.toList());
|
|
userIds = userList.stream().map(SysUser::getId).collect(Collectors.toList());
|
|
queryWrapper.in("id_", userIds);
|
|
queryWrapper.in("id_", userIds);
|
|
- }
|
|
|
|
- Optional.ofNullable(teacher.getOrganId()).ifPresent(organId ->
|
|
|
|
- queryWrapper.lambda().eq(Teacher::getOrganId, organId));
|
|
|
|
-
|
|
|
|
- IPage<Teacher> page = new Page(req.getPageNo() == null ? 1 : req.getPageNo(), req.getPageSize() == null ? 10 : req.getPageSize());
|
|
|
|
- IPage<Teacher> teacherIPage = this.page(page, queryWrapper);
|
|
|
|
-
|
|
|
|
- List<Teacher> teacherList = teacherIPage.getRecords();
|
|
|
|
- List<TeacherResp> teacherRespList = new ArrayList<>();
|
|
|
|
- if (!CollectionUtils.isEmpty(teacherList)) {
|
|
|
|
- teacherList.forEach(e -> {
|
|
|
|
- TeacherResp teacherResp = new TeacherResp();
|
|
|
|
- String ids[] = e.getSubjectId().split(",");
|
|
|
|
- List<String> stringB = Arrays.asList(ids);
|
|
|
|
- QueryWrapper<Subject> queryWrapperSub = new QueryWrapper<>();
|
|
|
|
- queryWrapperSub.in("id_", stringB);
|
|
|
|
- List<Subject> subjectList = subjectService.list(queryWrapperSub);
|
|
|
|
- if (!CollectionUtils.isEmpty(subjectList)) {
|
|
|
|
- List<String> subName = subjectList.stream().map(Subject::getName).collect(Collectors.toList());
|
|
|
|
- teacherResp.setSubjectName(subName);
|
|
|
|
- }
|
|
|
|
- teacherResp.setUserId(e.getId());
|
|
|
|
- SysUser sysUser = sysUserService.getById(e.getId());
|
|
|
|
- if (sysUser != null) {
|
|
|
|
- teacherResp.setAvatar(sysUser.getAvatar());
|
|
|
|
- teacherResp.setName(sysUser.getRealName());
|
|
|
|
- }
|
|
|
|
- QueryWrapper<ClassGroupTeacherMapper> queryWrapper1 = new QueryWrapper<>();
|
|
|
|
- queryWrapper1.eq("user_id_", e.getId());
|
|
|
|
- List<ClassGroupTeacherMapper> classGroupTeacherMappers = classGroupTeacherMapperService.list(queryWrapper1);
|
|
|
|
- if (!CollectionUtils.isEmpty(classGroupTeacherMappers)) {
|
|
|
|
- List<Integer> classId = classGroupTeacherMappers.stream().map(ClassGroupTeacherMapper::getClassGroupId).collect(Collectors.toList());
|
|
|
|
- QueryWrapper<ClassGroup> groupQueryWrapper = new QueryWrapper<>();
|
|
|
|
- groupQueryWrapper.eq("id_", classId);
|
|
|
|
- List<ClassGroup> classGroups = classGroupService.list(groupQueryWrapper);
|
|
|
|
- if (!CollectionUtils.isEmpty(classGroups)) {
|
|
|
|
- List<String> className = classGroups.stream().map(ClassGroup::getName).collect(Collectors.toList());
|
|
|
|
-
|
|
|
|
- teacherResp.setClassName(className);
|
|
|
|
|
|
+ Optional.ofNullable(teacher.getOrganId()).ifPresent(organId ->
|
|
|
|
+ queryWrapper.lambda().eq(Teacher::getOrganId, organId));
|
|
|
|
+ IPage<Teacher> page = new Page(req.getPageNo() == null ? 1 : req.getPageNo(), req.getPageSize() == null ? 10 : req.getPageSize());
|
|
|
|
+ teacherIPage = this.page(page, queryWrapper);
|
|
|
|
+ List<Teacher> teacherList = teacherIPage.getRecords();
|
|
|
|
+ if (!CollectionUtils.isEmpty(teacherList)) {
|
|
|
|
+ teacherList.forEach(e -> {
|
|
|
|
+ TeacherResp teacherResp = new TeacherResp();
|
|
|
|
+ String ids[] = e.getSubjectId().split(",");
|
|
|
|
+ List<String> stringB = Arrays.asList(ids);
|
|
|
|
+ QueryWrapper<Subject> queryWrapperSub = new QueryWrapper<>();
|
|
|
|
+ queryWrapperSub.in("id_", stringB);
|
|
|
|
+ List<Subject> subjectList = subjectService.list(queryWrapperSub);
|
|
|
|
+ if (!CollectionUtils.isEmpty(subjectList)) {
|
|
|
|
+ List<String> subName = subjectList.stream().map(Subject::getName).collect(Collectors.toList());
|
|
|
|
+ teacherResp.setSubjectName(subName);
|
|
}
|
|
}
|
|
- }
|
|
|
|
-
|
|
|
|
- teacherRespList.add(teacherResp);
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
|
|
+ teacherResp.setUserId(e.getId());
|
|
|
|
+ SysUser sysUser = sysUserService.getById(e.getId());
|
|
|
|
+ if (sysUser != null) {
|
|
|
|
+ teacherResp.setAvatar(sysUser.getAvatar());
|
|
|
|
+ teacherResp.setName(sysUser.getRealName());
|
|
|
|
+ }
|
|
|
|
+ QueryWrapper<ClassGroupTeacherMapper> queryWrapper1 = new QueryWrapper<>();
|
|
|
|
+ queryWrapper1.eq("user_id_", e.getId());
|
|
|
|
+ List<ClassGroupTeacherMapper> classGroupTeacherMappers = classGroupTeacherMapperService.list(queryWrapper1);
|
|
|
|
+ if (!CollectionUtils.isEmpty(classGroupTeacherMappers)) {
|
|
|
|
+ List<Integer> classId = classGroupTeacherMappers.stream().map(ClassGroupTeacherMapper::getClassGroupId).collect(Collectors.toList());
|
|
|
|
+ QueryWrapper<ClassGroup> groupQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ groupQueryWrapper.eq("id_", classId);
|
|
|
|
+ List<ClassGroup> classGroups = classGroupService.list(groupQueryWrapper);
|
|
|
|
+ if (!CollectionUtils.isEmpty(classGroups)) {
|
|
|
|
+ List<String> className = classGroups.stream().map(ClassGroup::getName).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ teacherResp.setClassName(className);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ teacherRespList.add(teacherResp);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
response.setReturnCode(ReturnCodeEnum.CODE_200.getCode());
|
|
response.setReturnCode(ReturnCodeEnum.CODE_200.getCode());
|
|
response.setMessage(ReturnCodeEnum.CODE_200.getValue());
|
|
response.setMessage(ReturnCodeEnum.CODE_200.getValue());
|