package com.fs.company.service.impl.call.node;

import com.fs.company.service.IWorkflowNode;
import com.fs.company.service.IWorkflowNodeFactory;
import com.fs.enums.NodeTypeEnum;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author MixLiu
 * @date 2026/1/28 11:07
 * @description 工厂实现
 */
@Component
public class WorkflowNodeFactory implements IWorkflowNodeFactory {

    @Override
    public IWorkflowNode createNode(String nodeKey, NodeTypeEnum type, String nodeName,
                                    Map<String, Object> properties) {
        IWorkflowNode node = null;
        switch (type) {
            case START:
                node = new StartNode(nodeKey, nodeName, properties);
                break;
            case CONDITION:
                node = new ConditionNode(nodeKey, nodeName, properties);
                break;
            case END:
                node = new EndNode(nodeKey, nodeName, properties);
                break;
            case AI_CALL_TASK:
                node = new AiCallTaskNode(nodeKey, nodeName, properties);
                break;
            case AI_SEND_MSG_TASK:
                node = new AiSendMsgTaskNode(nodeKey, nodeName, properties);
                break;
            case AI_ADD_WX_TASK:
                node = new AiAddWxTaskNode(nodeKey, nodeName, properties);
                break;
            case AI_QW_ADD_WX_TASK:
                node = new AiQwAddWxTaskNode(nodeKey, nodeName, properties);
                break;
            case OUTBOUND_TASK:
                node = new OutBoundTaskNode(nodeKey, nodeName, properties);
                break;
            case DELAY:
                node = new DelayNode(nodeKey, nodeName, properties);
                break;
            default:
                throw new IllegalArgumentException("Unsupported node type: " + type);
        }
        return node;
    }
}
