package com.lingyue.extract.dto.response;

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

import java.util.Date;
import java.util.List;

/**
 * 来源文件响应
 * 
 * @author lingyue
 * @since 2026-01-23
 */
@Data
@Schema(description = "来源文件响应")
public class SourceFileResponse {
    
    @Schema(description = "ID")
    private String id;
    
    @Schema(description = "模板ID")
    private String templateId;
    
    @Schema(description = "文件别名")
    private String alias;
    
    @Schema(description = "文件说明")
    private String description;
    
    @Schema(description = "允许的文件类型")
    private List<String> fileTypes;
    
    @Schema(description = "是否必须")
    private Boolean required;
    
    @Schema(description = "示例文件文档ID")
    private String exampleDocumentId;
    
    @Schema(description = "显示顺序")
    private Integer displayOrder;
    
    @Schema(description = "创建时间")
    private Date createTime;
    
    // ==================== 统计信息 ====================
    
    @Schema(description = "关联的变量数量")
    private Integer variableCount;
    
    /**
     * 从实体转换
     */
    public static SourceFileResponse fromEntity(SourceFile sourceFile) {
        SourceFileResponse response = new SourceFileResponse();
        response.setId(sourceFile.getId());
        response.setTemplateId(sourceFile.getTemplateId());
        response.setAlias(sourceFile.getAlias());
        response.setDescription(sourceFile.getDescription());
        response.setFileTypes(sourceFile.getFileTypes());
        response.setRequired(sourceFile.getRequired());
        response.setExampleDocumentId(sourceFile.getExampleDocumentId());
        response.setDisplayOrder(sourceFile.getDisplayOrder());
        response.setCreateTime(sourceFile.getCreateTime());
        return response;
    }
}
