package fr.titionfire.ffsaf.data.model;

import io.quarkus.runtime.annotations.RegisterForReflection;
import jakarta.persistence.*;
import lombok.*;
import org.eclipse.microprofile.openapi.annotations.media.Schema;

@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
@RegisterForReflection

@Entity
@Table(name = "licence")
public class LicenceModel implements LoggableModel  {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Schema(description = "L'identifiant de la licence.")
    Long id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "membre", referencedColumnName = "id")
    @Schema(description = "Le membre de la licence. (optionnel)")
    MembreModel membre;

    Long club_id;

    @Schema(description = "La saison de la licence.", example = "2025")
    int saison;

    @Schema(description = "Nom et date du médecin sur certificat médical.", example = "M. Jean¤2025-02-03", format = "<Nom>¤<yyyy-mm-dd>")
    String certificate;

    @Schema(description = "Licence validée", example = "true")
    boolean validate;

    @Schema(description = "Licence payer", example = "true")
    @Column(nullable = false, columnDefinition = "boolean default false")
    boolean pay = false;

    @Override
    public String getObjectName() {
        return "licence " + id.toString();
    }

    @Override
    public LogModel.ObjectType getObjectType() {
        return LogModel.ObjectType.Licence;
    }
}
