package dev.lions.unionflow.server.entity;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.UUID;

/**
 * Entité Favori pour la gestion des favoris utilisateur
 * 
 * @author UnionFlow Team
 * @version 1.0
 */
@Entity
@Table(
    name = "favoris",
    indexes = {
        @Index(name = "idx_favori_utilisateur", columnList = "utilisateur_id"),
        @Index(name = "idx_favori_type", columnList = "type_favori"),
        @Index(name = "idx_favori_categorie", columnList = "categorie")
    }
)
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class Favori extends BaseEntity {

    @NotNull
    @Column(name = "utilisateur_id", nullable = false)
    private UUID utilisateurId;

    @NotBlank
    @Column(name = "type_favori", nullable = false, length = 50)
    private String typeFavori; // PAGE, DOCUMENT, CONTACT, RACCOURCI

    @NotBlank
    @Column(name = "titre", nullable = false, length = 255)
    private String titre;

    @Column(name = "description", length = 1000)
    private String description;

    @Column(name = "url", length = 1000)
    private String url;

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

    @Column(name = "couleur", length = 50)
    private String couleur;

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

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

    @Column(name = "nb_visites")
    @Builder.Default
    private Integer nbVisites = 0;

    @Column(name = "derniere_visite")
    private LocalDateTime derniereVisite;

    @Column(name = "est_plus_utilise")
    @Builder.Default
    private Boolean estPlusUtilise = false;
}

