package com.dbnt.faisp.main.userInfo.model;

import lombok.*;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;


@Getter
@Setter
@Entity
@NoArgsConstructor
@DynamicInsert
@DynamicUpdate
@IdClass(UserCareer.UserCareerId.class)
@Table(name = "user_career")
public class UserCareer{
  @Id
  @Column(name = "user_seq")
  private Integer userSeq;
  @Id
  @Column(name = "career_seq")
  private Integer careerSeq;
  @Column(name = "career_cd")
  private String careerCd;
  @Column(name = "designation_cd")
  private String designationCd;
  @Column(name = "work_organ")
  private String workOrgan;
  @Column(name = "work_part")
  private String workPart;
  @Column(name = "work_position_str")
  private String workPositionStr;
  @Column(name = "work_title")
  private String workTitle;
  @Column(name = "start_date")
  @DateTimeFormat(pattern = "yyyy-MM-dd")
  private LocalDate startDate;
  @Column(name = "end_date")
  @DateTimeFormat(pattern = "yyyy-MM-dd")
  private LocalDate endDate;
  @Column(name = "work_day")
  private Integer workDay;
  @Column(name = "work_month")
  private Integer workMonth;
  @Column(name = "hord_cd")
  private String hordCd;

  @Column(name = "wrt_organ")
  private String wrtOrgan;
  @Column(name = "wrt_part")
  private String wrtPart;
  @Column(name = "wrt_user_seq")
  private Integer wrtUserSeq;
  @Column(name = "wrt_user_grd")
  private String wrtUserGrd;
  @Column(name = "wrt_user_nm")
  private String wrtUserNm;
  @Column(name = "wrt_dt")
  @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
  private LocalDateTime wrtDt;


  @Transient
  List<UserCareer> careerList;

  @Embeddable
  @Data
  @NoArgsConstructor
  @AllArgsConstructor
  public static class UserCareerId implements Serializable {
    private Integer userSeq;
    private Integer careerSeq;
  }

}
