package com.cool.store.service.closeup.impl;

import com.cool.store.service.closeup.PlatformAutoStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 歇业平台自动开闭店工厂
 * </p>
 *
 * @author wangff
 * @since 2026/4/8
 */
@Service
public class PlatformAutoFactory {
    private final Map<String , PlatformAutoStrategy> map = new HashMap<>();

    @Autowired
    public PlatformAutoFactory(PlatformAutoStrategy[] strategies) {
        for (PlatformAutoStrategy platformAutoStrategy : strategies) {
            map.put(platformAutoStrategy.getCode(), platformAutoStrategy);
        }
    }

    public PlatformAutoStrategy getByCode(String code) {
        return map.get(code);
    }
}
