/**
 * @ProjectName: 智慧评标-主观分助手
 * @Package: com.zhpb.gdyd_zhpb_zgf.entity.mysql
 * @ClassName: Supplier
 * @Description: 供应商实体类，映射t_supplier表，存储供应商基本信息
 * @Author: 张志锋
 * @Date: 2025-11-01
 * @Version: 1.0
 * @Copyright: © 2025 智慧评标-主观分助手
 */
package com.zhpb.gdyd_zhpb_zgf.entity.mysql;

import jakarta.persistence.*;
import lombok.Data;
import java.time.LocalDateTime;

/**
 * 供应商实体类
 */
@Entity
@Table(name = "t_supplier")
@Data
public class Supplier {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 供应商ID（业务ID，唯一）
     */
    @Column(name = "supplier_id", unique = true, nullable = false, length = 64)
    private String supplierId;

    /**
     * 供应商名称
     */
    @Column(name = "supplier_name", nullable = false, length = 256)
    private String supplierName;

    /**
     * 供应商代码
     */
    @Column(name = "supplier_code", length = 128)
    private String supplierCode;

    /**
     * 供应商类型
     */
    @Column(name = "supplier_type", length = 64)
    private String supplierType;

    /**
     * 联系人
     */
    @Column(name = "contact_person", length = 128)
    private String contactPerson;

    /**
     * 联系电话
     */
    @Column(name = "contact_phone", length = 64)
    private String contactPhone;

    /**
     * 联系邮箱
     */
    @Column(name = "contact_email", length = 128)
    private String contactEmail;

    /**
     * 供应商地址
     */
    @Column(name = "address", columnDefinition = "TEXT")
    private String address;

    /**
     * 供应商状态（active, inactive等）
     */
    @Column(name = "status", length = 32)
    private String status;

    /**
     * 备注
     */
    @Column(name = "remarks", columnDefinition = "TEXT")
    private String remarks;

    /**
     * 创建时间
     */
    @Column(name = "create_time", nullable = false)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @Column(name = "update_time")
    private LocalDateTime updateTime;

    @PrePersist
    public void prePersist() {
        this.createTime = LocalDateTime.now();
        this.updateTime = LocalDateTime.now();
    }

    @PreUpdate
    public void preUpdate() {
        this.updateTime = LocalDateTime.now();
    }
}

