|
@@ -1,10 +1,28 @@
|
|
|
package com.ym.mec.education.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+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.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 org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -17,4 +35,50 @@ import org.springframework.stereotype.Service;
|
|
|
@Service("ITeacherService")
|
|
|
public class TeacherServiceImpl extends ServiceImpl<TeacherMapper, Teacher> implements ITeacherService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService sysUserService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISubjectService subjectService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageResponse teacherList(TeacherReq req) {
|
|
|
+ PageResponse response = new PageResponse();
|
|
|
+ QueryWrapper<SysUser> userQueryWrapper = new QueryWrapper<>();
|
|
|
+ List<SysUser> userList = null;
|
|
|
+ if(req != null && StringUtils.isEmpty(req.getName())){
|
|
|
+ userQueryWrapper.like("real_name_",req.getName());
|
|
|
+ userList = sysUserService.list(userQueryWrapper);
|
|
|
+ }
|
|
|
+ QueryWrapper<Teacher> queryWrapper = new QueryWrapper<>();
|
|
|
+ List<Integer> userIds = null;
|
|
|
+ if(!CollectionUtils.isEmpty(userList)){
|
|
|
+ userIds = userList.stream().map(SysUser::getId).collect(Collectors.toList());
|
|
|
+ queryWrapper.in("id_",userIds);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|