package ru.soune.nocopy.entity.file;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Entity
@Table(name = "image_hashes", indexes = {
        @Index(name = "idx_image_hashes_hash64", columnList = "hash64_hi, hash64_lo"),
        @Index(name = "idx_image_hashes_hash64_hi", columnList = "hash64_hi"),
        @Index(name = "idx_image_hashes_hash64_lo", columnList = "hash64_lo")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ImageHashEntity {

    @Id
    @Column(name = "file_id")
    private String fileId;

    @OneToOne(fetch = FetchType.LAZY)
    @MapsId
    @JoinColumn(name = "file_id")
    private FileEntity file;

    @Column(name = "hash64_hi")
    private Long hash64Hi;

    @Column(name = "hash64_lo")
    private Long hash64Lo;

    @Column(name = "hash_algorithm", nullable = false)
    private String hashAlgorithm;

    @Column(name = "created_at")
    private LocalDateTime createdAt;
}
