package com.cool.store.service.close;

import lombok.RequiredArgsConstructor;
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 2025/10/8
 */
@Service
@RequiredArgsConstructor
public class AccountCloseFactory {
    private final Map<String, AccountCloseStrategy> map = new HashMap<>();


    @Autowired
    public AccountCloseFactory(AccountCloseStrategy[] accountCloseStrategies) {
        for (AccountCloseStrategy accountCloseStrategy : accountCloseStrategies) {
            map.put(accountCloseStrategy.getSystemCode(), accountCloseStrategy);
        }
    }

    public AccountCloseStrategy getByCode(String systemCode) {
        return map.get(systemCode);
    }
}
