mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-04 12:18:42 +08:00 
			
		
		
		
	1. 处理多个环境的配置
This commit is contained in:
		
							
								
								
									
										11
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								README.md
									
									
									
									
									
								
							@@ -35,12 +35,12 @@
 | 
			
		||||
|  | 部门管理 | 配置系统组织机构(公司、部门、小组),树结构展现支持数据权限 |
 | 
			
		||||
|  | 岗位管理 | 配置系统用户所属担任职务 |
 | 
			
		||||
|  | 字典管理 | 对系统中经常使用的一些较为固定的数据进行维护 |
 | 
			
		||||
|  | 通知公告 | 系统通知公告信息发布维护 |
 | 
			
		||||
| 🚀 | 短信管理 | 短信渠道、短息模板、短信日志,对接阿里云、云片等主流短信平台 |
 | 
			
		||||
| 🚀 | 操作日志 | 系统正常操作日志记录和查询,集成 Swagger 生成日志内容 |
 | 
			
		||||
|  | 登录日志 | 系统登录日志记录查询包含登录异常 |
 | 
			
		||||
|  | 通知公告 | 系统通知公告信息发布维护 |
 | 
			
		||||
 | 
			
		||||
计划新增功能:
 | 
			
		||||
* 短信
 | 
			
		||||
* 邮件
 | 
			
		||||
* 钉钉、飞书等通知
 | 
			
		||||
 | 
			
		||||
@@ -87,14 +87,15 @@
 | 
			
		||||
 | 
			
		||||
## 技术栈
 | 
			
		||||
 | 
			
		||||
**后端**
 | 
			
		||||
### 后端
 | 
			
		||||
 | 
			
		||||
| 框架 | 说明 |  版本 | 学习指南 |
 | 
			
		||||
| --- | --- | --- | --- |
 | 
			
		||||
