|
@@ -5,15 +5,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.ym.mec.education.base.PageResponse;
|
|
|
-import com.ym.mec.education.entity.Subject;
|
|
|
-import com.ym.mec.education.entity.SysUser;
|
|
|
-import com.ym.mec.education.entity.Teacher;
|
|
|
+import com.ym.mec.education.entity.*;
|
|
|
+import com.ym.mec.education.enums.ReturnCodeEnum;
|
|
|
import com.ym.mec.education.mapper.TeacherMapper;
|
|
|
import com.ym.mec.education.req.TeacherReq;
|
|
|
import com.ym.mec.education.resp.TeacherResp;
|
|
|
-import com.ym.mec.education.service.ISubjectService;
|
|
|
-import com.ym.mec.education.service.ISysUserService;
|
|
|
-import com.ym.mec.education.service.ITeacherService;
|
|
|
+import com.ym.mec.education.service.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
@@ -41,6 +38,11 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherMapper, Teacher> impl
|
|
|
@Autowired
|
|
|
private ISubjectService subjectService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IClassGroupService classGroupService;
|
|
|
+ @Autowired
|
|
|
+ private IClassGroupTeacherMapperService classGroupTeacherMapperService;
|
|
|
+
|
|
|
@Override
|
|
|
public PageResponse teacherList(TeacherReq req) {
|
|
|
PageResponse response = new PageResponse();
|
|
@@ -73,12 +75,36 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherMapper, Teacher> impl
|
|
|
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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ teacherRespList.add(teacherResp);
|
|
|
});
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+ response.setReturnCode(ReturnCodeEnum.CODE_200.getCode());
|
|
|
+ response.setMessage(ReturnCodeEnum.CODE_200.getValue());
|
|
|
+ response.setRecords(teacherRespList);
|
|
|
+ response.setTotal(Math.toIntExact(teacherIPage.getTotal()));
|
|
|
return null;
|
|
|
}
|
|
|
}
|