package com.lingyue.graph.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

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

/**
 * 节点值项
 * 表示从单个节点获取的值
 * 
 * @author lingyue
 * @since 2026-01-21
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "节点值项")
public class NodeValueItem {
    
    @Schema(description = "节点引用类型", example = "graph_node/document_element")
    private String refType;
    
    @Schema(description = "节点ID")
    private String nodeId;
    
    @Schema(description = "值类型", example = "text/image/table")
    private String valueType;
    
    @Schema(description = "文本值")
    private String textValue;
    
    @Schema(description = "图片URL")
    private String imageUrl;
    
    @Schema(description = "图片路径")
    private String imagePath;
    
    @Schema(description = "表格数据")
    private List<List<Map<String, Object>>> tableData;
    
    @Schema(description = "原始节点名称")
    private String nodeName;
    
    @Schema(description = "原始节点类型")
    private String nodeType;
    
    /**
     * 创建文本值项
     */
    public static NodeValueItem text(String refType, String nodeId, String value, String nodeName) {
        return NodeValueItem.builder()
                .refType(refType)
                .nodeId(nodeId)
                .valueType("text")
                .textValue(value)
                .nodeName(nodeName)
                .build();
    }
    
    /**
     * 创建图片值项
     */
    public static NodeValueItem image(String refType, String nodeId, String imageUrl, String imagePath, String nodeName) {
        return NodeValueItem.builder()
                .refType(refType)
                .nodeId(nodeId)
                .valueType("image")
                .imageUrl(imageUrl)
                .imagePath(imagePath)
                .nodeName(nodeName)
                .build();
    }
    
    /**
     * 创建表格值项
     */
    public static NodeValueItem table(String refType, String nodeId, List<List<Map<String, Object>>> tableData, String nodeName) {
        return NodeValueItem.builder()
                .refType(refType)
                .nodeId(nodeId)
                .valueType("table")
                .tableData(tableData)
                .nodeName(nodeName)
                .build();
    }
}
