package com.lingyue.extract.dto.response;

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

import java.util.Date;

/**
 * 模板列表项响应
 * 
 * @author lingyue
 * @since 2026-01-23
 */
@Data
@Schema(description = "模板列表项响应")
public class TemplateListResponse {
    
    @Schema(description = "模板ID")
    private String id;
    
    @Schema(description = "模板名称")
    private String name;
    
    @Schema(description = "模板描述")
    private String description;
    
    @Schema(description = "状态: draft/published/archived")
    private String status;
    
    @Schema(description = "是否公开")
    private Boolean isPublic;
    
    @Schema(description = "使用次数")
    private Integer useCount;
    
    @Schema(description = "来源文件数量")
    private Integer sourceFileCount;
    
    @Schema(description = "变量数量")
    private Integer variableCount;
    
    @Schema(description = "创建时间")
    private Date createTime;
    
    @Schema(description = "更新时间")
    private Date updateTime;
    
    /**
     * 从实体转换
     */
    public static TemplateListResponse fromEntity(Template template) {
        TemplateListResponse response = new TemplateListResponse();
        response.setId(template.getId());
        response.setName(template.getName());
        response.setDescription(template.getDescription());
        response.setStatus(template.getStatus());
        response.setIsPublic(template.getIsPublic());
        response.setUseCount(template.getUseCount());
        response.setCreateTime(template.getCreateTime());
        response.setUpdateTime(template.getUpdateTime());
        return response;
    }
}
