package com.lingyue.extract.dto.response;

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

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

/**
 * 项目详情响应
 * 
 * @author lingyue
 * @since 2026-01-22
 */
@Data
@Schema(description = "项目详情响应")
public class ProjectDetailResponse {
    
    @Schema(description = "项目ID")
    private String id;
    
    @Schema(description = "用户ID")
    private String userId;
    
    @Schema(description = "项目名称")
    private String name;
    
    @Schema(description = "项目描述")
    private String description;
    
    @Schema(description = "状态")
    private String status;
    
    @Schema(description = "项目配置")
    private Map<String, Object> config;
    
    @Schema(description = "创建时间")
    private Date createTime;
    
    @Schema(description = "更新时间")
    private Date updateTime;
    
    // ==================== 关联数据 ====================
    
    @Schema(description = "来源文档列表")
    private List<SourceDocumentResponse> sourceDocuments;
    
    @Schema(description = "来源文档数量")
    private Integer documentCount;
    
    @Schema(description = "规则数量")
    private Integer ruleCount;
    
    @Schema(description = "已完成规则数量")
    private Integer completedRuleCount;
    
    /**
     * 从实体转换
     */
    public static ProjectDetailResponse fromEntity(Project project) {
        ProjectDetailResponse response = new ProjectDetailResponse();
        response.setId(project.getId());
        response.setUserId(project.getUserId());
        response.setName(project.getName());
        response.setDescription(project.getDescription());
        response.setStatus(project.getStatus());
        response.setConfig(project.getConfig());
        response.setCreateTime(project.getCreateTime());
        response.setUpdateTime(project.getUpdateTime());
        return response;
    }
}
