package dev.lions.unionflow.server.entity;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.UUID;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * Participation d'un membre à une session de formation LBC/FT.
 *
 * @since 2026-04-25 (P1-NEW-12)
 */
@Entity
@Table(name = "participations_formation_lbcft",
    uniqueConstraints = @UniqueConstraint(columnNames = {"formation_id", "membre_id"}),
    indexes = {
        @Index(name = "idx_participation_membre", columnList = "membre_id"),
        @Index(name = "idx_participation_statut", columnList = "statut_participation")
    })
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class ParticipationFormationLbcFt extends BaseEntity {

  @NotNull
  @ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn(name = "formation_id", nullable = false)
  private FormationLbcFt formation;

  @NotNull
  @Column(name = "membre_id", nullable = false)
  private UUID membreId;

  @NotBlank
  @Column(name = "statut_participation", nullable = false, length = 20)
  @Builder.Default
  private String statutParticipation = "INSCRIT"; // INSCRIT, PRESENT, ABSENT, CERTIFIE

  @Column(name = "date_certification")
  private LocalDateTime dateCertification;

  @Column(name = "numero_certificat", length = 100)
  private String numeroCertificat;

  @Column(name = "score_quiz", precision = 5, scale = 2)
  private BigDecimal scoreQuiz;
}
