Class StudentServiceImpl

java.lang.Object
com.markvarga21.studentmanager.service.impl.StudentServiceImpl
All Implemented Interfaces:
StudentService

@Service public class StudentServiceImpl extends Object implements StudentService
The service class which contains the core logic of the application.
  • Constructor Details

    • StudentServiceImpl

      public StudentServiceImpl()
  • Method Details

    • getAllStudents

      public org.springframework.data.domain.Page<StudentDto> getAllStudents(Integer page, Integer size)
      Retrieves all the students from the application.
      Specified by:
      getAllStudents in interface StudentService
      Parameters:
      page - The actual page.
      size - The number of elements in a single page.
      Returns:
      A subset of students inside a Page object.
      Since:
      1.0
    • createStudent

      public StudentDto createStudent(StudentDto studentDto, String username, String roles)
      Validates-, and then persists the student into the database.
      Specified by:
      createStudent in interface StudentService
      Parameters:
      studentDto - The student itself.
      username - The username of the user who created the student.
      roles - The roles of the user who created the student.
      Returns:
      The updated AppUserDto.
    • validPassportNumber

      public boolean validPassportNumber(String passportNumber)
      Checks if the passport number is already in use.
      Specified by:
      validPassportNumber in interface StudentService
      Parameters:
      passportNumber - The passport number to check.
      Returns:
      true if the passport number is valid, false otherwise.
    • getStudentById

      public StudentDto getStudentById(Long id)
      Retrieves a student from the application using its id.
      Specified by:
      getStudentById in interface StudentService
      Parameters:
      id - The identifier of the student we want to retrieve.
      Returns:
      The searched student.
      Since:
      1.0
    • getStudentByUsername

      public Optional<StudentDto> getStudentByUsername(String username)
      Retrieves a student by its username.
      Specified by:
      getStudentByUsername in interface StudentService
      Parameters:
      username - The username of the student.
      Returns:
      The student's DTO.
    • modifyStudentById

      public StudentDto modifyStudentById(StudentDto studentDto, Long studentId)
      Validates and then modifies the student's information.
      Specified by:
      modifyStudentById in interface StudentService
      Parameters:
      studentDto - The user itself.
      studentId - The is of the student.
      Returns:
      The updated StudentDto.
      Since:
      1.0
    • deleteStudentById

      public StudentDto deleteStudentById(Long id)
      Deletes a student by its ID.
      Specified by:
      deleteStudentById in interface StudentService
      Parameters:
      id - The identifier used for deleting a student.
      Returns:
      The recently deleted student's DTO.
      Since:
      1.0
    • setValidity

      public String setValidity(Long studentId, boolean valid)
      Validates the passport manually.
      Specified by:
      setValidity in interface StudentService
      Parameters:
      studentId - The id of the student.
      valid - The validity of the passport.
      Returns:
      A String containing a feedback of the operation.
    • getStudentByFirstAndLastName

      public Optional<StudentDto> getStudentByFirstAndLastName(String firstName, String lastName)
      Retrieves a student from the database using its first and last name.
      Specified by:
      getStudentByFirstAndLastName in interface StudentService
      Parameters:
      firstName - The first name of the student.
      lastName - The last name of the student.
      Returns:
      The found student.