package com.ecep.contract.model;

import java.util.Objects;

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

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;

/**
 * 存货分类
 */
@Getter
@Setter
@Entity
@Table(name = "INVENTORY_CATALOG", schema = "supplier_ms")
public class InventoryCatalog implements IdentityEntity, BasedEntity, Voable<InventoryCatalogVo> {
    @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;

    @Override
    public String toPrettyString() {
        return getName() + " " + getCode();
    }

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

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

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