package nckd.jxccl.swc.hcdm.servicehelper;

import kd.bos.dataentity.TypesContainer;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

/**
* 薪酬微服务工厂类
* @author W.Y.C
* @date 2026/1/7 21:37
* @version 1.0
*/
public class ServiceFactory {

    private static final Map<String, String> SERVICE_MAP = new HashMap<String, String>() {
        {
            this.put("ISwcService", "nckd.jxccl.swc.hcdm.mservice.SwcService");
        }
    };

    public static <T> T getService(Class<T> clazz) {
        return (T)getService(clazz.getSimpleName());
    }

    public static Object getService(String serviceName) {
        String className = (String)SERVICE_MAP.get(serviceName);
        if (className == null) {
            throw new RuntimeException(String.format(Locale.ROOT, "%s service not find", serviceName));
        } else {
            return TypesContainer.getOrRegisterSingletonInstance(className);
        }
    }
}