package com.lingyue.extract.dto.response;

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

/**
 * 变量预览提取响应
 * 
 * @author lingyue
 * @since 2026-01-24
 */
@Data
@Schema(description = "变量预览提取响应")
public class VariablePreviewResponse {
    
    @Schema(description = "变量ID")
    private String variableId;
    
    @Schema(description = "变量名")
    private String variableName;
    
    @Schema(description = "提取的值")
    private String extractedValue;
    
    @Schema(description = "置信度 0-1")
    private Double confidence;
    
    @Schema(description = "来源预览文本")
    private String sourcePreview;
    
    @Schema(description = "来源位置描述")
    private String sourceLocation;
    
    @Schema(description = "是否成功")
    private Boolean success;
    
    @Schema(description = "错误信息")
    private String errorMessage;
    
    public static VariablePreviewResponse success(String variableId, String variableName, 
                                                    String value, Double confidence, String sourcePreview) {
        VariablePreviewResponse response = new VariablePreviewResponse();
        response.setVariableId(variableId);
        response.setVariableName(variableName);
        response.setExtractedValue(value);
        response.setConfidence(confidence);
        response.setSourcePreview(sourcePreview);
        response.setSuccess(true);
        return response;
    }
    
    public static VariablePreviewResponse error(String variableId, String variableName, String errorMessage) {
        VariablePreviewResponse response = new VariablePreviewResponse();
        response.setVariableId(variableId);
        response.setVariableName(variableName);
        response.setSuccess(false);
        response.setErrorMessage(errorMessage);
        return response;
    }
}
