update 优化 适配框架多数据库支持 完成 oracle postgres 数据库适配

(放弃 sqlserver 适配 原因: 基础中间件均不支持)
2.X
疯狂的狮子li 2 years ago
parent db5d448623
commit 77e899981a

@ -18,7 +18,7 @@
> 系统演示: [传送门](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=4836388&doc_id=1469725) 分布式集群版本(功能一致)
| 功能介绍 | 使用技术 | 文档地址 | 特性注意事项 |
|--------------|--------------------------|----------------------------------------------------------------------------------------------------|-----------------------------------|
|-----------|--------------------------|----------------------------------------------------------------------------------------------------|-----------------------------------|
| 微服务权限管理系统 | RuoYi-Cloud-Plus | [RuoYi-Cloud-Plus官网](https://gitee.com/JavaLionLi/RuoYi-Cloud-Plus) | 重写 RuoYi-Cloud 全方位升级(不兼容原框架) |
| 分布式集群分支 | RuoYi-Vue-Plus | [RuoYi-Vue-Plus官网](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus) | 重写 RuoYi-Vue (不兼容原框架) |
| Vue3分支 | RuoYi-Cloud-Plus-UI | [UI地址](https://gitee.com/JavaLionLi/RuoYi-Cloud-Plus-UI) | 由于组件还未完善 仅供学习 |
@ -29,9 +29,8 @@
| 容器框架 | Undertow | [Undertow官网](https://undertow.io/) | 基于 XNIO 的高性能容器 |
| 权限认证框架 | Sa-Token、Jwt | [Sa-Token官网](https://sa-token.dev33.cn/) | 强解耦、强扩展 |
| 关系数据库 | MySQL | [MySQL官网](https://dev.mysql.com/) | 适配 8.X 最低 5.7 |
| 关系数据库(未完成) | Oracle | [Oracle官网](https://www.oracle.com/cn/database/) | 适配 12c |
| 关系数据库(未完成) | PostgreSQL | [PostgreSQL官网](https://www.postgresql.org/) | 适配 14 |
| 关系数据库(未完成) | SQLServer | [SQLServer官网](https://docs.microsoft.com/zh-cn/sql/sql-server) | 适配 2019 |
| 关系数据库 | Oracle | [Oracle官网](https://www.oracle.com/cn/database/) | 适配 12c |
| 关系数据库 | PostgreSQL | [PostgreSQL官网](https://www.postgresql.org/) | 适配 14 |
| 缓存数据库 | Redis | [Redis官网](https://redis.io/) | 适配 6.X 最低 5.X |
| 分布式注册中心 | Alibaba Nacos | [Alibaba Nacos文档](https://nacos.io/zh-cn/docs/quick-start.html) | 采用2.X 基于GRPC通信高性能 |
| 分布式配置中心 | Alibaba Nacos | [Alibaba Nacos文档](https://nacos.io/zh-cn/docs/quick-start.html) | 采用2.X 基于GRPC通信高性能 |

@ -13,6 +13,14 @@ datasource:
url: jdbc:mysql://localhost:3306/ry-job?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&rewriteBatchedStatements=true
username: root
password: password
# system-oracle:
# url: jdbc:oracle:thin:@//localhost:1521/XE
# username: ROOT
# password: password
# system-postgres:
# url: jdbc:postgresql://localhost:5432/postgres?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
# username: root
# password: password
spring:
datasource:

@ -11,14 +11,20 @@ spring:
url: ${datasource.system-master.url}
username: ${datasource.system-master.username}
password: ${datasource.system-master.password}
# 从库数据源
#slave:
# lazy: true
# oracle:
# type: ${spring.datasource.type}
# driver-class-name:
# url:
# username:
# password:
# driverClassName: oracle.jdbc.OracleDriver
# url: ${datasource.system-oracle.url}
# username: ${datasource.system-oracle.username}
# password: ${datasource.system-oracle.password}
# hikari:
# connectionTestQuery: SELECT 1 FROM DUAL
# postgres:
# type: ${spring.datasource.type}
# driverClassName: org.postgresql.Driver
# url: ${datasource.system-postgres.url}
# username: ${datasource.system-postgres.url}
# password: ${datasource.system-postgres.url}
# 代码生成
gen:

@ -11,6 +11,20 @@ spring:
url: ${datasource.system-master.url}
username: ${datasource.system-master.username}
password: ${datasource.system-master.password}
# oracle:
# type: ${spring.datasource.type}
# driverClassName: oracle.jdbc.OracleDriver
# url: ${datasource.system-oracle.url}
# username: ${datasource.system-oracle.username}
# password: ${datasource.system-oracle.password}
# hikari:
# connectionTestQuery: SELECT 1 FROM DUAL
# postgres:
# type: ${spring.datasource.type}
# driverClassName: org.postgresql.Driver
# url: ${datasource.system-postgres.url}
# username: ${datasource.system-postgres.url}
# password: ${datasource.system-postgres.url}
mail:
enabled: false

@ -11,10 +11,17 @@ spring:
url: ${datasource.system-master.url}
username: ${datasource.system-master.username}
password: ${datasource.system-master.password}
# 从库数据源
# slave:
# oracle:
# type: ${spring.datasource.type}
# driver-class-name:
# url:
# username:
# password:
# driverClassName: oracle.jdbc.OracleDriver
# url: ${datasource.system-oracle.url}
# username: ${datasource.system-oracle.username}
# password: ${datasource.system-oracle.password}
# hikari:
# connectionTestQuery: SELECT 1 FROM DUAL
# postgres:
# type: ${spring.datasource.type}
# driverClassName: org.postgresql.Driver
# url: ${datasource.system-postgres.url}
# username: ${datasource.system-postgres.url}
# password: ${datasource.system-postgres.url}

@ -50,6 +50,21 @@
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
<!-- Oracle -->
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
</dependency>
<!-- PostgreSql -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<!-- SqlServer -->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</dependency>
</dependencies>
</project>

@ -41,10 +41,25 @@ spring:
datasource:
# 主库数据源
master:
type: ${spring.datasource.type}
driver-class-name: com.mysql.cj.jdbc.Driver
url: ${datasource.system-master.url}
username: ${datasource.system-master.username}
password: ${datasource.system-master.password}
# oracle:
# type: ${spring.datasource.type}
# driverClassName: oracle.jdbc.OracleDriver
# url: ${datasource.system-oracle.url}
# username: ${datasource.system-oracle.username}
# password: ${datasource.system-oracle.password}
# hikari:
# connectionTestQuery: SELECT 1 FROM DUAL
# postgres:
# type: ${spring.datasource.type}
# driverClassName: org.postgresql.Driver
# url: ${datasource.system-postgres.url}
# username: ${datasource.system-postgres.url}
# password: ${datasource.system-postgres.url}
--- # elasticsearch 功能配置
# 文档地址: https://www.easy-es.cn/

@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.core.utils.StreamUtils;
import com.ruoyi.common.mybatis.helper.DataBaseHelper;
import com.ruoyi.system.api.RemoteDataScopeService;
import com.ruoyi.system.api.domain.SysDept;
import com.ruoyi.system.domain.SysRoleDept;
@ -47,7 +48,7 @@ public class RemoteDataScopeServiceImpl implements RemoteDataScopeService {
public String getDeptAndChild(Long deptId) {
List<SysDept> deptList = deptMapper.selectList(new LambdaQueryWrapper<SysDept>()
.select(SysDept::getDeptId)
.apply("find_in_set({0},ancestors) <> 0", deptId));
.apply(DataBaseHelper.findInSet(deptId, "ancestors")));
List<Long> ids = StreamUtils.toList(deptList, SysDept::getDeptId);
ids.add(deptId);
List<SysDept> list = deptMapper.selectList(new LambdaQueryWrapper<SysDept>()

@ -10,6 +10,7 @@ import com.ruoyi.common.core.constant.UserConstants;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.TreeBuildUtils;
import com.ruoyi.common.mybatis.helper.DataBaseHelper;
import com.ruoyi.common.satoken.utils.LoginHelper;
import com.ruoyi.system.api.domain.SysDept;
import com.ruoyi.system.api.domain.SysRole;
@ -124,7 +125,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
public long selectNormalChildrenDeptById(Long deptId) {
return baseMapper.selectCount(new LambdaQueryWrapper<SysDept>()
.eq(SysDept::getStatus, UserConstants.DEPT_NORMAL)
.apply("find_in_set({0}, ancestors) <> 0", deptId));
.apply(DataBaseHelper.findInSet(deptId, "ancestors")));
}
/**
@ -250,7 +251,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
*/
public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) {
List<SysDept> children = baseMapper.selectList(new LambdaQueryWrapper<SysDept>()
.apply("find_in_set({0},ancestors) <> 0", deptId));
.apply(DataBaseHelper.findInSet(deptId, "ancestors")));
List<SysDept> list = new ArrayList<>();
for (SysDept child : children) {
SysDept dept = new SysDept();

@ -15,6 +15,7 @@ import com.ruoyi.common.core.utils.StreamUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.mybatis.core.page.PageQuery;
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
import com.ruoyi.common.mybatis.helper.DataBaseHelper;
import com.ruoyi.common.satoken.utils.LoginHelper;
import com.ruoyi.system.api.domain.SysDept;
import com.ruoyi.system.api.domain.SysRole;
@ -82,7 +83,7 @@ public class SysUserServiceImpl implements ISysUserService {
.and(ObjectUtil.isNotNull(user.getDeptId()), w -> {
List<SysDept> deptList = deptMapper.selectList(new LambdaQueryWrapper<SysDept>()
.select(SysDept::getDeptId)
.apply("find_in_set({0},ancestors) <> 0", user.getDeptId()));
.apply(DataBaseHelper.findInSet(user.getDeptId(), "ancestors")));
List<Long> ids = StreamUtils.toList(deptList, SysDept::getDeptId);
ids.add(user.getDeptId());
w.in("u.dept_id", ids);

Loading…
Cancel
Save