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

import dev.lions.unionflow.server.entity.BaseEntity;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import lombok.*;
import java.math.BigDecimal;

@Entity
@Table(name = "candidats", indexes = {
        @Index(name = "idx_candidat_campagne", columnList = "campagne_vote_id")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
@ToString(exclude = "campagneVote")
public class Candidat extends BaseEntity {

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "campagne_vote_id", nullable = false)
    private CampagneVote campagneVote;

    @NotBlank
    @Column(name = "nom_candidature", nullable = false, length = 150)
    private String nomCandidatureOuChoix;

    @Column(name = "membre_associe_id", length = 36)
    private String membreIdAssocie;

    @Column(name = "profession_foi", columnDefinition = "TEXT")
    private String professionDeFoi;

    @Column(name = "photo_url", length = 500)
    private String photoUrl;

    @Column(name = "nombre_voix")
    @Builder.Default
    private Integer nombreDeVoix = 0;

    @Column(name = "pourcentage", precision = 5, scale = 2)
    @Builder.Default
    private BigDecimal pourcentageObtenu = BigDecimal.ZERO;
}
