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

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.ZonedDateTime;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;

@Getter
@Setter
@Entity
@Table(name = "tb_member")
public class MemberEntity {

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

  @Column(name = "uuid", nullable = false, insertable = false)
  private UUID uuid;

  @Size(max = 50)
  @Column(name = "employee_no", length = 50)
  private String employeeNo;

  @Size(max = 100)
  @NotNull
  @Column(name = "name", nullable = false, length = 100)
  private String name;

  @Size(max = 255)
  @NotNull
  @Column(name = "password", nullable = false)
  private String password;

  @Size(max = 100)
  @Column(name = "email", length = 100)
  private String email;

  @Size(max = 20)
  @ColumnDefault("'INACTIVE'")
  @Column(name = "status", length = 20)
  private String status = "INACTIVE";

  @Column(name = "created_dttm", nullable = false, insertable = false)
  private ZonedDateTime createdDttm;

  @Column(name = "updated_dttm", nullable = false, insertable = false)
  private ZonedDateTime updatedDttm;

  @OneToMany(mappedBy = "memberUuid")
  private Set<MemberRoleEntity> tbMemberRoles = new LinkedHashSet<>();
}
