package com.astalange.core.entity;

import jakarta.persistence.*;
import java.time.LocalDateTime;

@Entity
@Table(name = "token_pre_inscription")
public class TokenPreInscription {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "valeur_uuid", nullable = false, unique = true, length = 36)
    private String valeurUuid;

    @Column(name = "date_expiration", nullable = false)
    private LocalDateTime dateExpiration;

    @Column(name = "est_utilise", nullable = false)
    private Boolean estUtilise = false;

    // Getters and Setters
    public Long getId() { return id; }
    public void setId(Long id) { this.id = id; }

    public String getValeurUuid() { return valeurUuid; }
    public void setValeurUuid(String valeurUuid) { this.valeurUuid = valeurUuid; }

    public LocalDateTime getDateExpiration() { return dateExpiration; }
    public void setDateExpiration(LocalDateTime dateExpiration) { this.dateExpiration = dateExpiration; }

    public Boolean getEstUtilise() { return estUtilise; }
    public void setEstUtilise(Boolean estUtilise) { this.estUtilise = estUtilise; }

    @Transient
    public boolean isValide() {
        return !estUtilise && dateExpiration.isAfter(LocalDateTime.now());
    }
}
