package com.lutao.cloud.common.data.tenant;

import com.lutao.cloud.common.core.constant.CommonConstants;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import lombok.extern.slf4j.Slf4j;

/**

 * @date 2018/9/14
 */
@Slf4j
public class CloudFeignTenantInterceptor implements RequestInterceptor{

	@Override
	public void apply(RequestTemplate requestTemplate){
		if (TenantContextHolder.getTenantId() == null){
			log.debug("TTL 中的 租户ID为空，feign拦截器 >> 跳过");
			return;
		}
		requestTemplate.header(CommonConstants.TENANT_ID, TenantContextHolder.getTenantId().toString());
	}

}
