Class FileUploadServiceImpl
java.lang.Object
com.markvarga21.studentmanager.service.file.impl.FileUploadServiceImpl
- All Implemented Interfaces:
FileUploadService
The
FileUploadServiceImpl
class is used to store and manipulate the
images of a student.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionchangeImage
(Long studentId, StudentImageType imageType, org.springframework.web.multipart.MultipartFile file) A method which is used to change the image for the given type and student id.deleteImage
(Long studentId) A method used to delete the images from the database for a given student id.org.springframework.data.domain.Page<StudentImage>
getAllImages
(Integer page, Integer size) A method used to get all the student images from the database.byte[]
getImageForType
(Long studentId, StudentImageType type) A method which is used to get the image for the given type and student id.getStudentImageById
(Long studentId) A method which is used to get the image for the given student ID.uploadFile
(Long studentId, org.springframework.web.multipart.MultipartFile passportImage, org.springframework.web.multipart.MultipartFile selfieImage) A method used to store the images in the database.
-
Constructor Details
-
FileUploadServiceImpl
public FileUploadServiceImpl()
-
-
Method Details
-
uploadFile
public String uploadFile(Long studentId, org.springframework.web.multipart.MultipartFile passportImage, org.springframework.web.multipart.MultipartFile selfieImage) A method used to store the images in the database.- Specified by:
uploadFile
in interfaceFileUploadService
- Parameters:
studentId
- The id of the student.passportImage
- The passport file.selfieImage
- The selfie file.- Returns:
- A feedback message.
-
getAllImages
A method used to get all the student images from the database.- Specified by:
getAllImages
in interfaceFileUploadService
- Parameters:
page
- The page number.size
- The number of elements in a page.- Returns:
- The images.
-
deleteImage
A method used to delete the images from the database for a given student id.- Specified by:
deleteImage
in interfaceFileUploadService
- Parameters:
studentId
- The id of the student.- Returns:
- An informational message.
-
getImageForType
A method which is used to get the image for the given type and student id.- Specified by:
getImageForType
in interfaceFileUploadService
- Parameters:
studentId
- The id of the student.type
- The image type.- Returns:
- The image.
-
changeImage
@CachePut(value="studentImage", key="#studentId") public StudentImage changeImage(Long studentId, StudentImageType imageType, org.springframework.web.multipart.MultipartFile file) A method which is used to change the image for the given type and student id.- Specified by:
changeImage
in interfaceFileUploadService
- Parameters:
studentId
- The id of the student.imageType
- The image type.file
- The new image.- Returns:
- The updated student image group.
-
getStudentImageById
@Cacheable(value="studentImage", key="#studentId") public StudentImage getStudentImageById(Long studentId) A method which is used to get the image for the given student ID.- Specified by:
getStudentImageById
in interfaceFileUploadService
- Parameters:
studentId
- The id of the student.- Returns:
- The student's images.
-