/**
 * @ProjectName: 智慧评标-主观分助手
 * @Package: com.zhpb.gdyd_zhpb_zgf.entity.mysql
 * @ClassName: PromptTemplate
 * @Description: 提示词模板实体类，映射t_prompt_template表，存储智能问答的提示词配置
 * @Author: 张志锋
 * @Date: 2025-11-03
 * @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_prompt_template")
@Data
public class PromptTemplate {

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

    /**
     * 模板ID（业务ID，唯一）
     */
    @Column(name = "template_id", unique = true, nullable = false, length = 64)
    private String templateId;

    /**
     * 模板名称
     */
    @Column(name = "template_name", nullable = false, length = 256)
    private String templateName;

    /**
     * 模板类型（qa-智能问答, summary-摘要, etc）
     */
    @Column(name = "template_type", nullable = false, length = 32)
    private String templateType = "qa";

    /**
     * 提示词内容
     */
    @Column(name = "prompt_content", nullable = false, columnDefinition = "TEXT")
    private String promptContent;

    /**
     * 模板描述
     */
    @Column(name = "description", columnDefinition = "TEXT")
    private String description;

    /**
     * 是否启用
     */
    @Column(name = "is_active", nullable = false)
    private Boolean isActive = true;

    /**
     * 排序号
     */
    @Column(name = "sort_order", nullable = false)
    private Integer sortOrder = 0;

    /**
     * 创建人
     */
    @Column(name = "created_by", length = 64)
    private String createdBy;

    /**
     * 更新人
     */
    @Column(name = "updated_by", length = 64)
    private String updatedBy;

    /**
     * 创建时间
     */
    @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();
        if (this.templateId == null) {
            this.templateId = java.util.UUID.randomUUID().toString().replace("-", "");
        }
    }

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