package com.jianshui.invoice.factory;

import com.jianshui.invoice.service.IInvoiceApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

/**
 * @Description 进项服务工厂类
 * @Author 巩权林
 * @Date 2022-03-25 14:57
 **/
@Service
public class IInvoiceServiceFactory {

    @Autowired
    private final Map<String, IInvoiceApiService> services = new ConcurrentHashMap<>();


    public IInvoiceApiService getService(String key) {
        IInvoiceApiService requestService = services.get(key);
        if (requestService == null) {
            throw new RuntimeException("未定义的请求方式 " + key);
        }

        return requestService;
    }
}
