package net.shyshkin.study.fullstack.supportportal.backend.domain;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.Builder;

import javax.persistence.*;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Entity
@Table(name = "events")
public class Event {

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

    @Column(nullable = false, unique = true)
    private String code;

    @Column(nullable = false)
    private String year;

    @Column(nullable = false)
    private String subject;

    @Column(nullable = false)
    private String title;

    private String subTitle;

    @Column(nullable = false)
    private String date;

    @ElementCollection
    @CollectionTable(name = "venues", joinColumns = @JoinColumn(name = "event_id"))
    private List<Venue> venue;

    @ElementCollection
    @CollectionTable(name = "highlights", joinColumns = @JoinColumn(name = "event_id"))
    private List<String> highlights;

    @ElementCollection
    @CollectionTable(name = "organisers", joinColumns = @JoinColumn(name = "event_id"))
    private List<String> organisers;

    // @ElementCollection
    // @CollectionTable(name = "fees", joinColumns = @JoinColumn(name = "event_id"))
    // private List<Fee> fee;

    @Column(nullable = false)
    private String phone;

    @Column(nullable = false)
    private String email;

    @Column(nullable = false)
    private Boolean isActive;

    @ManyToMany
    @JoinTable(
        name = "event_professors",
        joinColumns = @JoinColumn(name = "event_id"),
        inverseJoinColumns = @JoinColumn(name = "professor_id")
    )
    private List<Professor> professors;

    // Assuming you have these classes defined as well
    @Embeddable
    public static class Venue {
        private String title;
        private String date;
        private String address;
        private String info;
    }

    @Embeddable
    public static class Fee {
        private String desc;
        private Integer cost;
    }
}
