/** 查询学生信息分页 */ @Override public PageResponse<StudentManagerDTO> queryStudentPage(StudentPageRequest studentPageRequest) { String schoolId = studentPageRequest.getSchoolId(); if (schoolId == null) { schoolId = userService.getSchoolId(studentPageRequest.getUserId()); studentPageRequest.setSchoolId(schoolId); } // 获取学生信息的总条数 MStudentManager studentManager = new MStudentManager(); BeanUtils.copyProperties(studentPageRequest, studentManager); long count = studentMapper.selectCount(studentManager); // 获取当前页的信息 Page page = PageUtils.buildPage(studentPageRequest); List<MStudentManager> mStudentList = studentMapper.selectMStudentManagerPage(page, studentManager); /* 给返回接口赋值 */ List<StudentManagerDTO> studentManagerDTOs = new ArrayList<>(); for (MStudentManager mstudents : mStudentList) { StudentManagerDTO studentManagerDTO = new StudentManagerDTO(); BeanUtils.copyProperties(mstudents, studentManagerDTO); studentManagerDTO.setLastLoginDate( mstudents.getLastLoginDate() == null ? "从未登录" : DateFormatUtils.format(mstudents.getLastLoginDate(), "yyyy-MM-dd HH:mm")); if (mstudents.getYears() != null) { studentManagerDTO.setClassAliasName( getGrade(mstudents.getYears()) + studentManagerDTO.getClassAliasName()); } else { studentManagerDTO.setClassAliasName("无班级"); } studentManagerDTOs.add(studentManagerDTO); } // 返回对象 PageResponse<StudentManagerDTO> pageResponse = new PageResponse<>(); PageUtils.buldPageResponse(studentPageRequest, pageResponse); pageResponse.setRows(studentManagerDTOs); pageResponse.setRecords(count); return pageResponse; }
/** 修改学生信息 */ @Override public StudentManagerDTO updateStudentInfo(String userId, String realName, String classId) { String schoolId = userService.getSchoolId(userId); // 更换用户名称 usersMapper.updateUserName(userId, realName, schoolId); // 更换班级 MClass mClass = classMapper.selectByPrimaryKey(classId, schoolId); studentMapper.updateStudentMessage(userId, mClass); // 修改家庭关系表中用户名称 familyRelationService.updateName(userId, realName); MStudentManager studentManager = studentMapper.selectStudentByUserId(userId, schoolId); StudentManagerDTO studentManagerDTO = new StudentManagerDTO(); BeanUtils.copyProperties(studentManager, studentManagerDTO); studentManagerDTO.setClassAliasName( getGrade(mClass.getYears()) + studentManagerDTO.getClassAliasName()); // 修改孩子名称,班级信息,删除缓存数据 deleteRedisOfParent(userId, schoolId); cacheService.delete(MessageFormat.format(CacheConstants.KEY_USER, userId)); return studentManagerDTO; }