package com.ecep.contract.model;

import java.io.Serializable;
import java.util.Objects;

import com.ecep.contract.util.HibernateProxyUtils;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToOne;
import jakarta.persistence.PrimaryKeyJoinColumn;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * 客户评估表数据
 * <p>
 * <p>
 * 注意：字段不能使用 primitive type，否则自动转换时会出现 Null Value 问题
 */

@Entity
@Getter
@Setter
@ToString
@Table(name = "COMPANY_CUSTOMER_EVALUATION_FORM_FILE")
public class CompanyCustomerEvaluationFormFile implements IdentityEntity, BasedEntity, Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "ID", nullable = false)
    private Integer id;

    @PrimaryKeyJoinColumn
    @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    private CompanyCustomerFile customerFile;

    /**
     * 经济指标分类
     */
    @Column(name = "CATALOG")
    private String catalog;
    /**
     * 综合指标
     */
    @Column(name = "LEVEL")
    private String level;
    /**
     * 资信等级
     */
    @Column(name = "CREDIT_LEVEL")
    private Integer creditLevel = 0;

    private Integer score1 = 0;
    private Integer score2 = 0;
    private Integer score3 = 0;
    private Integer score4 = 0;
    private Integer score5 = 0;
    /**
     * 分数模板版本
     */
    @Column(name = "SCORE_TEMPLATE_VER")
    private Integer scoreTemplateVersion = 1;

    @Override
    public String toPrettyString() {
        return getCatalog() + ", level=" + getCreditLevel();
    }

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

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