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

import com.kamco.cd.training.dataset.dto.DatasetClsObjDto.Basic;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.ZonedDateTime;
import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;

@Getter
@Setter
@Entity
@Table(name = "tb_dataset_cls_obj")
public class DatasetClsObjEntity {

  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Column(name = "obj_id", nullable = false)
  private Long objId;

  @Column(name = "uuid")
  private UUID uuid;

  @NotNull
  @Column(name = "dataset_uid", nullable = false)
  private Long datasetUid;

  @Column(name = "type")
  private String type;

  @Column(name = "yyyy")
  private Integer yyyy;

  @Size(max = 255)
  @Column(name = "class_cd")
  private String classCd;

  @Size(max = 255)
  @Column(name = "map_sheet_num")
  private String mapSheetNum;

  @Column(name = "tif_img_path")
  private String tifImgPath;

  @Column(name = "file_name")
  private String fileName;

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

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

  @ColumnDefault("false")
  @Column(name = "deleted")
  private Boolean deleted;

  public Basic toDto() {
    return new Basic(
        this.objId,
        this.uuid,
        this.datasetUid,
        this.type,
        this.yyyy,
        this.classCd,
        this.mapSheetNum,
        this.tifImgPath,
        this.fileName,
        this.createdDttm,
        this.createdUid,
        this.deleted);
  }
}
