package com.jianshui.invoice.factory;

import com.jianshui.invoice.service.IInvoiceRequestService;
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 10:43
 **/
@Service
public class IInvoiceRequestFactory {

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


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

        return requestService;
    }
}
