package com.sikey.wa04.business.infrastructure.dto.model;

import com.sikey.wa04.business.domain.entity.Device;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;

import java.time.Instant;
import java.util.List;

@Getter
@Setter
@Entity
@Table(name = "tb_device")
public class DeviceModel extends BaseModel {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    private Long id;

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

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

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

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

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

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

    @Column(name = "video_call_channel")
    private Integer videoCallChannel;

    @Column(name = "activation_time")
    private Instant activationTime;

    @Column(name = "deleted_at")
    private Instant deletedAt;

    @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
    @JoinColumn(
            name = "device_id",
            referencedColumnName = "id",
            foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private List<DeviceConfigModel> deviceConfigModelList;

}