package com.ff.base.utils;

import com.ff.base.constant.Constants;
import com.ff.base.datasource.DynamicDataSourceContextHolder;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * 持有Utils
 *
 * @author shi
 * @date 2024/12/10
 */
public class TenantUtils {



    /**
     * 获取租户id redis
     *
     * @return {@link String }
     */
    public static String getTenantIdRedis(String key) {
        String dataSourceType = DynamicDataSourceContextHolder.getDataSourceType();
        dataSourceType = StringUtils.hasText(dataSourceType) ? dataSourceType : Constants.DATA_SOURCE;
        return dataSourceType.toLowerCase()+":"+key;

    }
}
