package com.ecep.contract.model;

import java.util.Objects;

import com.ecep.contract.util.HibernateProxyUtils;
import com.ecep.contract.vo.CustomerCatalogVo;

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;
import lombok.ToString;

/**
 * U8系统的 客户分类
 */
@Getter
@Setter
@Entity
@Table(name = "CUSTOMER_CATALOG", schema = "supplier_ms")
@ToString
public class CustomerCatalog implements BasedEntity, IdentityEntity, Voable<CustomerCatalogVo> {
    @Id
    @Column(name = "ID", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    /**
     * 用友U8系统中的合同分类代码
     */
    @Column(name = "CODE")
    private String code;

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

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

    @Override
    public String toPrettyString() {
        return code + " " + name;
    }

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

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

    @Override
    public CustomerCatalogVo toVo() {
        CustomerCatalogVo vo = new CustomerCatalogVo();
        vo.setId(id);
        vo.setCode(code);
        vo.setName(name);
        vo.setDescription(description);
        return vo;
    }
}
