package com.hotwj.platform.flow.strategy;

import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 流程策略工厂
 *
 * @author shihongwei
 * @date 2026-01-25
 */
@Component
public class FlowStrategyFactory {

    private final Map<String, IFlowStrategy> strategyMap = new ConcurrentHashMap<>();

    public FlowStrategyFactory(List<IFlowStrategy> strategies) {
        for (IFlowStrategy strategy : strategies) {
            strategyMap.put(strategy.getFlowCode(), strategy);
        }
    }

    /**
     * 获取流程策略
     *
     * @param flowCode 流程编码
     * @return 策略对象
     */
    public IFlowStrategy getStrategy(String flowCode) {
        return strategyMap.get(flowCode);
    }
}
