package com.lingyue.extract.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.Date;
import java.util.Map;

/**
 * 来源文档实体
 * 
 * 项目中用到的文档，关联已解析的 Document
 * 
 * @author lingyue
 * @since 2026-01-22
 */
@Data
@TableName(value = "extract_source_documents", autoResultMap = true)
@Schema(description = "项目来源文档")
public class SourceDocument {
    
    @Schema(description = "ID")
    @TableId
    private String id;
    
    @Schema(description = "项目ID")
    @TableField("project_id")
    private String projectId;
    
    @Schema(description = "关联的 Document ID")
    @TableField("document_id")
    private String documentId;
    
    @Schema(description = "文档别名，如'可研批复'")
    @TableField("alias")
    private String alias;
    
    @Schema(description = "文档类型: pdf/docx/xlsx")
    @TableField("doc_type")
    private String docType;
    
    @Schema(description = "显示顺序")
    @TableField("display_order")
    private Integer displayOrder;
    
    @Schema(description = "元数据")
    @TableField(value = "metadata", typeHandler = JacksonTypeHandler.class)
    private Map<String, Object> metadata;
    
    @Schema(description = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField("create_time")
    private Date createTime;
    
    // ==================== 文档类型常量 ====================
    
    public static final String DOC_TYPE_PDF = "pdf";
    public static final String DOC_TYPE_DOCX = "docx";
    public static final String DOC_TYPE_XLSX = "xlsx";
}
