package com.dbnt.kcscbackend.admin.config.entity;

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.LocalDateTime;

@Getter
@Setter
@Entity
@NoArgsConstructor
@DynamicInsert
@DynamicUpdate
@Table(name = "tc_code_item")
@IdClass(TcCodeItem.TcCodeItemId.class)
public class TcCodeItem {
  @Id
  @Column(name = "item_cd")
  private String itemCd;
  @Id
  @Column(name = "grp_cd")
  private String grpCd;
  @Column(name = "item_nm")
  private String itemNm;
  @Column(name = "frst_crt_id")
  private String frstCrtId;
  @Column(name = "frst_crt_dt")
  @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
  private LocalDateTime frstCrtDt;
  @Column(name = "last_chg_id")
  private String lastChgId;
  @Column(name = "last_chg_dt")
  @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
  private LocalDateTime lastChgDt;
  @Column(name = "use_yn")
  private String useYn;
  @Column(name = "grp_order")
  private Integer grpOrder;

  @Embeddable
  @Data
  @NoArgsConstructor
  @AllArgsConstructor
  public static class TcCodeItemId implements Serializable {
    private String itemCd;
    private String grpCd;
  }
}
