package com.jeesharp.business.modules.member.application.support;

import com.jeesharp.business.modules.member.api.MemberPointsBizOrderProvider;
import org.springframework.stereotype.Component;

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

/**
 * 业态订单 Provider 注册表，按 bizScene 路由。
 *
 * @author jeesharp
 * @since 2026-06-24
 */
@Component
public class MemberPointsBizOrderProviderRegistry {

    private final Map<String, MemberPointsBizOrderProvider> providerMap;

    public MemberPointsBizOrderProviderRegistry(List<MemberPointsBizOrderProvider> providers) {
        this.providerMap = new HashMap<>();
        if (providers != null) {
            for (MemberPointsBizOrderProvider provider : providers) {
                providerMap.put(provider.bizScene(), provider);
            }
        }
    }

    public MemberPointsBizOrderProvider getProvider(String bizScene) {
        return providerMap.get(bizScene);
    }
}
