@Override public StudentDTO updateStudentForAPP(StudentDTO studentDTO) { // 更新联系方式 UserDTO userDTO = new UserDTO(); boolean isAllNot = true; // 学生姓名 String name = studentDTO.getRealName(); if (!StringUtils.isEmpty(name)) { userDTO.setRealName(name); isAllNot = false; } String school = studentDTO.getSchoolId(); if (school != null) { userDTO.setSchoolId(school); isAllNot = false; } else { logger.warn("schoolId不能为空"); return null; } String userId = studentDTO.getUserId(); if (!StringUtils.isEmpty(userId)) { userDTO.setUserId(userId); } else { logger.warn("userId不能为空"); return null; } String mobile = studentDTO.getMobile(); if (!StringUtils.isEmpty(mobile)) { userDTO.setMobile(mobile); isAllNot = false; } String email = studentDTO.getEmail(); if (!StringUtils.isEmpty(email)) { userDTO.setEmail(email); isAllNot = false; } if (!isAllNot) { userService.updateByUserId(userDTO); } // 更新班级 String schoolId = userService.getSchoolId(userId); if (StringUtils.isEmpty(schoolId)) { throw new MemberException("该学生没有学校"); } MSchool mSchool = mSchoolMapper.selectByPrimaryKey(schoolId); String classId = studentDTO.getClassId(); if (!StringUtils.isEmpty(classId)) { MClass mClass = classMapper.selectByPrimaryKey(classId, schoolId); if (mClass == null) { logger.warn("找不到班级号为" + classId + "的班级"); return null; } MStudent mStudent = new MStudent(); mStudent.setUserId(studentDTO.getUserId()); mStudent.setClassName(mClass.getName()); mStudent.setClassId(classId); mStudent.setSchoolId(schoolId); studentMapper.updateByPrimaryKey(mStudent); } studentDTO.setClassId(classId); studentDTO.setSchoolId(schoolId); studentDTO.setSchoolName(mSchool.getName()); return studentDTO; }