Merge remote-tracking branch 'origin/dev' into warm-flow-future
This commit is contained in:
commit
a3ab410d7b
@ -320,4 +320,21 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不区分大小写检查 CharSequence 是否以指定的前缀开头。
|
||||||
|
*
|
||||||
|
* @param str 要检查的 CharSequence 可能为 null
|
||||||
|
* @param prefixs 要查找的前缀可能为 null
|
||||||
|
* @return 是否包含
|
||||||
|
*/
|
||||||
|
public static boolean startWithAnyIgnoreCase(CharSequence str, CharSequence... prefixs) {
|
||||||
|
// 判断是否是以指定字符串开头
|
||||||
|
for (CharSequence prefix : prefixs) {
|
||||||
|
if (StringUtils.startsWithIgnoreCase(str, prefix)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,10 @@ public class PlusDataPermissionHandler {
|
|||||||
if (!StringUtils.containsAny(type.getSqlTemplate(), keys.toArray(String[]::new))) {
|
if (!StringUtils.containsAny(type.getSqlTemplate(), keys.toArray(String[]::new))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// 当前注解不满足模板 不处理
|
||||||
|
if (!StringUtils.containsAny(type.getSqlTemplate(), dataColumn.key())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// 忽略数据权限 防止spel表达式内有其他sql查询导致死循环调用
|
// 忽略数据权限 防止spel表达式内有其他sql查询导致死循环调用
|
||||||
String sql = DataPermissionHelper.ignore(() ->
|
String sql = DataPermissionHelper.ignore(() ->
|
||||||
parser.parseExpression(type.getSqlTemplate(), parserContext).getValue(context, String.class)
|
parser.parseExpression(type.getSqlTemplate(), parserContext).getValue(context, String.class)
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package org.dromara.common.tenant.helper;
|
package org.dromara.common.tenant.helper;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.context.SaHolder;
|
||||||
|
import cn.dev33.satoken.context.model.SaStorage;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.baomidou.mybatisplus.core.plugins.IgnoreStrategy;
|
import com.baomidou.mybatisplus.core.plugins.IgnoreStrategy;
|
||||||
import com.baomidou.mybatisplus.core.plugins.InterceptorIgnoreHelper;
|
import com.baomidou.mybatisplus.core.plugins.InterceptorIgnoreHelper;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.dromara.common.core.constant.GlobalConstants;
|
import org.dromara.common.core.constant.GlobalConstants;
|
||||||
import org.dromara.common.core.utils.ServletUtils;
|
|
||||||
import org.dromara.common.core.utils.SpringUtils;
|
import org.dromara.common.core.utils.SpringUtils;
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
import org.dromara.common.core.utils.reflect.ReflectUtils;
|
import org.dromara.common.core.utils.reflect.ReflectUtils;
|
||||||
@ -137,7 +137,7 @@ public class TenantHelper {
|
|||||||
}
|
}
|
||||||
String cacheKey = DYNAMIC_TENANT_KEY + ":" + LoginHelper.getUserId();
|
String cacheKey = DYNAMIC_TENANT_KEY + ":" + LoginHelper.getUserId();
|
||||||
RedisUtils.setCacheObject(cacheKey, tenantId);
|
RedisUtils.setCacheObject(cacheKey, tenantId);
|
||||||
ServletUtils.getRequest().setAttribute(cacheKey, tenantId);
|
SaHolder.getStorage().set(cacheKey, tenantId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -157,15 +157,15 @@ public class TenantHelper {
|
|||||||
if (StringUtils.isNotBlank(tenantId)) {
|
if (StringUtils.isNotBlank(tenantId)) {
|
||||||
return tenantId;
|
return tenantId;
|
||||||
}
|
}
|
||||||
HttpServletRequest request = ServletUtils.getRequest();
|
SaStorage storage = SaHolder.getStorage();
|
||||||
String cacheKey = DYNAMIC_TENANT_KEY + ":" + LoginHelper.getUserId();
|
String cacheKey = DYNAMIC_TENANT_KEY + ":" + LoginHelper.getUserId();
|
||||||
tenantId = (String) request.getAttribute(cacheKey);
|
tenantId = storage.getString(cacheKey);
|
||||||
// 如果为 -1 说明已经查过redis并且不存在值 则直接返回null
|
// 如果为 -1 说明已经查过redis并且不存在值 则直接返回null
|
||||||
if (StringUtils.isNotBlank(tenantId)) {
|
if (StringUtils.isNotBlank(tenantId)) {
|
||||||
return tenantId.equals("-1") ? null : tenantId;
|
return tenantId.equals("-1") ? null : tenantId;
|
||||||
}
|
}
|
||||||
tenantId = RedisUtils.getCacheObject(cacheKey);
|
tenantId = RedisUtils.getCacheObject(cacheKey);
|
||||||
request.setAttribute(cacheKey, StringUtils.isBlank(tenantId) ? "-1" : tenantId);
|
storage.set(cacheKey, StringUtils.isBlank(tenantId) ? "-1" : tenantId);
|
||||||
return tenantId;
|
return tenantId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ public class TenantHelper {
|
|||||||
TEMP_DYNAMIC_TENANT.remove();
|
TEMP_DYNAMIC_TENANT.remove();
|
||||||
String cacheKey = DYNAMIC_TENANT_KEY + ":" + LoginHelper.getUserId();
|
String cacheKey = DYNAMIC_TENANT_KEY + ":" + LoginHelper.getUserId();
|
||||||
RedisUtils.deleteObject(cacheKey);
|
RedisUtils.deleteObject(cacheKey);
|
||||||
ServletUtils.getRequest().removeAttribute(cacheKey);
|
SaHolder.getStorage().delete(cacheKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -137,7 +137,7 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||||||
}
|
}
|
||||||
// 过滤并转换表格数据
|
// 过滤并转换表格数据
|
||||||
List<GenTable> tables = tablesMap.values().stream()
|
List<GenTable> tables = tablesMap.values().stream()
|
||||||
.filter(x -> !startWithAnyIgnoreCase(x.getName(), TABLE_IGNORE))
|
.filter(x -> !StringUtils.startWithAnyIgnoreCase(x.getName(), TABLE_IGNORE))
|
||||||
.filter(x -> {
|
.filter(x -> {
|
||||||
if (CollUtil.isEmpty(tableNames)) {
|
if (CollUtil.isEmpty(tableNames)) {
|
||||||
return true;
|
return true;
|
||||||
@ -176,16 +176,6 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||||||
return TableDataInfo.build(page);
|
return TableDataInfo.build(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean startWithAnyIgnoreCase(CharSequence cs, CharSequence... searchCharSequences) {
|
|
||||||
// 判断是否是以指定字符串开头
|
|
||||||
for (CharSequence searchCharSequence : searchCharSequences) {
|
|
||||||
if (StringUtils.startsWithIgnoreCase(cs, searchCharSequence)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询据库列表
|
* 查询据库列表
|
||||||
*
|
*
|
||||||
@ -204,7 +194,7 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Table<?>> tableList = tablesMap.values().stream()
|
List<Table<?>> tableList = tablesMap.values().stream()
|
||||||
.filter(x -> !startWithAnyIgnoreCase(x.getName(), TABLE_IGNORE))
|
.filter(x -> !StringUtils.startWithAnyIgnoreCase(x.getName(), TABLE_IGNORE))
|
||||||
.filter(x -> tableNameSet.contains(x.getName())).toList();
|
.filter(x -> tableNameSet.contains(x.getName())).toList();
|
||||||
|
|
||||||
if (CollUtil.isEmpty(tableList)) {
|
if (CollUtil.isEmpty(tableList)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user