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

import com.dbnt.faisp.config.BaseModel;
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 = "user_alarm")
@IdClass(UserAlarm.UserAlarmId.class)
public class UserAlarm extends BaseModel {
  @Id
  @Column(name = "alarm_key")
  private String alarmKey;
  @Id
  @Column(name = "user_seq")
  private Integer userSeq;
  @Column(name = "menu_key")
  private Integer menuKey;
  @Column(name = "ref_doc_key")
  private Integer refDocKey;
  @Column(name = "alarm_msg")
  private String alarmMsg;
  @Column(name = "view_yn")
  private String viewYn;
  @Column(name = "wrt_dt")
  @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
  private LocalDateTime wrtDt;

  @Embeddable
  @Data
  @NoArgsConstructor
  @AllArgsConstructor
  public static class UserAlarmId implements Serializable {
    private String alarmKey;
    private Integer userSeq;
  }
}
