瀏覽代碼

修改根据当前登录老师查询学员列表入参

肖玮 5 年之前
父節點
當前提交
b815458f57

+ 3 - 2
mec-education/src/main/java/com/ym/mec/education/controller/StudentController.java

@@ -2,6 +2,7 @@ package com.ym.mec.education.controller;
 
 import com.ym.mec.education.base.PageResponse;
 import com.ym.mec.education.req.ClassGroupReq;
+import com.ym.mec.education.req.StudentReq;
 import com.ym.mec.education.req.TeacherReq;
 import com.ym.mec.education.service.IClassGroupStudentMapperService;
 import io.swagger.annotations.Api;
@@ -36,8 +37,8 @@ public class StudentController {
 
     @PostMapping("/listByTeacher")
     @ApiOperation("根据当前登录人查询对应学员名单列表")
-    public PageResponse listByTeacher(@RequestBody TeacherReq teacherReq) {
-        return groupStudentMapperService.getPageByTeacher(teacherReq);
+    public PageResponse listByTeacher(@RequestBody StudentReq studentReq) {
+        return groupStudentMapperService.getPageByTeacher(studentReq);
     }
 
 }

+ 2 - 1
mec-education/src/main/java/com/ym/mec/education/service/IClassGroupStudentMapperService.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.ym.mec.education.base.PageResponse;
 import com.ym.mec.education.entity.ClassGroupStudentMapper;
 import com.ym.mec.education.req.ClassGroupReq;
+import com.ym.mec.education.req.StudentReq;
 import com.ym.mec.education.req.TeacherReq;
 import com.ym.mec.education.resp.ClassStudentResp;
 import java.util.List;
@@ -27,5 +28,5 @@ public interface IClassGroupStudentMapperService extends IService<ClassGroupStud
 
     Page<ClassGroupStudentMapper> selectPageByCondition(ClassGroupReq classGroupReq);
 
-    PageResponse getPageByTeacher(TeacherReq teacherReq);
+    PageResponse getPageByTeacher(StudentReq studentReq);
 }

+ 10 - 10
mec-education/src/main/java/com/ym/mec/education/service/impl/ClassGroupStudentMapperServiceImpl.java

@@ -6,11 +6,13 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.google.common.collect.Lists;
 import com.ym.mec.biz.dal.enums.JobTypeEnum;
+import com.ym.mec.common.security.SecurityUtils;
 import com.ym.mec.education.base.PageResponse;
 import com.ym.mec.education.entity.*;
 import com.ym.mec.education.enums.TeachTypeEnum;
 import com.ym.mec.education.mapper.ClassGroupStudentMapperMapper;
 import com.ym.mec.education.req.ClassGroupReq;
+import com.ym.mec.education.req.StudentReq;
 import com.ym.mec.education.req.TeacherReq;
 import com.ym.mec.education.resp.ClassStudentResp;
 import com.ym.mec.education.resp.StudentListResp;
@@ -105,12 +107,9 @@ public class ClassGroupStudentMapperServiceImpl extends ServiceImpl<ClassGroupSt
     }
 
     @Override
-    public PageResponse getPageByTeacher(TeacherReq teacherReq) {
-        if (Objects.isNull(teacherReq.getUserId())) {
-            return PageResponse.errorParam();
-        }
+    public PageResponse getPageByTeacher(StudentReq studentReq) {
         //判断当前登录人角色
-        Teacher teacher = teacherService.getById(teacherReq.getUserId());
+        Teacher teacher = teacherService.getById(SecurityUtils.getUser().getUserId());
         if (Objects.nonNull(teacher)) {
             //教学主管
             QueryWrapper<MusicGroup> musicGroupQueryWrapper = new QueryWrapper<>();
@@ -129,7 +128,7 @@ public class ClassGroupStudentMapperServiceImpl extends ServiceImpl<ClassGroupSt
                         musicGroupList.stream().map(MusicGroup::getId).collect(Collectors.toList()));
                 List<ClassGroup> classGroupList = classGroupService.list(classGroupQueryWrapper);
                 if (!CollectionUtils.isEmpty(classGroupList)) {
-                    return PageResponse.success(getPage(classGroupList, teacherReq, musicGroupList));
+                    return PageResponse.success(getPage(classGroupList, studentReq, musicGroupList));
                 }
             }
             //指导老师 助教老师
@@ -150,14 +149,14 @@ public class ClassGroupStudentMapperServiceImpl extends ServiceImpl<ClassGroupSt
                 if (!CollectionUtils.isEmpty(classGroupList)) {
                     musicGroupQueryWrapper.lambda().in(MusicGroup::getId, classGroupList.stream().map(ClassGroup::getMusicGroupId).collect(Collectors.toList()));
                     musicGroupList = musicGroupService.list(musicGroupQueryWrapper);
-                    return PageResponse.success(getPage(classGroupList, teacherReq, musicGroupList));
+                    return PageResponse.success(getPage(classGroupList, studentReq, musicGroupList));
                 }
             }
         }
         return PageResponse.noDataExists();
     }
 
-    private IPage<StudentListResp> getPage(List<ClassGroup> classGroupList, TeacherReq teacherReq, List<MusicGroup> musicGroupList) {
+    private IPage<StudentListResp> getPage(List<ClassGroup> classGroupList, StudentReq studentReq, List<MusicGroup> musicGroupList) {
         Page<StudentListResp> pageResult = new Page<>();
         ArrayList<StudentListResp> resultList = Lists.newArrayList();
         QueryWrapper<ClassGroupStudentMapper> classGroupStudentMapperQueryWrapper = new QueryWrapper<>();
@@ -167,8 +166,9 @@ public class ClassGroupStudentMapperServiceImpl extends ServiceImpl<ClassGroupSt
         if (!CollectionUtils.isEmpty(classGroupStudentMapperList)) {
             QueryWrapper<SysUser> sysUserQueryWrapper = new QueryWrapper<>();
             sysUserQueryWrapper.lambda().in(SysUser::getId,
-                    classGroupStudentMapperList.stream().map(ClassGroupStudentMapper::getUserId).collect(Collectors.toList()));
-            Page<SysUser> sysUserPage = new Page<>(teacherReq.getPageNo(), teacherReq.getPageSize());
+                    classGroupStudentMapperList.stream().map(ClassGroupStudentMapper::getUserId).collect(Collectors.toList()))
+                    .like(SysUser::getRealName, studentReq.getStudentName());
+            Page<SysUser> sysUserPage = new Page<>(studentReq.getPageNo(), studentReq.getPageSize());
             IPage<SysUser> page = sysUserService.page(sysUserPage, sysUserQueryWrapper);
             if (!CollectionUtils.isEmpty(page.getRecords())) {
                 BeanUtils.copyProperties(page, pageResult);