package fr.titionfire.ffsaf.data.model;

import fr.titionfire.ffsaf.data.id.RegisterId;
import io.quarkus.runtime.annotations.RegisterForReflection;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@RegisterForReflection

@Entity
@Table(name = "helloasso_register")
public class HelloAssoRegisterModel {
    @EmbeddedId
    RegisterId id;

    @MapsId("competitionId")
    @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
    @JoinColumn(name = "id_competition")
    CompetitionModel competition;

    @MapsId("membreId")
    @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
    @JoinColumn(name = "id_membre")
    MembreModel membre;

    Integer orderId;

    public HelloAssoRegisterModel(CompetitionModel competition, MembreModel membre, Integer orderId) {
        this.id = new RegisterId(competition.getId(), membre.getId());
        this.competition = competition;
        this.membre = membre;
        this.orderId = orderId;
    }
}
