package dev.lions.unionflow.server.entity.registre;

import dev.lions.unionflow.server.api.enums.registre.StatutAgrement;
import dev.lions.unionflow.server.entity.BaseEntity;
import dev.lions.unionflow.server.entity.Membre;
import dev.lions.unionflow.server.entity.Organisation;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.*;

import java.time.LocalDate;

@Entity
@Table(name = "agrements_professionnels", indexes = {
        @Index(name = "idx_agrement_membre", columnList = "membre_id"),
        @Index(name = "idx_agrement_orga", columnList = "organisation_id")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class AgrementProfessionnel extends BaseEntity {

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "membre_id", nullable = false)
    private Membre membre;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "organisation_id", nullable = false)
    private Organisation organisation;

    @Column(name = "secteur_ordre", length = 150)
    private String secteurOuOrdre;

    @Column(name = "numero_licence", length = 100)
    private String numeroLicenceOuRegistre;

    @Column(name = "categorie_classement", length = 100)
    private String categorieClassement;

    @Column(name = "date_delivrance")
    private LocalDate dateDelivrance;

    @Column(name = "date_expiration")
    private LocalDate dateExpiration;

    @NotNull
    @Enumerated(EnumType.STRING)
    @Column(name = "statut", nullable = false, length = 50)
    @Builder.Default
    private StatutAgrement statut = StatutAgrement.PROVISOIRE;
}
