package com.itdominator.api.repositories;


import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import com.itdominator.api.dto.ThumbnailDto;
import com.itdominator.api.entities.Thumbnails;
import com.itdominator.api.entities.ThumbnailsId;



@Repository
public interface ThumbnailRepository extends JpaRepository<Thumbnails, ThumbnailsId> {

    @Query(value = "SELECT * FROM thumbnails", nativeQuery = true)
    List<ThumbnailDto> getAllThumbnails();

    @Query(value = "SELECT path FROM thumbnails WHERE file_hash = :fileHash", nativeQuery = true)
    ThumbnailDto findThumbnailByHash(String fileHash);

    @Query(value = "SELECT path FROM thumbnails WHERE id = :id", nativeQuery = true)
    ThumbnailDto findThumbnailById(int id);

}
