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.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_EXTEND_VENDOR_INFO", schema = "supplier_ms")
@ToString
public class ExtendVendorInfo implements IdentityEntity {
    @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(fetch = FetchType.LAZY)
    @JoinColumn(name = "VENDOR_GROUP_ID")
    @ToString.Exclude
    private VendorGroup group;

    /**
     * 合同序号
     */
    @Column(name = "CODE_SN")
    private int codeSequenceNumber;

    /**
     * 是否已分配指定供应商
     */
    @Column(name = "ASSIGNED_PROVIDER")
    private boolean assignedProvider;

    /**
     * 是否是预采购
     */
    @Column(name = "PRE_PURCHASE")
    private boolean prePurchase;

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

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