mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-24 07:19:46 +08:00
!286 合并 多租户功能
* add 新增 ruoyi-common-tenant 多租户模块 全框架适配多租户改动 * update 优化 隐藏页面主键 * remove 移除 缓存列表功能(多租户缓存功能繁杂多样 没有办法在页面管理) * update 重构 全局缓存KEY 与 常用缓存KEY做区分 * update 重构 OssFactory 加载方式 改为每次比对配置做实例更新 * update 优化 SaTokenDao 改为 Bean 注入 便于扩展 * update 重构 项目初始化数据改为懒加载 不提供热加载 * update 重构 验证码开关使用配置文件(经调查少有动态开启需求) * update 优化 启用 sqlserver 高版本语法 简化sql脚本语法 * update 优化 DataPermissionHelper 增加 开启/关闭 忽略数据权限功能 * update 优化 连接池增加 keepaliveTime 探活参数 * update 优化 调整连接池最长生命周期 防止出现警告 * update 优化 代码生成页面模板 校验不必要的表单数据 * add 新增 StringUtils splitTo 与 splitList 方法 优化业务代码
This commit is contained in:
@ -1,41 +0,0 @@
|
||||
package com.ruoyi.common.mybatis.core.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Tree基类
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class TreeEntity<T> extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 父菜单名称
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String parentName;
|
||||
|
||||
/**
|
||||
* 父菜单ID
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 子部门
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<T> children = new ArrayList<>();
|
||||
|
||||
}
|
@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.*;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ReflectionKit;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.toolkit.Db;
|
||||
import com.ruoyi.common.core.utils.BeanCopyUtils;
|
||||
@ -17,6 +17,9 @@ import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 自定义 Mapper 接口, 实现 自定义扩展
|
||||
@ -193,4 +196,8 @@ public interface BaseMapperPlus<M, T, V> extends BaseMapper<T> {
|
||||
return (P) voPage;
|
||||
}
|
||||
|
||||
default <C> List<C> selectObjs(Wrapper<T> wrapper, Function<? super Object, C> mapper) {
|
||||
return this.selectObjs(wrapper).stream().filter(Objects::nonNull).map(mapper).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -89,8 +89,8 @@ public class PageQuery implements Serializable {
|
||||
// 兼容前端排序类型
|
||||
isAsc = StringUtils.replaceEach(isAsc, new String[]{"ascending", "descending"}, new String[]{"asc", "desc"});
|
||||
|
||||
String[] orderByArr = orderBy.split(",");
|
||||
String[] isAscArr = isAsc.split(",");
|
||||
String[] orderByArr = orderBy.split(StringUtils.SEPARATOR);
|
||||
String[] isAscArr = isAsc.split(StringUtils.SEPARATOR);
|
||||
if (isAscArr.length != 1 && isAscArr.length != orderByArr.length) {
|
||||
throw new ServiceException("排序参数有误");
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.ruoyi.common.mybatis.helper;
|
||||
package com.ruoyi.common.mybatis.handler;
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import lombok.extern.slf4j.Slf4j;
|
@ -35,7 +35,6 @@ import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 数据权限过滤
|
||||
@ -79,7 +78,7 @@ public class PlusDataPermissionHandler {
|
||||
DataPermissionHelper.setVariable("user", currentUser);
|
||||
}
|
||||
// 如果是超级管理员,则不过滤数据
|
||||
if (LoginHelper.isAdmin()) {
|
||||
if (LoginHelper.isSuperAdmin()) {
|
||||
return where;
|
||||
}
|
||||
String dataFilterSql = buildDataFilter(dataColumns, isSelect);
|
||||
|
@ -3,6 +3,8 @@ package com.ruoyi.common.mybatis.helper;
|
||||
import cn.dev33.satoken.context.SaHolder;
|
||||
import cn.dev33.satoken.context.model.SaStorage;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.plugins.IgnoreStrategy;
|
||||
import com.baomidou.mybatisplus.core.plugins.InterceptorIgnoreHelper;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@ -44,4 +46,19 @@ public class DataPermissionHelper {
|
||||
}
|
||||
throw new NullPointerException("data permission context type exception");
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启忽略数据权限(开启后需手动调用 {@link #disableIgnore()} 关闭)
|
||||
*/
|
||||
public static void enableIgnore() {
|
||||
InterceptorIgnoreHelper.handle(IgnoreStrategy.builder().dataPermission(true).build());
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭忽略数据权限
|
||||
*/
|
||||
public static void disableIgnore() {
|
||||
InterceptorIgnoreHelper.clearIgnoreStrategy();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user