Class StudentServiceImpl
java.lang.Object
com.markvarga21.studentmanager.service.impl.StudentServiceImpl
- All Implemented Interfaces:
StudentService
The service class which contains the core logic of the application.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateStudent
(StudentDto studentDto, String username, String roles) Validates-, and then persists the student into 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 application.getStudentByFirstAndLastName
(String firstName, String lastName) Retrieves a student from the database using its first and last name.getStudentById
(Long id) Retrieves a student from the application using its id.getStudentByUsername
(String username) Retrieves a student by its username.modifyStudentById
(StudentDto studentDto, Long studentId) Validates and then modifies the student's information.setValidity
(Long studentId, boolean valid) Validates the passport manually.boolean
validPassportNumber
(String passportNumber) Checks if the passport number is already in use.
-
Constructor Details
-
StudentServiceImpl
public StudentServiceImpl()
-
-
Method Details
-
getAllStudents
Retrieves all the students from the application.- Specified by:
getAllStudents
in interfaceStudentService
- 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
Validates-, and then persists the student into the database.- Specified by:
createStudent
in interfaceStudentService
- 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
Checks if the passport number is already in use.- Specified by:
validPassportNumber
in interfaceStudentService
- Parameters:
passportNumber
- The passport number to check.- Returns:
true
if the passport number is valid,false
otherwise.
-
getStudentById
Retrieves a student from the application using its id.- Specified by:
getStudentById
in interfaceStudentService
- Parameters:
id
- The identifier of the student we want to retrieve.- Returns:
- The searched student.
- Since:
- 1.0
-
getStudentByUsername
Retrieves a student by its username.- Specified by:
getStudentByUsername
in interfaceStudentService
- Parameters:
username
- The username of the student.- Returns:
- The student's DTO.
-
modifyStudentById
Validates and then modifies the student's information.- Specified by:
modifyStudentById
in interfaceStudentService
- Parameters:
studentDto
- The user itself.studentId
- The is of the student.- Returns:
- The updated
StudentDto
. - Since:
- 1.0
-
deleteStudentById
Deletes a student by its ID.- Specified by:
deleteStudentById
in interfaceStudentService
- Parameters:
id
- The identifier used for deleting a student.- Returns:
- The recently deleted student's DTO.
- Since:
- 1.0
-
setValidity
Validates the passport manually.- Specified by:
setValidity
in interfaceStudentService
- Parameters:
studentId
- The id of the student.valid
- The validity of the passport.- Returns:
- A
String
containing a feedback of the operation.
-
getStudentByFirstAndLastName
Retrieves a student from the database using its first and last name.- Specified by:
getStudentByFirstAndLastName
in interfaceStudentService
- Parameters:
firstName
- The first name of the student.lastName
- The last name of the student.- Returns:
- The found student.
-