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 javax.persistence.*;

import org.springframework.data.elasticsearch.annotations.Document;
import java.io.Serializable;
import java.time.Instant;
import java.util.Objects;

/**
 * A TBCustomer.
 */
@Entity
@Table(name = "tb_customer")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "smf_tbcustomer")
public class TBCustomer implements Serializable {

    private static final long serialVersionUID = 1L;

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

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

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

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

    @Column(name = "slug_name")
    private String slugName;

    @Column(name = "area_m_2")
    private Double areaM2;

    @Column(name = "is_activated")
    private Integer isActivated;

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

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

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

    @Column(name = "api_key")
    private String apiKey;

    @ManyToOne
    @JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
    private TBAddress tbAddress;

    @ManyToOne
    @JsonIgnoreProperties("")
    private TBDashboardType tbDashboardType;

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

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

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

    public TBCustomer() {
    }

    // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
    public Long getId() {
        return id;
    }

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

    public String getName() {
        return name;
    }

    public TBCustomer name(String name) {
        this.name = name;
        return this;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPhone() {
        return phone;
    }

    public TBCustomer phone(String phone) {
        this.phone = phone;
        return this;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public TBCustomer email(String email) {
        this.email = email;
        return this;
    }

    public void setEmail(String email) {
        this.email = email;
    }


    public String getSlugName() {
        return slugName;
    }

    public TBCustomer slugName(String slugName) {
        this.slugName = slugName;
        return this;
    }

    public void setSlugName(String slugName) {
        this.slugName = slugName;
    }

    public Double getAreaM2() {
        return areaM2;
    }

    public TBCustomer areaM2(Double areaM2) {
        this.areaM2 = areaM2;
        return this;
    }

    public void setAreaM2(Double areaM2) {
        this.areaM2 = areaM2;
    }

    public Integer getIsActivated() {
        return isActivated;
    }

    public TBCustomer isActivated(Integer isActivated) {
        this.isActivated = isActivated;
        return this;
    }

    public void setIsActivated(Integer isActivated) {
        this.isActivated = isActivated;
    }

    public Instant getCreatedDate() {
        return createdDate;
    }

    public TBCustomer createdDate(Instant createdDate) {
        this.createdDate = createdDate;
        return this;
    }

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

    public Instant getModifiedDate() {
        return modifiedDate;
    }

    public TBCustomer modifiedDate(Instant modifiedDate) {
        this.modifiedDate = modifiedDate;
        return this;
    }

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

    public Instant getDeletedDate() {
        return deletedDate;
    }

    public TBCustomer deletedDate(Instant deletedDate) {
        this.deletedDate = deletedDate;
        return this;
    }

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

    public TBAddress getTbAddress() {
        return tbAddress;
    }

    public TBCustomer tbAddress(TBAddress tBAddress) {
        this.tbAddress = tBAddress;
        return this;
    }

    public void setTbAddress(TBAddress tBAddress) {
        this.tbAddress = tBAddress;
    }

    public TBDashboardType getTbDashboardType() {
        return tbDashboardType;
    }

    public TBCustomer tbDashboardType(TBDashboardType tbDashboardType) {
        this.tbDashboardType = tbDashboardType;
        return this;
    }

    public void setTbDashboardType(TBDashboardType tbDashboardType) {
        this.tbDashboardType = tbDashboardType;
    }

    public TBDetailUser getCreatedBy() {
        return createdBy;
    }

    public TBCustomer createdBy(TBDetailUser tBDetailUser) {
        this.createdBy = tBDetailUser;
        return this;
    }

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

    public TBDetailUser getModifiedBy() {
        return modifiedBy;
    }

    public TBCustomer modifiedBy(TBDetailUser tBDetailUser) {
        this.modifiedBy = tBDetailUser;
        return this;
    }

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

    public TBDetailUser getDeletedBy() {
        return deletedBy;
    }

    public TBCustomer deletedBy(TBDetailUser tBDetailUser) {
        this.deletedBy = tBDetailUser;
        return this;
    }

    public void setDeletedBy(TBDetailUser tBDetailUser) {
        this.deletedBy = tBDetailUser;
    }
    // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove

    public String getApiKey() {
        return apiKey;
    }

    public void setApiKey(String apiKey) {
        this.apiKey = apiKey;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TBCustomer that = (TBCustomer) o;
        return Objects.equals(id, that.id) && Objects.equals(name, that.name) && Objects.equals(phone, that.phone) && Objects.equals(email, that.email) && Objects.equals(slugName, that.slugName) && Objects.equals(areaM2, that.areaM2) && Objects.equals(isActivated, that.isActivated) && Objects.equals(createdDate, that.createdDate) && Objects.equals(modifiedDate, that.modifiedDate) && Objects.equals(deletedDate, that.deletedDate) && Objects.equals(apiKey, that.apiKey) && Objects.equals(tbAddress, that.tbAddress) && Objects.equals(tbDashboardType, that.tbDashboardType) && Objects.equals(createdBy, that.createdBy) && Objects.equals(modifiedBy, that.modifiedBy) && Objects.equals(deletedBy, that.deletedBy);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name, phone, email, slugName, areaM2, isActivated, createdDate, modifiedDate, deletedDate, apiKey, tbAddress, tbDashboardType, createdBy, modifiedBy, deletedBy);
    }

    @Override
    public String toString() {
        return "TBCustomer{" +
            "id=" + getId() +
            ", name='" + getName() + "'" +
            ", phone='" + getPhone() + "'" +
            ", email='" + getEmail() + "'" +
            ", slugName='" + getSlugName() + "'" +
            ", areaM2=" + getAreaM2() +
            ", isActivated=" + getIsActivated() +
            ", createdDate='" + getCreatedDate() + "'" +
            ", modifiedDate='" + getModifiedDate() + "'" +
            ", deletedDate='" + getDeletedDate() + "'" +
            ", apiKey='" + getApiKey() + "'" +
            "}";
    }
}
