package org.raddatz.familienarchiv.ocr;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import java.time.LocalDateTime;
import java.util.UUID;

@Entity
@Table(name = "ocr_job_documents")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class OcrJobDocument {

    @Id
    @GeneratedValue(strategy = GenerationType.UUID)
    @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
    private UUID id;

    @Column(name = "job_id", nullable = false)
    @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
    private UUID jobId;

    @Column(name = "document_id", nullable = false)
    @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
    private UUID documentId;

    @Enumerated(EnumType.STRING)
    @Column(nullable = false)
    @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
    @Builder.Default
    private OcrDocumentStatus status = OcrDocumentStatus.PENDING;

    @Column(name = "error_message")
    private String errorMessage;

    @Column(name = "current_page")
    @Builder.Default
    private int currentPage = 0;

    @Column(name = "total_pages")
    @Builder.Default
    private int totalPages = 0;

    @Column(name = "created_at", nullable = false, updatable = false)
    @CreationTimestamp
    @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
    private LocalDateTime createdAt;

    @Column(name = "updated_at", nullable = false)
    @UpdateTimestamp
    @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
    private LocalDateTime updatedAt;
}
