diff --git a/src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsStudentManageServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsStudentManageServiceImpl.java index 410f1bd..5e5ae6c 100644 --- a/src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsStudentManageServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsStudentManageServiceImpl.java @@ -53,7 +53,7 @@ public class UmsStudentManageServiceImpl extends ServiceImpl pageQuery(UmsStudentPageQueryDTO umsStudentPageQueryDTO) { - LinkedHashSet umsStudentManages = coursesService.queryTeacherByStudentList(umsStudentPageQueryDTO.getName()); + LinkedHashSet umsStudentManages = coursesService.queryTeacherByStudentList(umsStudentPageQueryDTO.getUserId()); //总记录数 int totalCount = umsStudentManages.size(); @@ -61,17 +61,34 @@ public class UmsStudentManageServiceImpl extends ServiceImpl umsStudentManageList = umsStudentManages.stream() - .skip((umsStudentPageQueryDTO.getPage() - 1) * umsStudentPageQueryDTO.getPageSize()) - .limit(umsStudentPageQueryDTO.getPageSize()) - .collect(Collectors.toList()); - Map result = new HashMap<>(); - result.put("Records", umsStudentManageList); result.put("totalCount", totalCount); result.put("totalPages", totalPages); result.put("currentPage", umsStudentPageQueryDTO.getPage()); + //对集合里的数据进行模糊和分页查询 + if (umsStudentPageQueryDTO.getName() != null){ + List umsStudentManageList = umsStudentManages.stream() + .filter(studentManage -> studentManage.getName().contains(umsStudentPageQueryDTO.getName())) + .skip((umsStudentPageQueryDTO.getPage() - 1) * umsStudentPageQueryDTO.getPageSize()) + .limit(umsStudentPageQueryDTO.getPageSize()) + .collect(Collectors.toList()); + result.put("Records", umsStudentManageList); + }else if (umsStudentPageQueryDTO.getNumber() != null){ + List umsStudentManageList = umsStudentManages.stream() + .filter(studentManage -> studentManage.getNumber().contains(umsStudentPageQueryDTO.getNumber())) + .skip((umsStudentPageQueryDTO.getPage() - 1) * umsStudentPageQueryDTO.getPageSize()) + .limit(umsStudentPageQueryDTO.getPageSize()) + .collect(Collectors.toList()); + result.put("Records", umsStudentManageList); + }else { + List umsStudentManageList = umsStudentManages.stream() + .skip((umsStudentPageQueryDTO.getPage() - 1) * umsStudentPageQueryDTO.getPageSize()) + .limit(umsStudentPageQueryDTO.getPageSize()) + .collect(Collectors.toList()); + result.put("Records", umsStudentManageList); + } + return result; }