package com.ecep.contract.model;

import java.io.Serializable;
import java.util.Objects;

import com.ecep.contract.util.HibernateProxyUtils;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.Setter;

/**
 * 合同编号中前缀部分代表合同种类
 * <p>
 * 表明种类含义，以及存储方法、存储目的目录
 */
@Getter
@Setter
@Entity
@Table(name = "CONTRACT_CATALOG", schema = "supplier_ms")
public class ContractCatalog implements IdentityEntity, NamedEntity, Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID", nullable = false)
    private Integer id;

    /**
     * 合同编号 - 前的分类编号
     */
    @Column(name = "CODE")
    private String code;

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

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

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

    /**
     * 是否使用年份组织目录
     */
    @Column(name = "USE_YEAR")
    private boolean useYear;

    @Override
    public final boolean equals(Object object) {
        if (this == object)
            return true;
        if (object == null)
            return false;
        if (HibernateProxyUtils.isNotEffectiveClassEquals(object, this)) {
            return false;
        }
        ContractCatalog that = (ContractCatalog) object;
        return getId() != null && Objects.equals(getId(), that.getId());
    }

    @Override
    public final int hashCode() {
        return HibernateProxyUtils.hashCode(this);
    }
}
