package com.kamco.cd.training.postgres.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.ZonedDateTime;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;

@Getter
@Setter
@Entity
@Table(name = "tb_model_history")
public class ModelHistoryEntity {

  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Column(name = "hst_id", nullable = false)
  private Integer id;

  @NotNull
  @ManyToOne(fetch = FetchType.LAZY, optional = false)
  @JoinColumn(name = "model_id", nullable = false)
  private ModelMasterEntity model;

  @Column(name = "model_no")
  private Short modelNo;

  @Size(max = 50)
  @Column(name = "model_ver", length = 50)
  private String modelVer;

  @Column(name = "model_step")
  private Short modelStep;

  @Column(name = "step1_strt_dttm")
  private ZonedDateTime step1StrtDttm;

  @Column(name = "step1_end_dttm")
  private ZonedDateTime step1EndDttm;

  @Size(max = 20)
  @Column(name = "step1_state", length = 20)
  private String step1State;

  @Column(name = "step2_strt_dttm")
  private ZonedDateTime step2StrtDttm;

  @Column(name = "step2_end_dttm")
  private ZonedDateTime step2EndDttm;

  @Size(max = 20)
  @Column(name = "step2_state", length = 20)
  private String step2State;

  @Column(name = "error_msg", length = Integer.MAX_VALUE)
  private String errorMsg;

  @ColumnDefault("now()")
  @Column(name = "created_dttm")
  private ZonedDateTime createdDttm;

  @Column(name = "created_uid")
  private Long createdUid;
}
