@Override public StudentManagerDTO saveStudent(String name, String classId, String schoolId) { UserDTO userDTO = new UserDTO(); userDTO.setRealName(name); userDTO.setIdentityId(IdentityIdConstants.STUDENT); userDTO.setIdentityDescription("学生"); userDTO.setSchoolId(schoolId); userDTO.setArea(mSchoolMapper.selectByPrimaryKey(schoolId).getArea()); UserDTO users = userService.saveUser(userDTO); MClass mclass = classMapper.selectByPrimaryKey(classId, schoolId); StudentDTO studentDTO = new StudentDTO(); studentDTO.setUserId(users.getUserId()); studentDTO.setSchoolId(mclass.getSchoolId()); studentDTO.setSchoolName(mclass.getSchoolName()); studentDTO.setClassName(mclass.getName()); studentDTO.setClassId(classId); studentDTO.setClassAliasName(mclass.getAliasName()); studentDTO.setJoinClass(new Date()); MStudent mStudent = new MStudent(); BeanUtils.copyProperties(studentDTO, mStudent); studentMapper.insert(mStudent); MStudentManager studentManager = studentMapper.selectStudentByUserId(mStudent.getUserId(), schoolId); StudentManagerDTO studentManagerDTO = new StudentManagerDTO(); BeanUtils.copyProperties(studentManager, studentManagerDTO); studentManagerDTO.setClassAliasName( ClassNameUtil.getFullName(studentManager.getYears(), studentManager.getClassAliasName())); return studentManagerDTO; }
/** 修改学生信息 */ @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; }