package com.keao.edu.common.tenant;


import org.apache.commons.lang3.StringUtils;

public class TenantContextHolder {
	

	private static final ThreadLocal<String> tenantContextHolder = new ThreadLocal<String>();

	public static void setTenantId(String tenantId) {
		tenantContextHolder.set(tenantId);
	}

	/**
	 * 获取数据源
	 * @return
	 */
	public static String getTenantId() {
		if (StringUtils.isEmpty(tenantContextHolder.get())){
			return "0";
		}
		return tenantContextHolder.get();
	}

	/**
	 * 重置数据源
	 */
	public static void clearTenantId() {
		tenantContextHolder.remove();
	}

}
