package com.lingyue.extract.dto.response;

import com.lingyue.extract.entity.SourceDocument;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

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

/**
 * 来源文档响应
 * 
 * @author lingyue
 * @since 2026-01-22
 */
@Data
@Schema(description = "来源文档响应")
public class SourceDocumentResponse {
    
    @Schema(description = "来源文档ID")
    private String id;
    
    @Schema(description = "项目ID")
    private String projectId;
    
    @Schema(description = "关联的 Document ID")
    private String documentId;
    
    @Schema(description = "文档别名")
    private String alias;
    
    @Schema(description = "文档类型")
    private String docType;
    
    @Schema(description = "显示顺序")
    private Integer displayOrder;
    
    @Schema(description = "元数据")
    private Map<String, Object> metadata;
    
    @Schema(description = "创建时间")
    private Date createTime;
    
    // ==================== 关联的 Document 信息 ====================
    
    @Schema(description = "原始文档名称")
    private String originalFileName;
    
    @Schema(description = "文档解析状态")
    private String parseStatus;
    
    @Schema(description = "文档大小（字节）")
    private Long fileSize;
    
    /**
     * 从实体转换
     */
    public static SourceDocumentResponse fromEntity(SourceDocument sourceDocument) {
        SourceDocumentResponse response = new SourceDocumentResponse();
        response.setId(sourceDocument.getId());
        response.setProjectId(sourceDocument.getProjectId());
        response.setDocumentId(sourceDocument.getDocumentId());
        response.setAlias(sourceDocument.getAlias());
        response.setDocType(sourceDocument.getDocType());
        response.setDisplayOrder(sourceDocument.getDisplayOrder());
        response.setMetadata(sourceDocument.getMetadata());
        response.setCreateTime(sourceDocument.getCreateTime());
        return response;
    }
}
