Class FileUploadServiceImpl

java.lang.Object
com.markvarga21.studentmanager.service.file.impl.FileUploadServiceImpl
All Implemented Interfaces:
FileUploadService

@Service public class FileUploadServiceImpl extends Object implements FileUploadService
The FileUploadServiceImpl class is used to store and manipulate the images of a student.
  • 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 interface FileUploadService
      Parameters:
      studentId - The id of the student.
      passportImage - The passport file.
      selfieImage - The selfie file.
      Returns:
      A feedback message.
    • getAllImages

      public org.springframework.data.domain.Page<StudentImage> getAllImages(Integer page, Integer size)
      A method used to get all the student images from the database.
      Specified by:
      getAllImages in interface FileUploadService
      Parameters:
      page - The page number.
      size - The number of elements in a page.
      Returns:
      The images.
    • deleteImage

      @CacheEvict(value="studentImage", key="#studentId") public String deleteImage(Long studentId)
      A method used to delete the images from the database for a given student id.
      Specified by:
      deleteImage in interface FileUploadService
      Parameters:
      studentId - The id of the student.
      Returns:
      An informational message.
    • getImageForType

      public byte[] getImageForType(Long studentId, StudentImageType type)
      A method which is used to get the image for the given type and student id.
      Specified by:
      getImageForType in interface FileUploadService
      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 interface FileUploadService
      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 interface FileUploadService
      Parameters:
      studentId - The id of the student.
      Returns:
      The student's images.