Interface StudentService
- All Known Implementing Classes:
StudentServiceImpl
public interface StudentService
An interface which contains essential methods
for manipulating student information.
-
Method Summary
Modifier and TypeMethodDescriptioncreateStudent
(StudentDto studentDto, String username, String roles) Validates and then persists a student in the database.Deletes a student by its ID.org.springframework.data.domain.Page<StudentDto>
getAllStudents
(Integer page, Integer size) Retrieves all the students from the database.getStudentByFirstAndLastName
(String firstName, String lastName) Retrieves a student by its first and last name.getStudentById
(Long id) Retrieves a student from the database using its ID.getStudentByUsername
(String username) Retrieves a student by its username.modifyStudentById
(StudentDto studentDto, Long userId) Modifies the student given its id.setValidity
(Long studentId, boolean valid) Sets the validity of a student.boolean
validPassportNumber
(String passportNumber) Checks if the passport number is valid or not.
-
Method Details
-
getAllStudents
Retrieves all the students from the database.- Parameters:
page
- The page number.size
- The number of elements in a single page.- Returns:
- All the students stored in a
Page
.
-
createStudent
Validates and then persists a student in the database.- Parameters:
studentDto
- The student itself.username
- The username of the user who created the student.roles
- The concatenatedString
roles of the user who created the student.- Returns:
- The newly modified student.
-
getStudentById
Retrieves a student from the database using its ID.- Parameters:
id
- The identifier of the student we want to retrieve.- Returns:
- The found student.
-
modifyStudentById
Modifies the student given its id.- Parameters:
studentDto
- The student itself.userId
- The id of the student we want to modify.- Returns:
- The newly modified student.
-
deleteStudentById
Deletes a student by its ID.- Parameters:
id
- The identifier used for deleting a student.- Returns:
- The recently deleted student's DTO.
-
setValidity
Sets the validity of a student.- Parameters:
studentId
- The id of the student.valid
-true
if the passport is valid,false
otherwise.- Returns:
- A
String
containing a feedback of the operation.
-
validPassportNumber
Checks if the passport number is valid or not.- Parameters:
passportNumber
- The passport number to check.- Returns:
true
if the passport number is valid,false
otherwise.
-
getStudentByUsername
Retrieves a student by its username.- Parameters:
username
- The username of the student.- Returns:
- The student's DTO.
-
getStudentByFirstAndLastName
Retrieves a student by its first and last name.- Parameters:
firstName
- The first name of the student.lastName
- The last name of the student.- Returns:
- The student's DTO.
-