コード例 #1
1
 @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;
 }
コード例 #2
0
  @Override
  public StudentDTO queryStudentForAPP(String userId, String schoolId) {
    UserDTO mUsers = userService.getByUserId(userId);
    if (mUsers == null) {
      logger.debug("未找到学乐号为" + userId + "的学生用户");
      return null;
    }

    MStudent mStudent = studentMapper.selectByPrimaryKey(userId, schoolId);
    if (mStudent == null) {
      logger.debug("未找到学生id为" + userId + "的学生");
      throw new MemberException("未找到学生id为" + userId + "的学生");
    }
    // 学生信息
    StudentDTO studentDTO = new StudentDTO();
    studentDTO.setUserId(userId);
    studentDTO.setRealName(mUsers.getRealName());
    studentDTO.setSchoolId(mStudent.getSchoolId());
    studentDTO.setSchoolName(mStudent.getSchoolName());
    studentDTO.setClassId(mStudent.getClassId());
    studentDTO.setClassName(mStudent.getClassName());
    studentDTO.setMobile(mUsers.getMobile());
    studentDTO.setEmail(mUsers.getEmail());

    // 学校所在区域信息
    MSchool mSchool = mSchoolMapper.selectByPrimaryKey(mUsers.getSchoolId());
    if (mSchool == null) {
      logger.debug("未找到学乐号为" + userId + "的学生用户所在的学校");
      return null;
    }
    studentDTO.setAreaCode(mSchool.getArea());
    studentDTO.setAreaName(mSchool.getAreaName());

    // 班级信息
    MClass mClass = classMapper.selectByPrimaryKey(mStudent.getClassId(), schoolId);
    if (mClass == null) {
      logger.debug("未找到学乐号为" + userId + "的学生用户所在的班级");
      return null;
    }
    studentDTO.setGradeNum(getGradeNum(mClass.getYears()));
    studentDTO.setYear(mClass.getYears());
    return studentDTO;
  }
コード例 #3
0
  @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;
  }