|
@@ -0,0 +1,29 @@
|
|
|
+package com.ruoyi.common.datasource.context;
|
|
|
+
|
|
|
+/**
|
|
|
+ * DataScope上下文 Holder
|
|
|
+ *
|
|
|
+ * @author yq
|
|
|
+ */
|
|
|
+public class DataScopeContextHolder {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 当前租户编号
|
|
|
+ */
|
|
|
+ private static final ThreadLocal<String> DATA_SCOPE_SQL = new ThreadLocal<>();
|
|
|
+
|
|
|
+
|
|
|
+ public static String getDataScopeSql() {
|
|
|
+ return DATA_SCOPE_SQL.get();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static void setTenantId(String dataScope) {
|
|
|
+ DATA_SCOPE_SQL.set(dataScope);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void clear() {
|
|
|
+ DATA_SCOPE_SQL.remove();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|