package com.qiaoba.common.database.properties;

import com.qiaoba.common.base.constant.BaseConstant;
import org.springframework.stereotype.Component;

/**
 * 租户Schema
 *
 * @author ailanyin
 * @version 1.0
 * @since 2023/6/29 8:53
 */
@Component
public class TenantSchema {


    private static String schemaPrefix;

    public static void setSchemaPrefix(String name) {
        schemaPrefix = name;
    }

    /**
     * 租户schema生成逻辑
     * schemaPrefix + '-' + tenantId
     * eg: schema = abc-2
     *
     * @param tenantId 租户ID
     * @return schema
     */
    public static String getSchema(String tenantId) {
        return schemaPrefix + BaseConstant.HYPHEN_JOIN_STR + tenantId;
    }

}
