package com.ym.mec.common.tenant;


public class TenantContextHolder {
	

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

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

	/**
	 * 获取数据源
	 * @return
	 */
	public static Integer getTenantId() {
		Integer tenantId = tenantContextHolder.get();
		if (tenantId == null){
			return 0;
		}
		return tenantContextHolder.get();
	}

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

}
