package fr.marouse.entity;

import java.sql.Date;
import java.util.List;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.JoinTable;
import jakarta.persistence.ManyToMany;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;

@Entity
@Table(name = "Client")
public class Client {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "numClient")
    private int numClient;

    @Column(name = "nomClient", nullable = false)
    private String nomClient;

    @Column(name = "prenomClient", nullable = false)
    private String prenomClient;

    @Column(name = "adClient")
    private String adClient;

    @Column(name = "dateNaissClient")
    private Date dateNaissClient;

    @Column(name = "ageClient")
    private int ageClient;

    @ManyToOne(cascade = CascadeType.PERSIST)
    private Agent agent;

    @ManyToMany
    @JoinTable(
        name = "client_compte",
        joinColumns = @JoinColumn(name = "numClient"),
        inverseJoinColumns = @JoinColumn(name = "numCompte")
    )
    private List<Compte> comptes;

    public Client() {}
    public Client(String nomClient, String prenomClient, String adClient, java.sql.Date dateNaissClient, Agent agent, int age) {
        this.nomClient = nomClient;
        this.prenomClient = prenomClient;
        this.adClient = adClient;
        this.dateNaissClient = dateNaissClient;
        this.agent = agent;
        this.ageClient = age;
    }

    public int getNumClient() {
        return numClient;
    }

    public void setNumClient(int numClient) {
        this.numClient = numClient;
    }

    public String getNomClient() {
        return nomClient;
    }

    public void setNomClient(String nomClient) {
        this.nomClient = nomClient;
    }

    public String getPrenomClient() {
        return prenomClient;
    }

    public void setPrenomClient(String prenomClient) {
        this.prenomClient = prenomClient;
    }

    public String getAdClient() {
        return adClient;
    }

    public void setAdClient(String adClient) {
        this.adClient = adClient;
    }

    public Date getDateNaissClient() {
        return dateNaissClient;
    }

    public void setDateNaissClient(Date dateNaissClient) {
        this.dateNaissClient = dateNaissClient;
    }

    public int getAgeClient() {
        return ageClient;
    }

    public void setAgeClient(int ageClient) {
        this.ageClient = ageClient;
    }

    public Agent getAgent() {
        return this.agent;
    }

    public void setAgent(Agent agent) {
        this.agent = agent;
    }

    public List<Compte> getComptes() {
        return comptes;
    }

    public void setComptes(List<Compte> comptes) {
        this.comptes = comptes;
    }
}