package com.ruoyi.framework.mybatis.holder;

import lombok.Getter;
import lombok.Setter;
import org.springframework.core.NamedThreadLocal;

/**
 * 租户线程处理
 */
@Getter
@Setter
public class LogicHolder {

    /**
     * 排除表名
     */
    private String[] tableNames;

    /**
     * 排除表别名
     */
    private String[] aliases;

    private static final ThreadLocal<LogicHolder> LOGIC_KEY_HOLDER = new NamedThreadLocal<>("saas-delFlag");

    public static void setLogicHolder(LogicHolder logicHolder) {
        LOGIC_KEY_HOLDER.set(logicHolder);
    }

    public static LogicHolder getLogicHolder() {
        return LOGIC_KEY_HOLDER.get();
    }

    public static void clear() {
        LOGIC_KEY_HOLDER.remove();
    }

}
