增加多数据源演示(学生信息表的服务selectPage方法),默认关闭

This commit is contained in:
dataprince 2023-12-20 14:29:26 +08:00
parent ea1411246e
commit f546a47c61
3 changed files with 49 additions and 14 deletions

View File

@ -7,7 +7,7 @@
## 1、平台简介 ## 1、平台简介
Ruoyi-Flex是一套全部开源的快速开发平台使用MIT开源许可协议毫无保留给个人及企业免费使用。基于RuoYi-Vue、RuoYi-Vue-Plus集成MyBatis-Flex、JDK21、SpringBootV3.2.X+、Lombok、Sa-Token、SpringDoc、Hutool、SpringBoot Admin、PowerJob、Vue3、Element-Plus、MinIO等优秀开源软件 Ruoyi-Flex是一套全部开源的快速开发平台使用MIT开源许可协议毫无保留给个人及企业免费使用。基于RuoYi-Vue、RuoYi-Vue-Plus集成MyBatis-Flex、JDK21、SpringBootV3.2.X+、Lombok、Sa-Token、SpringDoc、Hutool、SpringBoot Admin、PowerJob、Vue3、Element-Plus、MinIO等优秀开源软件
## 2、系统特色 ## 2、系统特色
Ruoyi-Flex秉承“写的更少、性能更好、出错更低、交流通畅、快速入门” 的理念,为您带来全方位的赋能与提升: Ruoyi-Flex秉承“写的更少、性能更好、出错更低、交流通畅、快速入门” 的理念,为您带来全方位的赋能与提升:

View File

@ -38,15 +38,15 @@ mybatis-flex:
# 指定为HikariDataSource # 指定为HikariDataSource
type: com.zaxxer.hikari.HikariDataSource type: com.zaxxer.hikari.HikariDataSource
# mysql数据库 # mysql数据库
driver-class-name: com.mysql.cj.jdbc.Driver # driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/ruoyi-flex?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true # url: jdbc:mysql://localhost:3306/ruoyi-flex?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
username: root # username: root
password: Root@369 # password: Root@369
#postgresql数据库 #postgresql数据库
# driver-class-name: org.postgresql.Driver driver-class-name: org.postgresql.Driver
# url: jdbc:postgresql://localhost:5432/ruoyi-flex?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true url: jdbc:postgresql://localhost:5432/ruoyi-flex?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
# username: postgres username: postgres
# password: postgres@369 password: postgres@369
hikari: hikari:
#连接池名 #连接池名
@ -69,6 +69,42 @@ mybatis-flex:
keepaliveTime: 30000 keepaliveTime: 30000
# 连接测试query # 连接测试query
connection-test-query: SELECT 1 connection-test-query: SELECT 1
# 数据源-2
# ds2:
# # 指定为HikariDataSource
# type: com.zaxxer.hikari.HikariDataSource
# # mysql数据库
# driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://localhost:3306/ruoyi-flex?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
# username: root
# password: Root@369
# #postgresql数据库
## driver-class-name: org.postgresql.Driver
## url: jdbc:postgresql://localhost:5432/ruoyi-flex?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
## username: postgres
## password: postgres@369
#
# hikari:
# #连接池名
# pool-name: HikariCP-ds1
# #最小空闲连接数
# minimum-idle: 5
# # 空闲连接存活最大时间默认10分钟
# idle-timeout: 600000
# # 连接池最大连接数默认是10
# maximum-pool-size: 10
# # 此属性控制从池返回的连接的默认自动提交行为,默认值true
# auto-commit: true
# # 此属性控制池中连接的最长生命周期值0表示无限生命周期默认30分钟
# max-lifetime: 1800000
# # 数据库连接超时时间,默认30秒
# connection-timeout: 30000
# # 校验超时时间
# validationTimeout: 5000
# # 多久检查一次连接的活性
# keepaliveTime: 30000
# # 连接测试query
# connection-test-query: SELECT 1
# redis 单机配置(单机与集群只能开启一个另一个需要注释掉) # redis 单机配置(单机与集群只能开启一个另一个需要注释掉)
spring.data: spring.data:
@ -123,7 +159,7 @@ management:
--- # 监控中心客户端配置 --- # 监控中心客户端配置
spring.boot.admin.client: spring.boot.admin.client:
# 增加客户端开关 # 增加客户端开关
enabled: true enabled: false
url: http://localhost:9090/admin url: http://localhost:9090/admin
instance: instance:
service-host-type: IP service-host-type: IP
@ -134,7 +170,7 @@ spring.boot.admin.client:
powerjob: powerjob:
worker: worker:
# 如何开启调度中心请查看文档教程 # 如何开启调度中心请查看文档教程
enabled: true enabled: false
# 需要先在 powerjob 登录页执行应用注册后才能使用 # 需要先在 powerjob 登录页执行应用注册后才能使用
app-name: ruoyi-worker app-name: ruoyi-worker
# 28080 端口 随着主应用端口飘逸 避免集群冲突 # 28080 端口 随着主应用端口飘逸 避免集群冲突

View File

@ -2,8 +2,7 @@ package com.ruoyi.mf.service.impl;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import com.mybatisflex.annotation.UseDataSource;
import cn.hutool.core.util.ObjectUtil;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import com.ruoyi.common.core.utils.MapstructUtils; import com.ruoyi.common.core.utils.MapstructUtils;
@ -11,7 +10,6 @@ import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.orm.core.page.PageQuery; import com.ruoyi.common.orm.core.page.PageQuery;
import com.ruoyi.common.orm.core.page.TableDataInfo; import com.ruoyi.common.orm.core.page.TableDataInfo;
import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl; import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl;
import com.ruoyi.common.core.utils.DateUtils;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -85,6 +83,7 @@ public class MfStudentServiceImpl extends BaseServiceImpl<MfStudentMapper, MfStu
* @return 分页学生信息表集合 * @return 分页学生信息表集合
*/ */
@Override @Override
//@UseDataSource("ds2")
public TableDataInfo<MfStudentVo> selectPage(MfStudentBo mfStudentBo) public TableDataInfo<MfStudentVo> selectPage(MfStudentBo mfStudentBo)
{ {
QueryWrapper queryWrapper = buildQueryWrapper(mfStudentBo); QueryWrapper queryWrapper = buildQueryWrapper(mfStudentBo);