package com.lingyue.extract.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.lingyue.common.domain.entity.SimpleModel;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Map;

/**
 * 报告模板实体
 * 
 * 基于真实报告创建的模板，包含变量定义和来源文件配置
 * 用户上传示例报告，标记变量，保存为模板后可用于生成新报告
 * 
 * @author lingyue
 * @since 2026-01-23
 */
@EqualsAndHashCode(callSuper = true)
@Data
@TableName(value = "templates", autoResultMap = true)
@Schema(description = "报告模板")
public class Template extends SimpleModel {
    
    @Schema(description = "用户ID")
    @TableField("user_id")
    private String userId;
    
    @Schema(description = "模板名称")
    @TableField("name")
    private String name;
    
    @Schema(description = "模板描述")
    @TableField("description")
    private String description;
    
    @Schema(description = "示例报告文档ID，关联 documents 表")
    @TableField("base_document_id")
    private String baseDocumentId;
    
    @Schema(description = "状态: draft-草稿, published-已发布, archived-已归档")
    @TableField("status")
    private String status;
    
    @Schema(description = "模板配置")
    @TableField(value = "config", typeHandler = JacksonTypeHandler.class)
    private Map<String, Object> config;
    
    @Schema(description = "是否公开")
    @TableField("is_public")
    private Boolean isPublic;
    
    @Schema(description = "使用次数")
    @TableField("use_count")
    private Integer useCount;
    
    // ==================== 状态常量 ====================
    
    public static final String STATUS_DRAFT = "draft";
    public static final String STATUS_PUBLISHED = "published";
    public static final String STATUS_ARCHIVED = "archived";
}
