package com.itdominator.api.entities;


import java.io.Serializable;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.validation.constraints.Pattern;

import lombok.Data;
import lombok.EqualsAndHashCode;


@Entity
@Table
@Data
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
public class Thumbnails implements Serializable {

    private static final long serialVersionUID = -666L;

    @Id
    @Column(name = "id", nullable = false)
    @EqualsAndHashCode.Include
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int id;

    @Column(name = "file_name", nullable = false)
    private String fileName;

    @Column(name = "file_hash", length = 32, nullable = false)
    @Pattern(regexp = "[a-zA-Z0-9]*$")
    private String fileHash;

    @Column(name = "image", columnDefinition="BLOB NOT NULL")
    private byte[] image;

    public Thumbnails(String fileName, String fileHash, byte[] image) {
        this.fileName = fileName;
        this.fileHash = fileHash;
        this.image    = image;
    }

}
