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é Suggestion pour la gestion des suggestions utilisateur
 * 
 * @author UnionFlow Team
 * @version 1.0
 */
@Entity
@Table(
    name = "suggestions",
    indexes = {
        @Index(name = "idx_suggestion_utilisateur", columnList = "utilisateur_id"),
        @Index(name = "idx_suggestion_statut", columnList = "statut"),
        @Index(name = "idx_suggestion_categorie", columnList = "categorie")
    }
)
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
public class Suggestion extends BaseEntity {

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

    @Column(name = "utilisateur_nom", length = 255)
    private String utilisateurNom;

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

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

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

    @Column(name = "categorie", length = 50)
    private String categorie; // UI, FEATURE, PERFORMANCE, SECURITE, INTEGRATION, MOBILE, REPORTING

    @Column(name = "priorite_estimee", length = 50)
    private String prioriteEstimee; // BASSE, MOYENNE, HAUTE, CRITIQUE

    @Column(name = "statut", length = 50)
    @Builder.Default
    private String statut = "NOUVELLE"; // NOUVELLE, EVALUATION, APPROUVEE, DEVELOPPEMENT, IMPLEMENTEE, REJETEE

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

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

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

    @Column(name = "date_soumission")
    private LocalDateTime dateSoumission;

    @Column(name = "date_evaluation")
    private LocalDateTime dateEvaluation;

    @Column(name = "date_implementation")
    private LocalDateTime dateImplementation;

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

    @Column(name = "mise_a_jour", columnDefinition = "TEXT")
    private String miseAJour;
}

