This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
package ru.soune.nocopy.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import ru.soune.nocopy.entity.file.ImageHashEntity;
|
||||
|
||||
@Repository
|
||||
public interface ImageHashRepository extends JpaRepository<ImageHashEntity, String> {
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package ru.soune.nocopy.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import ru.soune.nocopy.entity.file.FileEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface ImageSimilarityRepository
|
||||
extends JpaRepository<FileEntity, String> {
|
||||
|
||||
@Query(value = """
|
||||
SELECT
|
||||
f.id AS similarFileId,
|
||||
f.original_file_name AS originalFileName,
|
||||
f.file_size AS fileSize,
|
||||
h.hash64_hi AS hash64Hi,
|
||||
h.hash64_lo AS hash64Lo
|
||||
FROM image_hashes ref
|
||||
JOIN image_hashes h
|
||||
ON ref.file_id <> h.file_id
|
||||
JOIN file_entities f
|
||||
ON f.id = h.file_id
|
||||
WHERE ref.file_id = :fileId
|
||||
""",
|
||||
nativeQuery = true)
|
||||
List<SimilarImageProjection> findCandidates(
|
||||
@Param("fileId") String fileId
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package ru.soune.nocopy.repository;
|
||||
|
||||
public interface SimilarImageProjection {
|
||||
|
||||
String getSimilarFileId();
|
||||
|
||||
String getOriginalFileName();
|
||||
|
||||
Long getFileSize();
|
||||
|
||||
Integer getHash64Hi();
|
||||
|
||||
Integer getHash64Lo();
|
||||
}
|
||||
Reference in New Issue
Block a user