package com.itsol.quantrivanphong.model;


import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import javax.validation.constraints.Size;
import java.util.ArrayList;
import java.util.List;

@Entity
@Table(name = "employee")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class Employee {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false, unique = true)
    private int id;

    @Column(name = "username", length = 128, nullable = false, unique = true)
    private String username;

    @Column(name = "password", length = 128)
    private String password;
    @Column(name = "confirm_password")
    @Size(min = 5, max = 20)
    private String confirmPassword;

    @Column(name = "first_name", length = 50)
    private String firstName;

    @Column(name = "last_name", length = 50)
    private String lastName;

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

    @Column(name = "email_address")
    private String emailAddress;

    @Column(name = "phone_number", length = 20)
    private String phoneNumber;

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

    @Column(name = "facebook_profile")
    private String facebookProfile;

    @Column(name = "position", length = 50)
    private String position;

    @Column(name = "home_town", length = 50)
    private String homeTown;

    @Column(name = "education", length = 50)
    private String education;

    @Column(name = "school", length = 50)
    private String school;

    @Column(name = "department", length = 50)
    private String department;

    @Column(name = "graduation_year", length = 10)
    private String graduationYear;

    @Column(name = "checked", nullable = false)
    private boolean checked;

    @Column(name = "status", nullable = false)
    private boolean status;

    @JsonIgnore
    @OneToMany(mappedBy = "employee", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private List<News> newsList = new ArrayList<>();

    @JsonIgnore
    @OneToMany(mappedBy = "employee", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private List<LeaveForm> leaveFormList = new ArrayList<>();

    @JsonIgnore
    @OneToMany(mappedBy = "employee", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private List<EmployeeRole> employeeRoleList = new ArrayList<>();

    @JsonIgnore
    @OneToMany(mappedBy = "employee", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private List<Eproject> eprojectList = new ArrayList<>();

}
