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.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * 比价供应商
 */
@Getter
@Setter
@Entity
@Table(name = "CONTRACT_BID_VENDOR", schema = "supplier_ms", indexes = {

})
@ToString
public class ContractBidVendor implements IdentityEntity, ContractBasedEntity, Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID", nullable = false)
    private Integer id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "CONTRACT_ID")
    @ToString.Exclude
    private Contract contract;

    @ManyToOne
    @JoinColumn(name = "COMPANY_ID")
    private Company company;

    /**
     * 供应商报价表
     * 关联到合同的文件
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "QUOTATION_SHEET_FILE_ID")
    @ToString.Exclude
    private ContractFile quotationSheet;

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

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