package com.agent.management.model.vo;

import com.agent.management.model.entity.Workflow;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 工作流列表 VO（含标签）
 */
@Data
public class WorkflowVO {

    private Long id;
    /** kebab-case 唯一标识，对外暴露 */
    private String name;
    /** 中文显示名 */
    private String displayName;
    private String description;
    private String graphData;
    /**
     * 运行模式：DAG（按画布拓扑）/ AGENTIC（AI 自主决策）。
     * 旧数据未设置时默认 "DAG"。对应设计文档 docs/plans/agentic-workflow-plan.md §1.1。
     */
    private String mode;
    private Long categoryId;
    private String categoryName;
    private LocalDateTime createdAt;
    private LocalDateTime updatedAt;

    /**
     * 关联的标签列表
     */
    private List<TagBriefVO> tags;

    public static WorkflowVO from(Workflow wf) {
        WorkflowVO vo = new WorkflowVO();
        vo.setId(wf.getId());
        vo.setName(wf.getName());
        vo.setDisplayName(wf.getDisplayName());
        vo.setDescription(wf.getDescription());
        vo.setGraphData(wf.getGraphData());
        vo.setMode(wf.getMode() != null ? wf.getMode() : "DAG");
        vo.setCategoryId(wf.getCategoryId());
        vo.setCreatedAt(wf.getCreatedAt());
        vo.setUpdatedAt(wf.getUpdatedAt());
        return vo;
    }
}
