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;

/**
 * 销售类型
 */
@Getter
@Setter
@Entity
@Table(name = "PROJECT_SALE_TYPE")
public class ProjectSaleType 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 = "PATH")
    private String path;

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

    @Column(name = "STORE_BY_YEAR")
    private boolean storeByYear;

    /**
     * 是否启用重大项目决策（三重一大）
     */
    @Column(name = "CRITICAL_PROJECT_DECISION")
    private boolean criticalProjectDecision;

    /**
     * 符合重大项目的合同金额条件
     */
    @Column(name = "CRITICAL_PROJECT_LIMIT")
    private double criticalProjectLimit;

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

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

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