package com.example.pdfservice.entity;

import jakarta.persistence.*;

import java.time.LocalDateTime;

/**
 * Metadata row for a single stored PDF.
 * The actual bytes live on disk at "filePath" — only the path is kept in SQL Server.
 */
@Entity
@Table(name = "file_document")
public class FileDocument {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /** Original name of the file as uploaded by the user, e.g. "invoice.pdf" */
    @Column(name = "original_file_name", nullable = false, length = 255)
    private String originalFileName;

    /** Randomized name used on disk to avoid collisions, e.g. "3f2a...-invoice.pdf" */
    @Column(name = "stored_file_name", nullable = false, length = 255)
    private String storedFileName;

    /** Full absolute path on disk where the file is stored */
    @Column(name = "file_path", nullable = false, length = 1000)
    private String filePath;

    @Column(name = "content_type", length = 100)
    private String contentType;

    @Column(name = "file_size")
    private long fileSize;

    @Column(name = "upload_date", nullable = false)
    private LocalDateTime uploadDate;

    public FileDocument() {
    }

    public FileDocument(String originalFileName, String storedFileName, String filePath,
                         String contentType, long fileSize, LocalDateTime uploadDate) {
        this.originalFileName = originalFileName;
        this.storedFileName = storedFileName;
        this.filePath = filePath;
        this.contentType = contentType;
        this.fileSize = fileSize;
        this.uploadDate = uploadDate;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getOriginalFileName() {
        return originalFileName;
    }

    public void setOriginalFileName(String originalFileName) {
        this.originalFileName = originalFileName;
    }

    public String getStoredFileName() {
        return storedFileName;
    }

    public void setStoredFileName(String storedFileName) {
        this.storedFileName = storedFileName;
    }

    public String getFilePath() {
        return filePath;
    }

    public void setFilePath(String filePath) {
        this.filePath = filePath;
    }

    public String getContentType() {
        return contentType;
    }

    public void setContentType(String contentType) {
        this.contentType = contentType;
    }

    public long getFileSize() {
        return fileSize;
    }

    public void setFileSize(long fileSize) {
        this.fileSize = fileSize;
    }

    public LocalDateTime getUploadDate() {
        return uploadDate;
    }

    public void setUploadDate(LocalDateTime uploadDate) {
        this.uploadDate = uploadDate;
    }
}
