package vn.azteam.tpf.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springframework.data.elasticsearch.annotations.Document;

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

@Entity
@Table(name = "tb_code_details")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "smf_tbcodedetails")
public class TBCodeDetails implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JsonIgnoreProperties("")
    @JsonIgnore
    @JoinColumn(name = "tb_code_id")
    private TBCode tbCode;

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

    @Column(name = "number_scan")
    private Integer numberScan;

    @Column(name = "status")
    @Enumerated(value = EnumType.STRING)
    private TBCodeDetailsStatusEnum status = TBCodeDetailsStatusEnum.NEW;

    @Column(name = "last_updated_date")
    private Instant lastUpdatedDate;

    @Column(name = "created_date")
    private Instant createdDate;

    @Column(name = "modified_date")
    private Instant modifiedDate;

    @Column(name = "deleted_date")
    private Instant deletedDate;

    @ManyToOne(fetch = FetchType.LAZY)
    @JsonIgnoreProperties("")
    @JoinColumn(name = "created_by")
    private TBDetailUser createdBy;

    @ManyToOne(fetch = FetchType.LAZY)
    @JsonIgnoreProperties("")
    @JoinColumn(name = "modified_by")
    private TBDetailUser modifiedBy;

    @ManyToOne(fetch = FetchType.LAZY)
    @JsonIgnoreProperties("")
    @JoinColumn(name = "deleted_by")
    private TBDetailUser deletedBy;


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public TBCode getTbCode() {
        return tbCode;
    }

    public void setTbCode(TBCode tbCode) {
        this.tbCode = tbCode;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Integer getNumberScan() {
        return numberScan;
    }

    public void setNumberScan(Integer numberScan) {
        this.numberScan = numberScan;
    }

    public TBCodeDetailsStatusEnum getStatus() {
        return status;
    }

    public void setStatus(TBCodeDetailsStatusEnum status) {
        this.status = status;
    }

    public Instant getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Instant createdDate) {
        this.createdDate = createdDate;
    }

    public Instant getModifiedDate() {
        return modifiedDate;
    }

    public void setModifiedDate(Instant modifiedDate) {
        this.modifiedDate = modifiedDate;
    }

    public TBDetailUser getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(TBDetailUser createdBy) {
        this.createdBy = createdBy;
    }

    public TBDetailUser getModifiedBy() {
        return modifiedBy;
    }

    public void setModifiedBy(TBDetailUser modifiedBy) {
        this.modifiedBy = modifiedBy;
    }

    public Instant getDeletedDate() {
        return deletedDate;
    }

    public void setDeletedDate(Instant deletedDate) {
        this.deletedDate = deletedDate;
    }

    public TBDetailUser getDeletedBy() {
        return deletedBy;
    }

    public void setDeletedBy(TBDetailUser deletedBy) {
        this.deletedBy = deletedBy;
    }

    public Instant getLastUpdatedDate() {
        return lastUpdatedDate;
    }

    public void setLastUpdatedDate(Instant lastUpdatedDate) {
        this.lastUpdatedDate = lastUpdatedDate;
    }
}
