package vn.azteam.tpf.domain;

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.util.Objects;

/**
 * A Casbin.
 */
@Entity
@Table(name = "casbin_rule")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "smf_casbinrule")
public class Casbin implements Serializable {
    private static final long serialVersionUID = 1L;

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

    @Column(name = "ptype")
    private String pType;
    @Column(name = "v0")
    private String v0;
    @Column(name = "v1")
    private String v1;
    @Column(name = "v2")
    private String v2;
    @Column(name = "v3")
    private String v3;
    @Column(name = "v4")
    private String v4;
    @Column(name = "v5")
    private String v5;

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

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

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

    @ManyToOne
    @JsonIgnoreProperties("")
    private TBRole tbRole;

    @ManyToOne
    @JsonIgnoreProperties("")
    private TBFunction tbFunction;

    @ManyToOne
    @JsonIgnoreProperties("")
    @JoinColumn(name = "created_by")
    private TBDetailUser createdBy;

    @ManyToOne
    @JsonIgnoreProperties("")
    @JoinColumn(name = "modified_by")
    private TBDetailUser modifiedBy;

    @ManyToOne
    @JsonIgnoreProperties("")
    @JoinColumn(name = "deleted_by")
    private TBDetailUser deletedBy;

    // 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 Integer getHasPermission() {
//        return hasPermission;
//    }

//    public Casbin hasPermission(Integer hasPermission) {
//        this.hasPermission = hasPermission;
//        return this;
//    }
//
//    public void setHasPermission(Integer hasPermission) {
//        this.hasPermission = hasPermission;
//    }

    public Long getCreatedDate() {
        return createdDate;
    }

    public Casbin createdDate(Long createdDate) {
        this.createdDate = createdDate;
        return this;
    }

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

    public Long getModifiedDate() {
        return modifiedDate;
    }

    public Casbin modifiedDate(Long modifiedDate) {
        this.modifiedDate = modifiedDate;
        return this;
    }

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

    public Long getDeletedDate() {
        return deletedDate;
    }

    public Casbin deletedDate(Long deletedDate) {
        this.deletedDate = deletedDate;
        return this;
    }

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

    public TBRole getTbRole() {
        return tbRole;
    }

    public Casbin tbRole(TBRole tbRole) {
        this.tbRole = tbRole;
        return this;
    }

    public void setTbRole(TBRole tbRole) {
        this.tbRole = tbRole;
    }

    public TBFunction getTbFunction() {
        return tbFunction;
    }

    public Casbin tbFunction(TBFunction tbFunction) {
        this.tbFunction = tbFunction;
        return this;
    }

    public void setTbFunction(TBFunction tbFunction) {
        this.tbFunction = tbFunction;
    }

    public TBDetailUser getCreatedBy() {
        return createdBy;
    }

    public Casbin createdBy(TBDetailUser detailUser) {
        this.createdBy = detailUser;
        return this;
    }

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

    public TBDetailUser getModifiedBy() {
        return modifiedBy;
    }

    public Casbin modifiedBy(TBDetailUser detailUser) {
        this.modifiedBy = detailUser;
        return this;
    }

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

    public TBDetailUser getDeletedBy() {
        return deletedBy;
    }

    public Casbin deletedBy(TBDetailUser detailUser) {
        this.deletedBy = detailUser;
        return this;
    }

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

    public String getpType() {
        return pType;
    }

    public void setpType(String pType) {
        this.pType = pType;
    }

    public Casbin pType(String pType) {
        this.pType = pType;
        return this;
    }

    public String getV0() {
        return v0;
    }

    public void setV0(String v0) {
        this.v0 = v0;
    }

    public Casbin v0(String v0) {
        this.v0 = v0;
        return this;
    }
    public String getV1() {
        return v1;
    }

    public void setV1(String v1) {
        this.v1 = v1;
    }

    public Casbin v1(String v1) {
        this.v1 = v1;
        return this;
    }
    public String getV2() {
        return v2;
    }

    public void setV2(String v2) {
        this.v2 = v2;
    }

    public Casbin v2(String v2) {
        this.v2 = v2;
        return this;
    }

    public String getV3() {
        return v3;
    }

    public void setV3(String v3) {
        this.v3 = v3;
    }

    public Casbin v3(String v3) {
        this.v3 = v3;
        return this;
    }

    public String getV4() {
        return v4;
    }

    public void setV4(String v4) {
        this.v4 = v4;
    }

    public Casbin v4(String v4) {
        this.v4 = v4;
        return this;
    }

    public String getV5() {
        return v5;
    }

    public void setV5(String v5) {
        this.v5 = v5;
    }

    public Casbin v5(String v5) {
        this.v5 = v5;
        return this;
    }
    // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Casbin casbin = (Casbin) o;
        if (casbin.getId() == null || getId() == null) {
            return false;
        }
        return Objects.equals(getId(), casbin.getId());
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(getId());
    }

    @Override
    public String toString() {
        return "Casbin{" +
            "id=" + getId() +
            "id=" + getpType() +
            "id=" + getV0() +
            "id=" + getV1() +
            "id=" + getV2() +
            "id=" + getV3() +
            "id=" + getV4() +
            "id=" + getV5() +
//            ", hasPermission=" + getHasPermission() +
            ", createdDate=" + getCreatedDate() +
            ", modifiedDate=" + getModifiedDate() +
            ", deletedDate=" + getDeletedDate() +
            "}";
    }
}
