package online.wesal.wesal.entity;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDateTime;

@Entity
@Table(name = "attendees", 
       uniqueConstraints = @UniqueConstraint(columnNames = {"invitation_id", "user_id"}))
public class Attendee {
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "invitation_id", nullable = false)
    @NotNull
    private Invitation invitation;
    
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id", nullable = false)
    @NotNull
    private User user;
    
    @Column(nullable = false)
    private LocalDateTime joinedAt = LocalDateTime.now();
    
    public Attendee() {}
    
    public Attendee(Invitation invitation, User user) {
        this.invitation = invitation;
        this.user = user;
    }
    
    public Long getId() {
        return id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }
    
    public Invitation getInvitation() {
        return invitation;
    }
    
    public void setInvitation(Invitation invitation) {
        this.invitation = invitation;
    }
    
    public User getUser() {
        return user;
    }
    
    public void setUser(User user) {
        this.user = user;
    }
    
    public LocalDateTime getJoinedAt() {
        return joinedAt;
    }
    
    public void setJoinedAt(LocalDateTime joinedAt) {
        this.joinedAt = joinedAt;
    }
}