package nckd.jxccl.wtc.wtp.servicehelper;

import kd.bos.dataentity.TypesContainer;
import kd.bos.exception.KDBizException;

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

/**
 * 工事假勤规则自定义微服务工厂
 * @author: jtd
 * @date: 2026/1/11 18:28
 */
public class ServiceFactory {

    private static Map<String, String> serviceMap = new HashMap<>();

    static {
        serviceMap.put("IWTPCustomerService", "nckd.jxccl.wtc.wtp.mservice.WTPCustomerService");
    }

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

    public static Object getService(String serviceName) {
        String className = serviceMap.get(serviceName);
        if (className == null) {
            throw new KDBizException(String.format(Locale.ROOT, "未找到%s对应的服务实现。", new Object[]{serviceName}));
        }
        return TypesContainer.getOrRegisterSingletonInstance(className);
    }

}
