package com.cd.detection.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Comment;

@Getter
@Setter
@Entity
@Table(name = "tb_zoo")
public class ZooEntity {

  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Column(name = "zoo_id")
  @Comment("동물원 ID")
  private Long zooId;

  @OneToMany(mappedBy = "zoo", fetch = FetchType.LAZY)
  private List<AnimalEntity> animals = new ArrayList<>();

  @Column(name = "zoo_name", nullable = false, length = 200)
  @Comment("동물원 이름")
  private String zooName;

  @Column(name = "description")
  @Comment("설명")
  private String description;

  @Column(name = "use_yn", nullable = false)
  @Comment("사용 여부")
  private Boolean useYn = true;

  @Column(name = "del_yn", nullable = false)
  @Comment("삭제 여부")
  private Boolean delYn = false;

  @Column(name = "created_dttm", nullable = false, updatable = false)
  @Comment("생성 일시")
  private ZonedDateTime createdDttm = ZonedDateTime.now();

  @Column(name = "updated_dttm", nullable = false)
  @Comment("수정 일시")
  private ZonedDateTime updatedDttm = ZonedDateTime.now();

  public void addAnimal(AnimalEntity animal) {
    animals.add(animal);
    animal.setZoo(this);
  }
}
