package com.huatek.busi.util;

import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;

import com.huatek.busi.service.BusiSiteTreeService;

/**
 * 工具类
 * 
 * @author anker_cheng
 * @date 2019/10/16
 */
public final class SpringUtils {

    private SpringUtils() {

    }

    public static String getDefaultSiteId() {
        WebApplicationContext context = ContextLoader.getCurrentWebApplicationContext();
        if (context == null) {
            return null;
        }
        BusiSiteTreeService busiSiteTreeService = context.getBean(BusiSiteTreeService.class);
        if (busiSiteTreeService == null) {
            return null;
        }
        return busiSiteTreeService.getDefaultSiteId();
    }
}
