package com.itsol.quantrivanphong.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.itsol.quantrivanphong.model.Employee;
import com.itsol.quantrivanphong.model.TimeSheet;
import com.itsol.quantrivanphong.model.Project;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "eproject")
public class Eproject {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false, unique = true)
    private int id;
// chức vụ trong project
    @Column(name = "position", nullable = false)
    private String position;
//ngày vào dự án
    @Column(name = "join_date",nullable =false)
    private Timestamp joinDate;
// ngày ra dự án
    @Column(name = "out_date",nullable = true)
    private Timestamp outDate;

    @ManyToOne(fetch = FetchType.EAGER)
    private Employee employee;

    @ManyToOne(fetch = FetchType.EAGER)
    private Project project;

    @JsonIgnore
    @OneToMany(mappedBy = "eproject", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private List<TimeSheet> timeSheetList  = new ArrayList<>();
}
