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

import lombok.*;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

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

@Getter
@Setter
@Entity
@NoArgsConstructor
@DynamicInsert
@DynamicUpdate
@Table(name = "public_comment")
@IdClass(PublicComment.PublicCommentId.class)
public class PublicComment {
  @Id
  @Column(name = "public_key")
  private Integer publicKey;
  @Id
  @Column(name = "comment_key")
  private Integer commentKey;
  @Column(name = "comment")
  private String comment;
  @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")
  private LocalDateTime wrtDt;
  @Column(name = "parent_comment")
  private Integer parentComment;

  @Transient
  private List<PublicComment> childCommentList;

  @Embeddable
  @Data
  @NoArgsConstructor
  @AllArgsConstructor
  public static class PublicCommentId implements Serializable {
    private Integer publicKey;
    private Integer commentKey;
  }
}
