package br.gov.sigefp.rh.domain;

import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.UuidGenerator;

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

@Entity
@Table(name = "agent_status_history", indexes = {
        @Index(name = "idx_history_agent_id", columnList = "agent_id"),
        @Index(name = "idx_history_changed_at", columnList = "changed_at")
})
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class AgentStatusHistory {

    @Id
    @GeneratedValue
    @UuidGenerator
    private UUID id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "agent_id", nullable = false)
    private Agent agent;

    @Column(name = "previous_status", length = 20)
    private String previousStatus;

    @Column(name = "new_status", length = 20)
    private String newStatus;

    @Column(name = "previous_functional_situation", length = 50)
    private String previousFunctionalSituation;

    @Column(name = "new_functional_situation", length = 50)
    private String newFunctionalSituation;

    @Column(name = "event_type", length = 50)
    private String eventType; // PROMOTIO, PROGRESSION, SUBSTITUTION, TRANSFER, etc.

    @Column(length = 500)
    private String reason;

    @Column(name = "changed_at", nullable = false)
    private LocalDateTime changedAt;

    @Column(name = "changed_by", length = 100)
    private String changedBy;

    @Column(name = "change_log", length = 1000)
    private String changeLog;
}
