package com.ecep.contract.model;

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

/**
 * 采购合同类型
 */
@Getter
@Setter
@Entity
@Table(name = "VENDOR_GROUP", schema = "supplier_ms")
@ToString
public class VendorGroup implements IdentityEntity, NamedEntity, BasedEntity {

    @Id
    @Column(name = "ID", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

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

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

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

    @Column(name = "IS_ACTIVE")
    private boolean active;

    @Column(name = "IS_PRICE_COMP")
    private boolean priceComparison;

    /**
     * 中选的供应商是否可以免除报价表
     */
    @Column(name = "IS_REQUIRE_QUOTATION_SHEET_FOR_BID")
    private boolean requireQuotationSheetForBid;

    /**
     * 是否可以提前预采购
     */
    @Column(name = "CAN_PRE_PURCHASE")
    private boolean canPrePurchase;

    @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;
        }
        VendorGroup that = (VendorGroup) object;
        return getId() != null && Objects.equals(getId(), that.getId());
    }

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