package com.dbnt.kcgfilemanager.model;

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

import javax.persistence.*;
import java.io.Serializable;

@Getter
@Setter
@Entity
@NoArgsConstructor
@DynamicInsert
@DynamicUpdate
@Table(name = "FILE_INFO")
@IdClass(FileInfo.FileInfoId.class)
public class FileInfo {

  @Id
  @Column(name = "CONTENT_SEQ", nullable = false)
  private Integer contentSeq;
  @Id
  @Column(name = "FILE_SEQ", nullable = false)
  private Integer fileSeq;

  @Column(name = "ORIGINAL_NAME")
  private String originalName;
  @Column(name = "CONVERSION_NAME")
  private String conversionName;
  @Column(name = "EXTENTION")
  private String extention;
  @Column(name = "FILE_SIZE")
  private String fileSize;
  @Column(name = "SAVE_PATH")
  private String savePath;

  @Embeddable
  @Data
  @NoArgsConstructor
  @AllArgsConstructor
  public static class FileInfoId implements Serializable {
    private Integer contentSeq;
    private Integer fileSeq;
  }

  public String getFullName(){
    return originalName+"."+extention;
  }
}
