package com.rj.dto;

import com.alibaba.fastjson.JSONObject;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
 * Dify工作流响应DTO
 * 
 * @author 李中华
 * @date 2025/1/3
 */
@Data
@Schema(description = "Dify企微对话分析工作流响应结果")
public class DifyWorkflowResponseDto {

    @Schema(description = "是否成功", example = "true")
    private Boolean success;

    @Schema(description = "响应消息", example = "工作流调用成功")
    private String message;

    @Schema(description = "工作流运行ID", example = "workflow_run_12345")
    private String workflowRunId;

    @Schema(description = "任务ID", example = "task_67890")
    private String taskId;

    @Schema(description = "工作流响应数据")
    private JSONObject data;

    @Schema(description = "元数据")
    private JSONObject metadata;

    @Schema(description = "错误类型（仅在失败时返回）", example = "RuntimeException")
    private String error;

    /**
     * 创建成功响应
     */
    public static DifyWorkflowResponseDto success(String workflowRunId, String taskId, JSONObject data, JSONObject metadata) {
        DifyWorkflowResponseDto response = new DifyWorkflowResponseDto();
        response.setSuccess(true);
        response.setMessage("工作流调用成功");
        response.setWorkflowRunId(workflowRunId);
        response.setTaskId(taskId);
        response.setData(data);
        response.setMetadata(metadata);
        return response;
    }


    /**
     * 创建失败响应
     */
    public static DifyWorkflowResponseDto failure(String message, String error) {
        DifyWorkflowResponseDto response = new DifyWorkflowResponseDto();
        response.setSuccess(false);
        response.setMessage(message);
        response.setError(error);
        return response;
    }
}









































































































