Przeglądaj źródła

update 优化 适配框架多数据库支持 完成 oracle postgres 数据库适配
(放弃 sqlserver 适配 原因: 基础中间件均不支持)

疯狂的狮子li 3 lat temu
rodzic
commit
77e899981a

+ 49 - 50
README.md

@@ -17,56 +17,55 @@
 
 > 系统演示: [传送门](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)                                           | 由于组件还未完善 仅供学习                     |
-| 前端开发框架       | Vue、Element UI           | [Element UI官网](https://element.eleme.cn/#/zh-CN)                                                   |                                   |
-| 后端开发框架       | SpringBoot               | [SpringBoot官网](https://spring.io/projects/spring-boot/#learn)                                      |                                   |
-| 微服务开发框架      | SpringCloud              | [SpringCloud官网](https://spring.io/projects/spring-cloud)                                           |                                   |
-| 微服务开发框架      | SpringCloudAlibaba       | [SpringCloudAlibaba官网](https://spring.io/projects/spring-cloud-alibaba)                            |                                   |
-| 容器框架         | 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                           |
-| 缓存数据库        | 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通信高性能                 |
-| 服务网关         | SpringCloud Gateway      | [SpringCloud Gateway文档](https://spring.io/projects/spring-cloud-gateway)                           | 响应式高性能网关                          |
-| 负载均衡         | SpringCloud Loadbalancer | [SpringCloud Loadbalancer文档](https://spring.io/guides/gs/spring-cloud-loadbalancer/)               | 负载均衡处理                            |
-| RPC远程调用      | Apache Dubbo             | [Apache Dubbo官网](https://dubbo.apache.org/zh/)                                                     | 原生态使用体验、高性能                       |
-| 分布式限流熔断      | Alibaba Sentinel         | [Alibaba Sentinel文档](https://sentinelguard.io/zh-cn/)                                              | 无侵入、高扩展                           |
-| 分布式事务        | Alibaba Seata            | [Alibaba Seata文档](http://seata.io/zh-cn/)                                                          | 无侵入、高扩展 支持 四种模式                   |
-| 分布式消息队列      | SpringCloud Stream       | [SpringCloud Stream文档](https://spring.io/projects/spring-cloud-stream)                             | 门面框架兼容各种MQ集成                      |
-| 分布式消息队列      | Apache Kafka             | [Apache Kafka文档](https://kafka.apache.org/)                                                        | 高性能高速度                            |
-| 分布式消息队列      | Apache RocketMQ          | [Apache RocketMQ文档](http://rocketmq.apache.org/)                                                   | 高可用功能多样                           |
-| 分布式消息队列      | RabbitMQ                 | [RabbitMQ文档](https://www.rabbitmq.com/)                                                            | 支持各种扩展插件功能多样性                     |
-| 分布式搜索引擎      | ElasticSearch、Easy-Es    | [Easy-Es官网](https://www.easy-es.cn/)                                                               | 以 Mybatis-Plus 方式操作 ElasticSearch |
-| 分布式链路追踪      | Apache SkyWalking        | [Apache SkyWalking文档](https://skywalking.apache.org/docs/)                                         | 链路追踪、网格分析、度量聚合、可视化                |
-| 分布式日志中心      | ELK                      | [ElasticSearch官网](https://www.elastic.co/cn/elasticsearch/)                                        | ELK业界成熟解决方案                       |
-| 分布式锁         | Lock4j                   | [Lock4j官网](https://gitee.com/baomidou/lock4j)                                                      | 注解锁、工具锁 多种多样                      |
-| 分布式幂等        | Redisson                 | [Lock4j文档](https://gitee.com/baomidou/lock4j)                                                      | 拦截重复提交                            |
-| 分布式任务调度      | Xxl-Job                  | [Xxl-Job官网](https://www.xuxueli.com/xxl-job/)                                                      | 高性能 高可靠 易扩展                       |
-| 分布式文件存储      | Minio                    | [Minio文档](https://docs.min.io/)                                                                    | 本地存储                              |
-| 分布式云存储       | 七牛、阿里、腾讯                 | [OSS使用文档](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=4359146&doc_id=1469725)  | 云存储                               |
-| 短信模块         | 阿里、腾讯                    | [短信使用文档](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=5578491&doc_id=1469725)   | 短信发送                              |
-| 分布式监控        | Prometheus、Grafana       | [Prometheus文档](https://prometheus.io/docs/introduction/overview/)                                  | 全方位性能监控                           |
-| 服务监控         | SpringBoot-Admin         | [SpringBoot-Admin文档](https://codecentric.github.io/spring-boot-admin/current/)                     | 全方位服务监控                           |
-| 数据库框架        | Mybatis-Plus             | [Mybatis-Plus文档](https://baomidou.com/guide/)                                                      | 快速 CRUD 增加开发效率                    |
-| 数据库框架        | P6spy                    | [p6spy官网](https://p6spy.readthedocs.io/)                                                           | 更强劲的 SQL 分析                       |
-| 多数据源框架       | Dynamic-Datasource       | [dynamic-ds文档](https://www.kancloud.cn/tracy5546/dynamic-datasource/content)                       | 支持主从与多种类数据库异构                     |
-| 序列化框架        | Jackson                  | [Jackson官网](https://github.com/FasterXML/jackson)                                                  | 统一使用 jackson 高效可靠                 |
-| Redis客户端     | Redisson                 | [Redisson文档](https://github.com/redisson/redisson/wiki/%E7%9B%AE%E5%BD%95)                         | 支持单机、集群配置                         |
-| 校验框架         | Validation               | [Validation文档](https://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/)     | 增强接口安全性、严谨性 支持国际化                 |
-| Excel框架      | Alibaba EasyExcel        | [EasyExcel文档](https://www.yuque.com/easyexcel/doc/easyexcel)                                       | 性能优异 扩展性强                         |
-| 文档框架         | SpringDoc、javadoc        | [接口文档](https://gitee.com/JavaLionLi/RuoYi-Cloud-Plus/wikis/pages?sort_id=5877829&doc_id=2056143)   | 无注解零入侵基于java注释                    |
-| 工具类框架        | Hutool、Lombok            | [Hutool文档](https://www.hutool.cn/docs/)                                                            | 减少代码冗余 增加安全性                      |
-| 代码生成器        | 适配MP、SpringDoc规范化代码      | [代码生成文档](https://gitee.com/JavaLionLi/RuoYi-Cloud-Plus/wikis/pages?sort_id=5522467&doc_id=2056143) | 一键生成前后端代码                         |
-| 部署方式         | Docker                   | [Docker文档](https://docs.docker.com/)                                                               | 容器编排 一键部署业务集群                     |
-| 国际化          | SpringMessage            | [SpringMVC文档](https://docs.spring.io/spring-framework/docs/current/reference/html/web.html#mvc)    | Spring标准国际化方案                     |
+| 功能介绍      | 使用技术                     | 文档地址                                                                                               | 特性注意事项                            |
+|-----------|--------------------------|----------------------------------------------------------------------------------------------------|-----------------------------------|
+| 微服务权限管理系统 | 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)                                           | 由于组件还未完善 仅供学习                     |
+| 前端开发框架    | Vue、Element UI           | [Element UI官网](https://element.eleme.cn/#/zh-CN)                                                   |                                   |
+| 后端开发框架    | SpringBoot               | [SpringBoot官网](https://spring.io/projects/spring-boot/#learn)                                      |                                   |
+| 微服务开发框架   | SpringCloud              | [SpringCloud官网](https://spring.io/projects/spring-cloud)                                           |                                   |
+| 微服务开发框架   | SpringCloudAlibaba       | [SpringCloudAlibaba官网](https://spring.io/projects/spring-cloud-alibaba)                            |                                   |
+| 容器框架      | 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                             |
+| 缓存数据库     | 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通信高性能                 |
+| 服务网关      | SpringCloud Gateway      | [SpringCloud Gateway文档](https://spring.io/projects/spring-cloud-gateway)                           | 响应式高性能网关                          |
+| 负载均衡      | SpringCloud Loadbalancer | [SpringCloud Loadbalancer文档](https://spring.io/guides/gs/spring-cloud-loadbalancer/)               | 负载均衡处理                            |
+| RPC远程调用   | Apache Dubbo             | [Apache Dubbo官网](https://dubbo.apache.org/zh/)                                                     | 原生态使用体验、高性能                       |
+| 分布式限流熔断   | Alibaba Sentinel         | [Alibaba Sentinel文档](https://sentinelguard.io/zh-cn/)                                              | 无侵入、高扩展                           |
+| 分布式事务     | Alibaba Seata            | [Alibaba Seata文档](http://seata.io/zh-cn/)                                                          | 无侵入、高扩展 支持 四种模式                   |
+| 分布式消息队列   | SpringCloud Stream       | [SpringCloud Stream文档](https://spring.io/projects/spring-cloud-stream)                             | 门面框架兼容各种MQ集成                      |
+| 分布式消息队列   | Apache Kafka             | [Apache Kafka文档](https://kafka.apache.org/)                                                        | 高性能高速度                            |
+| 分布式消息队列   | Apache RocketMQ          | [Apache RocketMQ文档](http://rocketmq.apache.org/)                                                   | 高可用功能多样                           |
+| 分布式消息队列   | RabbitMQ                 | [RabbitMQ文档](https://www.rabbitmq.com/)                                                            | 支持各种扩展插件功能多样性                     |
+| 分布式搜索引擎   | ElasticSearch、Easy-Es    | [Easy-Es官网](https://www.easy-es.cn/)                                                               | 以 Mybatis-Plus 方式操作 ElasticSearch |
+| 分布式链路追踪   | Apache SkyWalking        | [Apache SkyWalking文档](https://skywalking.apache.org/docs/)                                         | 链路追踪、网格分析、度量聚合、可视化                |
+| 分布式日志中心   | ELK                      | [ElasticSearch官网](https://www.elastic.co/cn/elasticsearch/)                                        | ELK业界成熟解决方案                       |
+| 分布式锁      | Lock4j                   | [Lock4j官网](https://gitee.com/baomidou/lock4j)                                                      | 注解锁、工具锁 多种多样                      |
+| 分布式幂等     | Redisson                 | [Lock4j文档](https://gitee.com/baomidou/lock4j)                                                      | 拦截重复提交                            |
+| 分布式任务调度   | Xxl-Job                  | [Xxl-Job官网](https://www.xuxueli.com/xxl-job/)                                                      | 高性能 高可靠 易扩展                       |
+| 分布式文件存储   | Minio                    | [Minio文档](https://docs.min.io/)                                                                    | 本地存储                              |
+| 分布式云存储    | 七牛、阿里、腾讯                 | [OSS使用文档](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=4359146&doc_id=1469725)  | 云存储                               |
+| 短信模块      | 阿里、腾讯                    | [短信使用文档](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=5578491&doc_id=1469725)   | 短信发送                              |
+| 分布式监控     | Prometheus、Grafana       | [Prometheus文档](https://prometheus.io/docs/introduction/overview/)                                  | 全方位性能监控                           |
+| 服务监控      | SpringBoot-Admin         | [SpringBoot-Admin文档](https://codecentric.github.io/spring-boot-admin/current/)                     | 全方位服务监控                           |
+| 数据库框架     | Mybatis-Plus             | [Mybatis-Plus文档](https://baomidou.com/guide/)                                                      | 快速 CRUD 增加开发效率                    |
+| 数据库框架     | P6spy                    | [p6spy官网](https://p6spy.readthedocs.io/)                                                           | 更强劲的 SQL 分析                       |
+| 多数据源框架    | Dynamic-Datasource       | [dynamic-ds文档](https://www.kancloud.cn/tracy5546/dynamic-datasource/content)                       | 支持主从与多种类数据库异构                     |
+| 序列化框架     | Jackson                  | [Jackson官网](https://github.com/FasterXML/jackson)                                                  | 统一使用 jackson 高效可靠                 |
+| Redis客户端  | Redisson                 | [Redisson文档](https://github.com/redisson/redisson/wiki/%E7%9B%AE%E5%BD%95)                         | 支持单机、集群配置                         |
+| 校验框架      | Validation               | [Validation文档](https://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/)     | 增强接口安全性、严谨性 支持国际化                 |
+| Excel框架   | Alibaba EasyExcel        | [EasyExcel文档](https://www.yuque.com/easyexcel/doc/easyexcel)                                       | 性能优异 扩展性强                         |
+| 文档框架      | SpringDoc、javadoc        | [接口文档](https://gitee.com/JavaLionLi/RuoYi-Cloud-Plus/wikis/pages?sort_id=5877829&doc_id=2056143)   | 无注解零入侵基于java注释                    |
+| 工具类框架     | Hutool、Lombok            | [Hutool文档](https://www.hutool.cn/docs/)                                                            | 减少代码冗余 增加安全性                      |
+| 代码生成器     | 适配MP、SpringDoc规范化代码      | [代码生成文档](https://gitee.com/JavaLionLi/RuoYi-Cloud-Plus/wikis/pages?sort_id=5522467&doc_id=2056143) | 一键生成前后端代码                         |
+| 部署方式      | Docker                   | [Docker文档](https://docs.docker.com/)                                                               | 容器编排 一键部署业务集群                     |
+| 国际化       | SpringMessage            | [SpringMVC文档](https://docs.spring.io/spring-framework/docs/current/reference/html/web.html#mvc)    | Spring标准国际化方案                     |
 
 ## 参考文档
 

+ 8 - 0
config/nacos/datasource.yml

@@ -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:

+ 14 - 8
config/nacos/ruoyi-gen.yml

@@ -11,14 +11,20 @@ spring:
           url: ${datasource.system-master.url}
           username: ${datasource.system-master.username}
           password: ${datasource.system-master.password}
-        # 从库数据源
-        #slave:
-        #  lazy: true
-        #  type: ${spring.datasource.type}
-        #  driver-class-name:
-        #  url:
-        #  username:
-        #  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}
 
 # 代码生成
 gen:

+ 14 - 0
config/nacos/ruoyi-resource.yml

@@ -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

+ 14 - 7
config/nacos/ruoyi-system.yml

@@ -11,10 +11,17 @@ spring:
           url: ${datasource.system-master.url}
           username: ${datasource.system-master.username}
           password: ${datasource.system-master.password}
-        # 从库数据源
-        # slave:
-        #  type: ${spring.datasource.type}
-        #  driver-class-name:
-        #  url:
-        #  username:
-        #  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}

+ 15 - 0
ruoyi-common/ruoyi-common-mybatis/pom.xml

@@ -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>

+ 15 - 0
ruoyi-example/ruoyi-demo/src/main/resources/application.yml

@@ -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/

+ 2 - 1
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/dubbo/RemoteDataScopeServiceImpl.java

@@ -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>()

+ 3 - 2
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java

@@ -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();

+ 2 - 1
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java

@@ -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);