| [Spring Boot](https://spring.io/projects/spring-boot) | 应用开发框架 | 2.4.2 | [文档](https://github.com/YunaiV/SpringBoot-Labs) |
 | 
			
		||||
| [MySQL](https://www.mysql.com/cn/) | 数据库服务器 | 5.7 |  |
 | 
			
		||||
| [Druid](https://github.com/alibaba/druid) | JDBC 连接池、监控组件 | 1.2.4 | [文档](http://www.iocoder.cn/Spring-Boot/datasource-pool/?yudao) |
 | 
			
		||||
| [MyBatis-Plus](https://mp.baomidou.com/) | MyBatis 增强工具包 | 3.4.1 | [文档](http://www.iocoder.cn/Spring-Boot/MyBatis/?yudao) |
 | 
			
		||||
| [MyBatis Plus](https://mp.baomidou.com/) | MyBatis 增强工具包 | 3.4.1 | [文档](http://www.iocoder.cn/Spring-Boot/MyBatis/?yudao) |
 | 
			
		||||
| [Dynamic Datasource](https://dynamic-datasource.com/) | 动态数据源 | 3.3.2 | [文档](hhttp://www.iocoder.cn/Spring-Boot/datasource-pool/?yudao) |
 | 
			
		||||
| [Redis](https://redis.io/) | key-value 数据库 | 5.0 |  |
 | 
			
		||||
| [Redisson](https://github.com/redisson/redisson) | Redis 客户端 | 3.1.46 | [文档](http://www.iocoder.cn/Spring-Boot/Redis/?yudao) |
 | 
			
		||||
| [Spring MVC](https://github.com/spring-projects/spring-framework/tree/master/spring-webmvc) | MVC 框架  | 5.4.2 | [文档](http://www.iocoder.cn/SpringMVC/MVC/?yudao) |
 | 
			
		||||
@@ -111,7 +112,7 @@
 | 
			
		||||
| [JUnit](https://junit.org/junit5/) | Java 单元测试框架 | 5.7.0 | - |
 | 
			
		||||
| [Mockito](https://github.com/mockito/mockito) | Java Mock 框架 | 3.6.28 | - |
 | 
			
		||||
 | 
			
		||||
**前端**
 | 
			
		||||
### 前端
 | 
			
		||||
 | 
			
		||||
| 框架 | 说明 |  版本 |
 | 
			
		||||
| --- | --- | --- |
 | 
			
		||||
 
 | 
			
		||||
@@ -1,27 +0,0 @@
 | 
			
		||||
package com.ruoyi.common.annotation;
 | 
			
		||||
 | 
			
		||||
import java.lang.annotation.Documented;
 | 
			
		||||
import java.lang.annotation.ElementType;
 | 
			
		||||
import java.lang.annotation.Retention;
 | 
			
		||||
import java.lang.annotation.RetentionPolicy;
 | 
			
		||||
import java.lang.annotation.Target;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 数据权限过滤注解
 | 
			
		||||
 *
 | 
			
		||||
 * @author ruoyi
 | 
			
		||||
 */
 | 
			
		||||
@Target(ElementType.METHOD)
 | 
			
		||||
@Retention(RetentionPolicy.RUNTIME)
 | 
			
		||||
@Documented
 | 
			
		||||
public @interface DataScope {
 | 
			
		||||
    /**
 | 
			
		||||
     * 部门表的别名
 | 
			
		||||
     */
 | 
			
		||||
    public String deptAlias() default "";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 用户表的别名
 | 
			
		||||
     */
 | 
			
		||||
    public String userAlias() default "";
 | 
			
		||||
}
 | 
			
		||||
@@ -1,145 +0,0 @@
 | 
			
		||||
package com.ruoyi.framework.aspectj;
 | 
			
		||||
 | 
			
		||||
import java.lang.reflect.Method;
 | 
			
		||||
 | 
			
		||||
import org.aspectj.lang.JoinPoint;
 | 
			
		||||
import org.aspectj.lang.Signature;
 | 
			
		||||
import org.aspectj.lang.annotation.Aspect;
 | 
			
		||||
import org.aspectj.lang.annotation.Before;
 | 
			
		||||
import org.aspectj.lang.annotation.Pointcut;
 | 
			
		||||
import org.aspectj.lang.reflect.MethodSignature;
 | 
			
		||||
import org.springframework.stereotype.Component;
 | 
			
		||||
import com.ruoyi.common.annotation.DataScope;
 | 
			
		||||
import com.ruoyi.common.core.domain.BaseEntity;
 | 
			
		||||
import com.ruoyi.common.core.domain.entity.SysRole;
 | 
			
		||||
import com.ruoyi.common.core.domain.entity.SysUser;
 | 
			
		||||
import com.ruoyi.common.core.domain.model.LoginUser;
 | 
			
		||||
import com.ruoyi.common.utils.ServletUtils;
 | 
			
		||||
import com.ruoyi.common.utils.StringUtils;
 | 
			
		||||
import com.ruoyi.common.utils.spring.SpringUtils;
 | 
			
		||||
import com.ruoyi.framework.web.service.TokenService;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 数据过滤处理
 | 
			
		||||
 *
 | 
			
		||||
 * @author ruoyi
 | 
			
		||||
 */
 | 
			
		||||
@Aspect
 | 
			
		||||
@Component
 | 
			
		||||
public class DataScopeAspect {
 | 
			
		||||
    /**
 | 
			
		||||
     * 全部数据权限
 | 
			
		||||
     */
 | 
			
		||||
    public static final String DATA_SCOPE_ALL = "1";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 自定数据权限
 | 
			
		||||
     */
 | 
			
		||||
    public static final String DATA_SCOPE_CUSTOM = "2";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 部门数据权限
 | 
			
		||||
     */
 | 
			
		||||
    public static final String DATA_SCOPE_DEPT = "3";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 部门及以下数据权限
 | 
			
		||||
     */
 | 
			
		||||
    public static final String DATA_SCOPE_DEPT_AND_CHILD = "4";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 仅本人数据权限
 | 
			
		||||
     */
 | 
			
		||||
    public static final String DATA_SCOPE_SELF = "5";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 数据权限过滤关键字
 | 
			
		||||
     */
 | 
			
		||||
    public static final String DATA_SCOPE = "dataScope";
 | 
			
		||||
 | 
			
		||||
    // 配置织入点
 | 
			
		||||
    @Pointcut("@annotation(com.ruoyi.common.annotation.DataScope)")
 | 
			
		||||
    public void dataScopePointCut() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Before("dataScopePointCut()")
 | 
			
		||||
    public void doBefore(JoinPoint point) throws Throwable {
 | 
			
		||||
        handleDataScope(point);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected void handleDataScope(final JoinPoint joinPoint) {
 | 
			
		||||
        // 获得注解
 | 
			
		||||
        DataScope controllerDataScope = getAnnotationLog(joinPoint);
 | 
			
		||||
        if (controllerDataScope == null) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        // 获取当前的用户
 | 
			
		||||
        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
 | 
			
		||||
        if (StringUtils.isNotNull(loginUser)) {
 | 
			
		||||
            SysUser currentUser = loginUser.getUser();
 | 
			
		||||
            // 如果是超级管理员,则不过滤数据
 | 
			
		||||
            if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin()) {
 | 
			
		||||
                dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(),
 | 
			
		||||
                        controllerDataScope.userAlias());
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 数据范围过滤
 | 
			
		||||
     *
 | 
			
		||||
     * @param joinPoint 切点
 | 
			
		||||
     * @param user      用户
 | 
			
		||||
     * @param userAlias 别名
 | 
			
		||||
     */
 | 
			
		||||
    public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias) {
 | 
			
		||||
        StringBuilder sqlString = new StringBuilder();
 | 
			
		||||
 | 
			
		||||
        for (SysRole role : user.getRoles()) {
 | 
			
		||||
            String dataScope = role.getDataScope();
 | 
			
		||||
            if (DATA_SCOPE_ALL.equals(dataScope)) {
 | 
			
		||||
                sqlString = new StringBuilder();
 | 
			
		||||
                break;
 | 
			
		||||
            } else if (DATA_SCOPE_CUSTOM.equals(dataScope)) {
 | 
			
		||||
                sqlString.append(StringUtils.format(
 | 
			
		||||
                        " OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptAlias,
 | 
			
		||||
                        role.getRoleId()));
 | 
			
		||||
            } else if (DATA_SCOPE_DEPT.equals(dataScope)) {
 | 
			
		||||
                sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", deptAlias, user.getDeptId()));
 | 
			
		||||
            } else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) {
 | 
			
		||||
                sqlString.append(StringUtils.format(
 | 
			
		||||
                        " OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )",
 | 
			
		||||
                        deptAlias, user.getDeptId(), user.getDeptId()));
 | 
			
		||||
            } else if (DATA_SCOPE_SELF.equals(dataScope)) {
 | 
			
		||||
                if (StringUtils.isNotBlank(userAlias)) {
 | 
			
		||||
                    sqlString.append(StringUtils.format(" OR {}.user_id = {} ", userAlias, user.getUserId()));
 | 
			
		||||
                } else {
 | 
			
		||||
                    // 数据权限为仅本人且没有userAlias别名不查询任何数据
 | 
			
		||||
                    sqlString.append(" OR 1=0 ");
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (StringUtils.isNotBlank(sqlString.toString())) {
 | 
			
		||||
            Object params = joinPoint.getArgs()[0];
 | 
			
		||||
            if (StringUtils.isNotNull(params) && params instanceof BaseEntity) {
 | 
			
		||||
                BaseEntity baseEntity = (BaseEntity) params;
 | 
			
		||||
                baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 是否存在注解,如果存在就获取
 | 
			
		||||
     */
 | 
			
		||||
    private DataScope getAnnotationLog(JoinPoint joinPoint) {
 | 
			
		||||
        Signature signature = joinPoint.getSignature();
 | 
			
		||||
        MethodSignature methodSignature = (MethodSignature) signature;
 | 
			
		||||
        Method method = methodSignature.getMethod();
 | 
			
		||||
 | 
			
		||||
        if (method != null) {
 | 
			
		||||
            return method.getAnnotation(DataScope.class);
 | 
			
		||||
        }
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,22 @@
 | 
			
		||||
package cn.iocoder.dashboard.framework.datasource.core.enums;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 对应于多数据源中不同数据源配置
 | 
			
		||||
 *
 | 
			
		||||
 * 通过在方法上,使用 {@link com.baomidou.dynamic.datasource.annotation.DS} 注解,设置使用的数据源。
 | 
			
		||||
 * 注意,默认是 {@link #MASTER} 数据源
 | 
			
		||||
 *
 | 
			
		||||
 * 对应官方文档为 http://dynamic-datasource.com/guide/customize/Annotation.html
 | 
			
		||||
 */
 | 
			
		||||
public interface DataSourceEnum {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 主库,推荐使用 {@link com.baomidou.dynamic.datasource.annotation.Master} 注解
 | 
			
		||||
     */
 | 
			
		||||
    String MASTER = "master";
 | 
			
		||||
    /**
 | 
			
		||||
     * 从库,推荐使用 {@link com.baomidou.dynamic.datasource.annotation.Slave} 注解
 | 
			
		||||
     */
 | 
			
		||||
    String SLAVE = "slave";
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,14 +0,0 @@
 | 
			
		||||
package cn.iocoder.dashboard.framework.datasource.core.enums;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 对应于多数据源中不同数据源配置
 | 
			
		||||
 *
 | 
			
		||||
 * 在方法上使用注解{@code  @DS(DatasourceMark.slave)}可以指定slave数据源,默认是master数据源
 | 
			
		||||
 */
 | 
			
		||||
public interface DatasourceMark {
 | 
			
		||||
 | 
			
		||||
    String MASTER = "master";
 | 
			
		||||
 | 
			
		||||
    String SLAVE = "slave";
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -18,11 +18,7 @@ public interface ToolSchemaTableMapper extends BaseMapperX<ToolSchemaTableDO> {
 | 
			
		||||
                .likeIfPresent("table_comment", tableComment));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    default List<ToolSchemaTableDO> selectListByTableSchema(String tableSchema) {
 | 
			
		||||
        return selectList(new QueryWrapper<ToolSchemaTableDO>().eq("table_schema", tableSchema));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    default ToolSchemaTableDO selectByTableName1(String tableSchema, String tableName) {
 | 
			
		||||
    default ToolSchemaTableDO selectByTableSchemaAndTableName(String tableSchema, String tableName) {
 | 
			
		||||
        return selectOne(new QueryWrapper<ToolSchemaTableDO>().eq("table_schema",tableSchema)
 | 
			
		||||
                        .eq("table_name", tableName));
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -101,10 +101,10 @@ public class ToolCodegenServiceImpl implements ToolCodegenService {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Long createCodegen(String tableName) {
 | 
			
		||||
        //获取当前schema
 | 
			
		||||
        // 获取当前schema
 | 
			
		||||
        String tableSchema = codegenProperties.getDbSchemas().iterator().next();
 | 
			
		||||
        // 从数据库中,获得数据库表结构
 | 
			
		||||
        ToolSchemaTableDO schemaTable = schemaTableMapper.selectByTableName1(tableSchema, tableName);
 | 
			
		||||
        ToolSchemaTableDO schemaTable = schemaTableMapper.selectByTableSchemaAndTableName(tableSchema, tableName);
 | 
			
		||||
        List<ToolSchemaColumnDO> schemaColumns = schemaColumnMapper.selectListByTableName(tableSchema, tableName);
 | 
			
		||||
        // 导入
 | 
			
		||||
        return this.createCodegen0(ToolCodegenImportTypeEnum.DB, schemaTable, schemaColumns);
 | 
			
		||||
 
 | 
			
		||||
@@ -4,39 +4,42 @@ server:
 | 
			
		||||
--- #################### 数据库相关配置 ####################
 | 
			
		||||
 | 
			
		||||
spring:
 | 
			
		||||
  # 数据源配置项 TODO 监控配置
 | 
			
		||||
  # 排除默认的自动配置,使用dynamic-datasource-spring-boot-starter配置多数据源,整合druid
 | 
			
		||||
  # 数据源配置项
 | 
			
		||||
  autoconfigure:
 | 
			
		||||
    exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
 | 
			
		||||
    exclude:
 | 
			
		||||
      - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源
 | 
			
		||||
  datasource:
 | 
			
		||||
    druid:
 | 
			
		||||
    druid: # Druid 【监控】相关的全局配置
 | 
			
		||||
      web-stat-filter:
 | 
			
		||||
        enabled: true
 | 
			
		||||
      stat-view-servlet:
 | 
			
		||||
        enabled: true
 | 
			
		||||
        # 设置白名单,不填则允许所有访问
 | 
			
		||||
        allow:
 | 
			
		||||
        allow: # 设置白名单,不填则允许所有访问
 | 
			
		||||
        url-pattern: /druid/*
 | 
			
		||||
        # 控制台管理用户名和密码
 | 
			
		||||
        login-username:
 | 
			
		||||
        login-username: # 控制台管理用户名和密码
 | 
			
		||||
        login-password:
 | 
			
		||||
      filter:
 | 
			
		||||
        stat:
 | 
			
		||||
          enabled: true
 | 
			
		||||
          # 慢 SQL 记录
 | 
			
		||||
          log-slow-sql: true
 | 
			
		||||
          log-slow-sql: true # 慢 SQL 记录
 | 
			
		||||
          slow-sql-millis: 100
 | 
			
		||||
          merge-sql: true
 | 
			
		||||
        wall:
 | 
			
		||||
          config:
 | 
			
		||||
            multi-statement-allow: true
 | 
			
		||||
    dynamic:
 | 
			
		||||
      # druid全局配置 https://dynamic-datasource.com/en/guide/integration/Druid.html#configurate-parameters
 | 
			
		||||
#      druid: #The following are the supported global parameters
 | 
			
		||||
#        initial-size:
 | 
			
		||||
#        max-active:
 | 
			
		||||
#        min-idle:
 | 
			
		||||
#        max-wait:
 | 
			
		||||
    dynamic: # 多数据源配置
 | 
			
		||||
      druid: # Druid 【连接池】相关的全局配置
 | 
			
		||||
        initial-size: 5 # 初始连接数
 | 
			
		||||
        min-idle: 10 # 最小连接池数量
 | 
			
		||||
        max-active: 20 # 最大连接池数量
 | 
			
		||||
        max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒
 | 
			
		||||
        time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒
 | 
			
		||||
        min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒
 | 
			
		||||
        max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒
 | 
			
		||||
        validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效
 | 
			
		||||
        test-while-idle: true
 | 
			
		||||
        test-on-borrow: false
 | 
			
		||||
        test-on-return: false
 | 
			
		||||
      primary: master
 | 
			
		||||
      datasource:
 | 
			
		||||
        master:
 | 
			
		||||
@@ -45,19 +48,12 @@ spring:
 | 
			
		||||
          driver-class-name: com.mysql.jdbc.Driver
 | 
			
		||||
          username: root
 | 
			
		||||
          password: 3WLiVUBEwTbvAfsh
 | 
			
		||||
          # druid 局部配置
 | 
			
		||||
#          druid: # The following are independent parameters that can be reset for each db
 | 
			
		||||
#            validation-query: select 1 FROM DUAL #such as oracle need this
 | 
			
		||||
#        slave:
 | 
			
		||||
#          name: ruoyi-vue-pro-slave
 | 
			
		||||
#          url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
 | 
			
		||||
#          driver-class-name: com.mysql.jdbc.Driver
 | 
			
		||||
#          username: root
 | 
			
		||||
#          password: 123456
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改
 | 
			
		||||
          name: ruoyi-vue-pro
 | 
			
		||||
          url: jdbc:mysql://400-infra.server.iocoder.cn:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
 | 
			
		||||
          driver-class-name: com.mysql.jdbc.Driver
 | 
			
		||||
          username: root
 | 
			
		||||
          password: 3WLiVUBEwTbvAfsh
 | 
			
		||||
 | 
			
		||||
  # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
 | 
			
		||||
  redis:
 | 
			
		||||
@@ -103,9 +99,9 @@ apollo:
 | 
			
		||||
    eagerLoad:
 | 
			
		||||
      enabled: true # 设置 Apollo 在日志初始化前生效,可以实现日志的动态级别配置
 | 
			
		||||
  jdbc: # 自定义的 JDBC 配置项,用于数据库的地址
 | 
			
		||||
    url: ${spring.datasource.url}
 | 
			
		||||
    username: ${spring.datasource.username}
 | 
			
		||||
    password: ${spring.datasource.password}
 | 
			
		||||
    url: ${spring.datasource.dynamic.datasource.master.url}
 | 
			
		||||
    username: ${spring.datasource.dynamic.datasource.master.username}
 | 
			
		||||
    password: ${spring.datasource.dynamic.datasource.master.password}
 | 
			
		||||
 | 
			
		||||
--- #################### 服务保障相关配置 ####################
 | 
			
		||||
 | 
			
		||||
@@ -181,7 +177,7 @@ yudao:
 | 
			
		||||
    base-path: http://127.0.0.1:${server.port}${yudao.web.api-prefix}/system/file/get/
 | 
			
		||||
  codegen:
 | 
			
		||||
    base-package: ${yudao.info.base-package}
 | 
			
		||||
    db-schemas: ${spring.datasource.name}
 | 
			
		||||
    db-schemas: ${spring.datasource.dynamic.datasource.master.name}
 | 
			
		||||
  xss:
 | 
			
		||||
    enable: false
 | 
			
		||||
    exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,7 @@ server:
 | 
			
		||||
--- #################### 数据库相关配置 ####################
 | 
			
		||||
 | 
			
		||||
spring:
 | 
			
		||||
  # 数据源配置项 TODO 监控配置
 | 
			
		||||
  # 数据源配置项
 | 
			
		||||
  autoconfigure:
 | 
			
		||||
    exclude:
 | 
			
		||||
      - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源
 | 
			
		||||
@@ -48,8 +48,8 @@ spring:
 | 
			
		||||
          driver-class-name: com.mysql.jdbc.Driver
 | 
			
		||||
          username: root
 | 
			
		||||
          password: 123456
 | 
			
		||||
        slave:
 | 
			
		||||
          name: ruoyi-vue-slave
 | 
			
		||||
        slave: # 模拟从库,可根据自己需要修改
 | 
			
		||||
          name: ruoyi-vue-pro
 | 
			
		||||
          url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
 | 
			
		||||
          driver-class-name: com.mysql.jdbc.Driver
 | 
			
		||||
          username: root
 | 
			
		||||
@@ -177,18 +177,10 @@ yudao:
 | 
			
		||||
    base-path: http://127.0.0.1:${server.port}${yudao.web.api-prefix}/system/file/get/
 | 
			
		||||
  codegen:
 | 
			
		||||
    base-package: ${yudao.info.base-package}
 | 
			
		||||
    db-schemas: ${spring.datasource.name}
 | 
			
		||||
    db-schemas: ${spring.datasource.dynamic.datasource.master.name}
 | 
			
		||||
  xss:
 | 
			
		||||
    enable: false
 | 
			
		||||
    exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系
 | 
			
		||||
      - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求
 | 
			
		||||
      - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求
 | 
			
		||||
  demo: false # 关闭演示模式
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -12,7 +12,6 @@ spring:
 | 
			
		||||
      max-file-size: 16MB # 单个文件大小
 | 
			
		||||
      max-request-size: 32MB # 设置总上传的文件大小
 | 
			
		||||
 | 
			
		||||
  # Jackson 配置项
 | 
			
		||||
  jackson:
 | 
			
		||||
    serialization:
 | 
			
		||||
      write-dates-as-timestamps: true # 设置 Date 的格式,使用时间戳
 | 
			
		||||
@@ -32,3 +31,6 @@ mybatis-plus:
 | 
			
		||||
      logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)
 | 
			
		||||
  mapper-locations: classpath*:mapper/*.xml
 | 
			
		||||
  type-aliases-package: ${yudao.info.base-package}.modules.*.dal.dataobject
 | 
			
		||||
 | 
			
		||||
--- #################### 芋道相关配置 ####################
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,8 @@ import cn.iocoder.dashboard.framework.datasource.config.DataSourceConfiguration;
 | 
			
		||||
import cn.iocoder.dashboard.framework.mybatis.config.MybatisConfiguration;
 | 
			
		||||
import cn.iocoder.dashboard.framework.redis.config.RedisConfig;
 | 
			
		||||
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
 | 
			
		||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration;
 | 
			
		||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.druid.DruidDynamicDataSourceConfiguration;
 | 
			
		||||
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
 | 
			
		||||
import org.redisson.spring.starter.RedissonAutoConfiguration;
 | 
			
		||||
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
 | 
			
		||||
@@ -26,6 +28,9 @@ public class BaseDbAndRedisIntegrationTest {
 | 
			
		||||
            // MyBatis 配置类
 | 
			
		||||
            MybatisConfiguration.class, // 自己的 MyBatis 配置类
 | 
			
		||||
            MybatisPlusAutoConfiguration.class, // MyBatis 的自动配置类
 | 
			
		||||
            // Dynamic Datasource 配置后类
 | 
			
		||||
            DynamicDataSourceAutoConfiguration.class, //
 | 
			
		||||
            DruidDynamicDataSourceConfiguration.class, //
 | 
			
		||||
            // Redis 配置类
 | 
			
		||||
            RedisAutoConfiguration.class, // Spring Redis 自动配置类
 | 
			
		||||
            RedisConfig.class, // 自己的 Redis 配置类
 | 
			
		||||
 
 | 
			
		||||
@@ -1,24 +1,12 @@
 | 
			
		||||
package cn.iocoder.dashboard.modules.tool.dal.mysql.codegen;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.dashboard.BaseDbUnitTest;
 | 
			
		||||
import cn.iocoder.dashboard.modules.tool.dal.dataobject.codegen.ToolSchemaTableDO;
 | 
			
		||||
import org.junit.jupiter.api.Test;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import static org.junit.jupiter.api.Assertions.assertTrue;
 | 
			
		||||
 | 
			
		||||
class ToolInformationSchemaTableMapperTest extends BaseDbUnitTest {
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private ToolSchemaTableMapper toolInformationSchemaTableMapper;
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void tstSelectListByTableSchema() {
 | 
			
		||||
        List<ToolSchemaTableDO> tables = toolInformationSchemaTableMapper
 | 
			
		||||
                .selectListByTableSchema("ruoyi-vue-pro");
 | 
			
		||||
        assertTrue(tables.size() > 0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -7,12 +7,37 @@ spring:
 | 
			
		||||
 | 
			
		||||
spring:
 | 
			
		||||
  # 数据源配置项
 | 
			
		||||
  autoconfigure:
 | 
			
		||||
    exclude:
 | 
			
		||||
      - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源
 | 
			
		||||
  datasource:
 | 
			
		||||
    name: ruoyi-vue-pro
 | 
			
		||||
    url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
 | 
			
		||||
    driver-class-name: com.mysql.jdbc.Driver
 | 
			
		||||
    username: root
 | 
			
		||||
    password: 123456
 | 
			
		||||
    dynamic: # 多数据源配置
 | 
			
		||||
      druid: # Druid 【连接池】相关的全局配置
 | 
			
		||||
        initial-size: 5 # 初始连接数
 | 
			
		||||
        min-idle: 10 # 最小连接池数量
 | 
			
		||||
        max-active: 20 # 最大连接池数量
 | 
			
		||||
        max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒
 | 
			
		||||
        time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒
 | 
			
		||||
        min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒
 | 
			
		||||
        max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒
 | 
			
		||||
        validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效
 | 
			
		||||
        test-while-idle: true
 | 
			
		||||
        test-on-borrow: false
 | 
			
		||||
        test-on-return: false
 | 
			
		||||
      primary: master
 | 
			
		||||
      datasource:
 | 
			
		||||
        master:
 | 
			
		||||
          name: ruoyi-vue-pro
 | 
			
		||||
          url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
 | 
			
		||||
          driver-class-name: com.mysql.jdbc.Driver
 | 
			
		||||
          username: root
 | 
			
		||||
          password: 123456
 | 
			
		||||
        slave: # 模拟从库,可根据自己需要修改
 | 
			
		||||
          name: ruoyi-vue-pro
 | 
			
		||||
          url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
 | 
			
		||||
          driver-class-name: com.mysql.jdbc.Driver
 | 
			
		||||
          username: root
 | 
			
		||||
          password: 123456
 | 
			
		||||
 | 
			
		||||
  # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
 | 
			
		||||
  redis:
 | 
			
		||||
@@ -70,7 +95,7 @@ yudao:
 | 
			
		||||
    base-path: http://127.0.0.1:${server.port}/${yudao.web.api-prefix}/file/get/
 | 
			
		||||
  codegen:
 | 
			
		||||
    base-package: ${yudao.info.base-package}.modules
 | 
			
		||||
    db-schemas: ${spring.datasource.name}
 | 
			
		||||
    db-schemas: ${spring.datasource.dynamic.datasource.master.name}
 | 
			
		||||
  xss:
 | 
			
		||||
    enable: false
 | 
			
		||||
    exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user