package com.jianshui.income.factory;

import com.jianshui.income.service.ICheckInvoice;
import com.jianshui.income.service.IIncomeRequestService;
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 ICheckServiceFactory {

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


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

        return requestService;
    }
}
