数据源初始化修改,日志修改
This commit is contained in:
parent
fa509f09c8
commit
0bf189797a
|
@ -35,7 +35,23 @@
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>local</id> <!--本地环境-->
|
||||||
|
<properties>
|
||||||
|
<profile.active>local</profile.active>
|
||||||
|
</properties>
|
||||||
|
<activation>
|
||||||
|
<activeByDefault>true</activeByDefault>
|
||||||
|
</activation>
|
||||||
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>dev</id> <!--开发环境-->
|
||||||
|
<properties>
|
||||||
|
<profile.active>dev</profile.active>
|
||||||
|
</properties>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
<build>
|
<build>
|
||||||
<finalName>kangarooDataCenter</finalName>
|
<finalName>kangarooDataCenter</finalName>
|
||||||
</build>
|
</build>
|
||||||
|
|
|
@ -1,16 +1,22 @@
|
||||||
package com.hzya.frame;
|
package com.hzya.frame;
|
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceCreatorAutoConfiguration;
|
||||||
|
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.druid.DruidDynamicDataSourceConfiguration;
|
||||||
|
import com.hzya.frame.DataSource.impl.DynamicDataSourceAssistConfiguration;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
|
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
|
||||||
import org.springframework.boot.web.servlet.ServletComponentScan;
|
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||||
import org.springframework.cache.annotation.EnableCaching;
|
import org.springframework.cache.annotation.EnableCaching;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.context.annotation.ImportResource;
|
import org.springframework.context.annotation.ImportResource;
|
||||||
|
|
||||||
@EnableCaching
|
@EnableCaching
|
||||||
@ServletComponentScan(basePackages = {"com.hzya.frame"})
|
@ServletComponentScan(basePackages = {"com.hzya.frame"})
|
||||||
@ImportResource(locations = {"classpath:cfgHome/**/spring/spring-*.xml"})
|
@ImportResource(locations = {"classpath:cfgHome/**/spring/spring-*.xml"})
|
||||||
|
@Import({DruidDynamicDataSourceConfiguration.class, DynamicDataSourceCreatorAutoConfiguration.class, DynamicDataSourceAssistConfiguration.class})
|
||||||
|
|
||||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
|
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
|
||||||
//@SpringBootApplication(scanBasePackages = {"com.hzya.frame"})
|
//@SpringBootApplication(scanBasePackages = {"com.hzya.frame"})
|
||||||
public class WebappApplication {
|
public class WebappApplication {
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
#######################dev环境#######################
|
||||||
|
logging:
|
||||||
|
#日志级别 指定目录级别
|
||||||
|
level:
|
||||||
|
root: error
|
||||||
|
file:
|
||||||
|
path: /Users/apple/Desktop/log/dev
|
|
@ -0,0 +1,7 @@
|
||||||
|
#######################本地环境#######################
|
||||||
|
logging:
|
||||||
|
#日志级别 指定目录级别
|
||||||
|
level:
|
||||||
|
root: info
|
||||||
|
file:
|
||||||
|
path: /Users/apple/Desktop/log/local
|
|
@ -1,25 +0,0 @@
|
||||||
#应用名
|
|
||||||
spring.application.name=kangarooDataCenter
|
|
||||||
#端口
|
|
||||||
server.port=9999
|
|
||||||
#编码集
|
|
||||||
server.tomcat.uri-encoding=utf-8
|
|
||||||
#工程访问名称
|
|
||||||
server.servlet.context-path=/kangarooDataCenter
|
|
||||||
#json日期格式化
|
|
||||||
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
|
|
||||||
spring.jackson.time-zone=GMT+8
|
|
||||||
context.initializer.classes= com.hzya.frame.web.init.ApplicationContextInitialized
|
|
||||||
spring.batch.job.enabled = false
|
|
||||||
mybatis.mapper-locations = classpath*:com/hzya/**/*.xml
|
|
||||||
mybatis.config-location= classpath:mybatis/mybatis-config.xml
|
|
||||||
#mybatis.configuration.call-setters-on-nulls=true
|
|
||||||
|
|
||||||
#日志配置
|
|
||||||
logging.config= classpath:log/logback-spring.xml
|
|
||||||
logging.file.path = /Users/xiangerlin/work/app/logs/zhongtai
|
|
||||||
|
|
||||||
#文件最大大小
|
|
||||||
spring.servlet.multipart.enabled=true
|
|
||||||
spring.servlet.multipart.max-file-size=100MB
|
|
||||||
spring.servlet.multipart.max-request-size=100MB
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
server:
|
||||||
|
port: 9999
|
||||||
|
servlet:
|
||||||
|
context-path: /kangarooDataCenter
|
||||||
|
localIP: 127.0.0.1
|
||||||
|
tomcat:
|
||||||
|
uri-encoding: utf-8
|
||||||
|
spring:
|
||||||
|
jackson:
|
||||||
|
date-format: yyyy-MM-dd HH:mm:ss
|
||||||
|
time-zone: GMT+8
|
||||||
|
application:
|
||||||
|
name: kangarooDataCenter
|
||||||
|
# mvc:
|
||||||
|
# pathmatch:
|
||||||
|
# use-suffix-pattern: true
|
||||||
|
profiles:
|
||||||
|
# active: @profileActive@
|
||||||
|
active: @profile.active@
|
||||||
|
# active: dev
|
||||||
|
servlet:
|
||||||
|
multipart:
|
||||||
|
enabled: true
|
||||||
|
#单个文件的大小
|
||||||
|
max-file-size: 100MB
|
||||||
|
#单次请求的文件的总大小
|
||||||
|
max-request-size: 100MB
|
||||||
|
# 默认数据源设置
|
||||||
|
datasource:
|
||||||
|
dynamic:
|
||||||
|
primary: master #设置默认的数据源或者数据源组,默认值即为master
|
||||||
|
strict: true #严格匹配数据源,默认false. true未匹配到指定数据源时抛异常,false使用默认数据源
|
||||||
|
datasource:
|
||||||
|
master:
|
||||||
|
url: jdbc:mysql://hzya.ufyct.com:9096/businesscenternew?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowLoadLocalInfile=false&autoReconnect=true&failOverReadOnly=false&connectTimeout=30000&socketTimeout=30000&autoReconnectForPools=true
|
||||||
|
username: root
|
||||||
|
password: bd993088e8a7c3dc5f44441617f9b4bf
|
||||||
|
# password: hzya1314
|
||||||
|
driver-class-name: com.mysql.jdbc.Driver # 3.2.0开始支持SPI可省略此配置
|
||||||
|
druid:
|
||||||
|
initial-size: 10 # 初始化时建立物理连接的个数。初始化发生在显示调用init方法,或者第一次getConnection时
|
||||||
|
min-idle: 10 # 最小连接池数量
|
||||||
|
maxActive: 200 # 最大连接池数量
|
||||||
|
maxWait: 60000 # 获取连接时最大等待时间,单位毫秒。配置了maxWait之后,缺省启用公平锁,并发效率会有所下降,如果需要可以通过配置
|
||||||
|
timeBetweenEvictionRunsMillis: 60000 # 关闭空闲连接的检测时间间隔.Destroy线程会检测连接的间隔时间,如果连接空闲时间大于等于minEvictableIdleTimeMillis则关闭物理连接。
|
||||||
|
minEvictableIdleTimeMillis: 300000 # 连接的最小生存时间.连接保持空闲而不被驱逐的最小时间
|
||||||
|
validationQuery: SELECT 1 FROM DUAL # 验证数据库服务可用性的sql.用来检测连接是否有效的sql 因数据库方言而差, 例如 oracle 应该写成 SELECT 1 FROM DUAL
|
||||||
|
testWhileIdle: true # 申请连接时检测空闲时间,根据空闲时间再检测连接是否有效.建议配置为true,不影响性能,并且保证安全性。申请连接的时候检测,如果空闲时间大于timeBetweenEvictionRun
|
||||||
|
testOnBorrow: false # 申请连接时直接检测连接是否有效.申请连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。
|
||||||
|
testOnReturn: false # 归还连接时检测连接是否有效.归还连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。
|
||||||
|
poolPreparedStatements: true # 开启PSCache
|
||||||
|
maxPoolPreparedStatementPerConnectionSize: 20 #设置PSCache值
|
||||||
|
connectionErrorRetryAttempts: 3 # 连接出错后再尝试连接三次
|
||||||
|
breakAfterAcquireFailure: true # 数据库服务宕机自动重连机制
|
||||||
|
timeBetweenConnectErrorMillis: 300000 # 连接出错后重试时间间隔
|
||||||
|
asyncInit: true # 异步初始化策略
|
||||||
|
remove-abandoned: true # 是否自动回收超时连接
|
||||||
|
remove-abandoned-timeout: 1800 # 超时时间(以秒数为单位)
|
||||||
|
transaction-query-timeout: 6000 # 事务超时时间
|
||||||
|
filters: stat,wall,log4j2
|
||||||
|
useGlobalDataSourceStat: true #合并多个DruidDataSource的监控数据
|
||||||
|
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000 #通过connectProperties属性来打开mergeSql功能;慢SQL记录
|
||||||
|
batch:
|
||||||
|
job:
|
||||||
|
enabled: false
|
||||||
|
logging:
|
||||||
|
#日志配置路径
|
||||||
|
# config: classpath:log/logback-spring.xml
|
||||||
|
config: classpath:logback-spring.xml
|
||||||
|
file:
|
||||||
|
path: /Users/apple/Desktop/log/dev
|
||||||
|
mybatis:
|
||||||
|
mapper-locations: classpath*:com/hzya/**/*.xml
|
||||||
|
config-location: classpath:mybatis/mybatis-config.xml
|
|
@ -16,7 +16,7 @@
|
||||||
<property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%1p}) %clr(${PID:- }){magenta} %clr(--){faint} %clr([%1.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
<property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%1p}) %clr(${PID:- }){magenta} %clr(--){faint} %clr([%1.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
||||||
|
|
||||||
<!-- 定义变量 -->
|
<!-- 定义变量 -->
|
||||||
<property name="LOG_PATH" value="D:/yongansystem/kangarooDataCenter/logs" />
|
<property name="LOG_PATH" value="/Users/apple/Desktop/log" />
|
||||||
<property name="MAX_HISTORY" value="100" />
|
<property name="MAX_HISTORY" value="100" />
|
||||||
<property name="MAX_FILE_SIZE" value="100MB" />
|
<property name="MAX_FILE_SIZE" value="100MB" />
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration>
|
||||||
|
<!-- 彩色日志(IDE下载插件才可以生效) -->
|
||||||
|
<!-- 彩色日志依赖的渲染类 -->
|
||||||
|
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
|
||||||
|
<conversionRule conversionWord="wex"
|
||||||
|
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
|
||||||
|
<conversionRule conversionWord="wEx"
|
||||||
|
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
|
||||||
|
<!-- 彩色日志格式 -->
|
||||||
|
<property name="CONSOLE_LOG_PATTERN"
|
||||||
|
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%1p}) %clr(${PID:- }){magenta} %clr(--){faint} %clr([%1.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
||||||
|
<springProperty scope="context" name="logPath" source="logging.file.path" defaultValue="logdir"/>
|
||||||
|
<!--定义日志文档的存储地址 勿在 LogBack 的配置中使用相对路径-->
|
||||||
|
<property name="LOG_HOME" value="${logPath}"/>
|
||||||
|
<!-- 控制面板输出 -->
|
||||||
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息-->
|
||||||
|
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||||
|
<level>INFO</level>
|
||||||
|
</filter>
|
||||||
|
<encoder>
|
||||||
|
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
|
||||||
|
<!-- 设置字符集 -->
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 按照每天生成日志文档 -->
|
||||||
|
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<FileNamePattern>${LOG_HOME}/%d{yyyy-MM-dd}/kangarooDataCenter_%d{yyyy-MM}.log</FileNamePattern>
|
||||||
|
<!--日志文档保留天数-->
|
||||||
|
<MaxHistory>50</MaxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||||
|
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
|
||||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss} %-5level [%thread] %logger{50} - %msg%n</pattern>
|
||||||
|
</encoder>
|
||||||
|
<!--日志文档最大的大小-->
|
||||||
|
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
|
||||||
|
<MaxFileSize>50MB</MaxFileSize>
|
||||||
|
</triggeringPolicy>
|
||||||
|
</appender>
|
||||||
|
<!-- 日志输出级别 ,就是说在整个项目中,日志级别在info一上的日志都打印。 root是根日志打印器,只有一个,负责整个系统的日志输出 -->
|
||||||
|
<root level="INFO">
|
||||||
|
<!-- 控制面板输出 -->
|
||||||
|
<appender-ref ref="STDOUT"/>
|
||||||
|
<!-- 按照每天生成日志文档 -->
|
||||||
|
<appender-ref ref="FILE"/>
|
||||||
|
</root>
|
||||||
|
</configuration>
|
|
@ -1,5 +1,7 @@
|
||||||
package com.hzya.frame;
|
package com.hzya.frame;
|
||||||
|
|
||||||
|
import com.hzya.frame.util.AESUtil;
|
||||||
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
@ -14,6 +16,12 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||||
@SpringBootTest(classes = {WebappApplication.class})
|
@SpringBootTest(classes = {WebappApplication.class})
|
||||||
public class temButtom {
|
public class temButtom {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test01() {
|
||||||
|
String a = AESUtil.encrypt("hzya1314");
|
||||||
|
System.out.println(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,7 +151,7 @@ public abstract class MybatisGenericDao<E extends Serializable, PK extends Seria
|
||||||
|
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
@DS("#o.dataSourceCode")
|
||||||
@Override
|
@Override
|
||||||
public E queryOne(E o) {
|
public E queryOne(E o) {
|
||||||
E e = selectOne(o);
|
E e = selectOne(o);
|
||||||
|
|
|
@ -27,7 +27,7 @@ import java.util.Map;
|
||||||
* @Date 2023-06-13 17:56
|
* @Date 2023-06-13 17:56
|
||||||
* @Version 1.0
|
* @Version 1.0
|
||||||
*/
|
*/
|
||||||
@Configuration
|
//@Configuration
|
||||||
public class DataSourceConfig {
|
public class DataSourceConfig {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DataSourceConfig.class);
|
private static final Logger logger = LoggerFactory.getLogger(DataSourceConfig.class);
|
||||||
//dataSource容器
|
//dataSource容器
|
||||||
|
|
|
@ -26,8 +26,8 @@ import java.util.Properties;
|
||||||
* @Date: 2020/3/31 10:25
|
* @Date: 2020/3/31 10:25
|
||||||
* 数据源工具类
|
* 数据源工具类
|
||||||
*/
|
*/
|
||||||
@Component
|
//@Component
|
||||||
@Lazy(value = false)
|
//@Lazy(value = false)
|
||||||
public class DataSourceUtil {
|
public class DataSourceUtil {
|
||||||
//DATASOURCECODE
|
//DATASOURCECODE
|
||||||
public static final ThreadLocal<BaseEntity> myContextThreadLocal = new ThreadLocal<>();
|
public static final ThreadLocal<BaseEntity> myContextThreadLocal = new ThreadLocal<>();
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
* Copyright © 2018 organization baomidou
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.hzya.frame.DataSource.impl;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多数据源连接池创建事件
|
||||||
|
*
|
||||||
|
* @author TaoYu
|
||||||
|
* @since 3.5.0
|
||||||
|
*/
|
||||||
|
public interface DataSourceInitEvent {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连接池创建前执行(可用于参数解密)
|
||||||
|
*
|
||||||
|
* @param dataSourceProperty 数据源基础信息
|
||||||
|
*/
|
||||||
|
void beforeCreate(DataSourceProperty dataSourceProperty);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连接池创建后执行
|
||||||
|
*
|
||||||
|
* @param dataSource 连接池
|
||||||
|
*/
|
||||||
|
void afterCreate(DataSource dataSource);
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* Copyright © 2018 organization baomidou
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.hzya.frame.DataSource.impl;
|
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
|
||||||
|
import com.baomidou.dynamic.datasource.event.DataSourceInitEvent;
|
||||||
|
import com.baomidou.dynamic.datasource.provider.DynamicDataSourceProvider;
|
||||||
|
import com.baomidou.dynamic.datasource.strategy.DynamicDataSourceStrategy;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动态数据源核心自动配置类
|
||||||
|
*
|
||||||
|
* @author TaoYu Kanyuxia
|
||||||
|
* @see DynamicDataSourceProvider
|
||||||
|
* @see DynamicDataSourceStrategy
|
||||||
|
* @see DynamicRoutingDataSource
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class DynamicDataSourceAssistConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
public DataSourceInitEvent dataSourceInitEvent() {
|
||||||
|
return new EncDataSourceInitEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
* Copyright © 2018 organization baomidou
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.hzya.frame.DataSource.impl;
|
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.event.DataSourceInitEvent;
|
||||||
|
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty;
|
||||||
|
import com.hzya.frame.util.AESUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多数据源默认解密事件
|
||||||
|
*
|
||||||
|
* @author TaoYu
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class EncDataSourceInitEvent implements DataSourceInitEvent {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author lvleigang
|
||||||
|
* @Description 数据源初始化解密,目前只解密密码
|
||||||
|
* @Date 11:00 上午 2024/4/11
|
||||||
|
* @param dataSourceProperty
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public void beforeCreate(DataSourceProperty dataSourceProperty) {
|
||||||
|
dataSourceProperty.setPassword(AESUtil.decrypt(dataSourceProperty.getPassword()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterCreate(DataSource dataSource) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
8
pom.xml
8
pom.xml
|
@ -373,22 +373,30 @@
|
||||||
<resource>
|
<resource>
|
||||||
<directory>src/main/resources</directory>
|
<directory>src/main/resources</directory>
|
||||||
<includes>
|
<includes>
|
||||||
|
<include>**/*.yml</include>
|
||||||
<include>**/*.properties</include>
|
<include>**/*.properties</include>
|
||||||
<include>**/*.xml</include>
|
<include>**/*.xml</include>
|
||||||
<include>**/*.xmreport</include>
|
<include>**/*.xmreport</include>
|
||||||
<include>**/*.xlsx</include>
|
<include>**/*.xlsx</include>
|
||||||
<include>**/*.json</include>
|
<include>**/*.json</include>
|
||||||
<include>**/*.xdb</include>
|
<include>**/*.xdb</include>
|
||||||
|
<!-- <include>**/*.jpg</include>-->
|
||||||
|
<include>**/*.txt</include>
|
||||||
</includes>
|
</includes>
|
||||||
|
<filtering>true</filtering>
|
||||||
</resource>
|
</resource>
|
||||||
|
|
||||||
<!--扫描配置文件所在的目录-->
|
<!--扫描配置文件所在的目录-->
|
||||||
<resource>
|
<resource>
|
||||||
<directory>src/</directory>
|
<directory>src/</directory>
|
||||||
<includes>
|
<includes>
|
||||||
|
<include>**/*.yml</include>
|
||||||
<include>**/*.properties</include>
|
<include>**/*.properties</include>
|
||||||
<include>**/*.xml</include>
|
<include>**/*.xml</include>
|
||||||
<include>**/*.json</include>
|
<include>**/*.json</include>
|
||||||
|
<include>**/*.txt</include>
|
||||||
|
<!-- <include>**/*.jpg</include>-->
|
||||||
|
|
||||||
</includes>
|
</includes>
|
||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
</resource>
|
</resource>
|
||||||
|
|
|
@ -18,5 +18,7 @@ public interface ISysDataSourceDao extends IBaseDao<SysDataSourceEntity, String>
|
||||||
int queryVoList_COUNT(SysDataSourceEntity entity);
|
int queryVoList_COUNT(SysDataSourceEntity entity);
|
||||||
|
|
||||||
Integer entity_count_not_id(SysDataSourceEntity checkEntity);
|
Integer entity_count_not_id(SysDataSourceEntity checkEntity);
|
||||||
|
|
||||||
|
List<SysDataSourceVo> queryDSBase(SysDataSourceEntity entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,5 +38,12 @@ public class SysDataSourceDaoImpl extends MybatisGenericDao<SysDataSourceEntity,
|
||||||
Integer o = (Integer) super.selectOne(getSqlIdPrifx() + "entity_count_not_id", entity);
|
Integer o = (Integer) super.selectOne(getSqlIdPrifx() + "entity_count_not_id", entity);
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DS("master")
|
||||||
|
@Override
|
||||||
|
public List<SysDataSourceVo> queryDSBase(SysDataSourceEntity entity) {
|
||||||
|
List<SysDataSourceVo> o = (List<SysDataSourceVo>) super.selectList(getSqlIdPrifx() + "queryDSBase", entity);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -214,6 +214,43 @@
|
||||||
<if test=" sort == null or sort == ''.toString() ">order by sorts asc</if>
|
<if test=" sort == null or sort == ''.toString() ">order by sorts asc</if>
|
||||||
<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
|
<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="queryDSBase" resultType="com.hzya.frame.sys.dataSource.entity.SysDataSourceVo"
|
||||||
|
parameterType="com.hzya.frame.sys.dataSource.entity.SysDataSourceEntity">
|
||||||
|
select
|
||||||
|
id,
|
||||||
|
source_code as sourceCode,
|
||||||
|
source_name as sourceName,
|
||||||
|
source_ip as sourceIp,
|
||||||
|
source_port as sourcePort,
|
||||||
|
db_name as dbName,
|
||||||
|
source_type as sourceType,
|
||||||
|
login_name as loginName,
|
||||||
|
password as password,
|
||||||
|
service_name as serviceName,
|
||||||
|
use_state as useState
|
||||||
|
from sys_data_source
|
||||||
|
<trim prefix="where" prefixOverrides="and">
|
||||||
|
<if test="id != null and id != ''">and id = #{id}</if>
|
||||||
|
<if test="sourceCode != null and sourceCode != ''">and source_code = #{sourceCode}</if>
|
||||||
|
<if test="sourceName != null and sourceName != ''">and source_name = #{sourceName}</if>
|
||||||
|
<if test="sourceIp != null and sourceIp != ''">and source_ip = #{sourceIp}</if>
|
||||||
|
<if test="sourcePort != null and sourcePort != ''">and source_port = #{sourcePort}</if>
|
||||||
|
<if test="dbName != null and dbName != ''">and db_name = #{dbName}</if>
|
||||||
|
<if test="sourceType != null and sourceType != ''">and source_type = #{sourceType}</if>
|
||||||
|
<if test="loginName != null and loginName != ''">and login_name = #{loginName}</if>
|
||||||
|
<if test="password != null and password != ''">and password = #{password}</if>
|
||||||
|
<if test="serviceName != null and serviceName != ''">and service_name = #{serviceName}</if>
|
||||||
|
<if test="useState != null">and use_state = #{useState}</if>
|
||||||
|
<if test="sorts != null">and sorts = #{sorts}</if>
|
||||||
|
<if test="create_user_id != null and create_user_id != ''">and create_user_id = #{create_user_id}</if>
|
||||||
|
<if test="create_time != null">and create_time = #{create_time}</if>
|
||||||
|
<if test="modify_user_id != null and modify_user_id != ''">and modify_user_id = #{modify_user_id}</if>
|
||||||
|
<if test="modify_time != null">and modify_time = #{modify_time}</if>
|
||||||
|
<if test="sts != null and sts != ''">and sts = #{sts}</if>
|
||||||
|
<if test="org_id != null and org_id != ''">and org_id = #{org_id}</if>
|
||||||
|
and sts='Y'
|
||||||
|
</trim>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<!-- 分页查询列表 采用like格式 -->
|
<!-- 分页查询列表 采用like格式 -->
|
||||||
|
|
|
@ -190,7 +190,7 @@ public class InterfaceCache {
|
||||||
List<SysInterfaceEntity> sysInterfaceEntities = sysInterfaceDao.queryBase(sysInterfaceEntity);
|
List<SysInterfaceEntity> sysInterfaceEntities = sysInterfaceDao.queryBase(sysInterfaceEntity);
|
||||||
if(sysInterfaceEntities != null && sysInterfaceEntities.size() > 0){
|
if(sysInterfaceEntities != null && sysInterfaceEntities.size() > 0){
|
||||||
for (int i = 0; i < sysInterfaceEntities.size(); i++) {
|
for (int i = 0; i < sysInterfaceEntities.size(); i++) {
|
||||||
interfaceMap.put("beanName"+sysInterfaceEntities.get(i).getBeanName()+"interfacName"+sysInterfaceEntities.get(i).getInterfacName(), sysInterfaceEntities.get(i));
|
interfaceMap.put("beanName"+sysInterfaceEntities.get(i).getBeanName()+"interfacName"+sysInterfaceEntities.get(i).getInterfaceName(), sysInterfaceEntities.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class SysInterfaceEntity extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* 方法名
|
* 方法名
|
||||||
*/
|
*/
|
||||||
private String interfacName;
|
private String interfaceName;
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
|
@ -58,12 +58,12 @@ public class SysInterfaceEntity extends BaseEntity {
|
||||||
this.beanName = beanName;
|
this.beanName = beanName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getInterfacName() {
|
public String getInterfaceName() {
|
||||||
return interfacName;
|
return interfaceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInterfacName(String interfacName) {
|
public void setInterfaceName(String interfaceName) {
|
||||||
this.interfacName = interfacName;
|
this.interfaceName = interfaceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRemark() {
|
public String getRemark() {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<result property="id" column="id" jdbcType="VARCHAR"/>
|
<result property="id" column="id" jdbcType="VARCHAR"/>
|
||||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||||
<result property="beanName" column="bean_name" jdbcType="VARCHAR"/>
|
<result property="beanName" column="bean_name" jdbcType="VARCHAR"/>
|
||||||
<result property="interfacName" column="interfac_name" jdbcType="VARCHAR"/>
|
<result property="interfaceName" column="interface_name" jdbcType="VARCHAR"/>
|
||||||
<result property="remark" column="remark" jdbcType="VARCHAR"/>
|
<result property="remark" column="remark" jdbcType="VARCHAR"/>
|
||||||
<result property="state" column="state" jdbcType="VARCHAR"/>
|
<result property="state" column="state" jdbcType="VARCHAR"/>
|
||||||
<result property="sorts" column="sorts" jdbcType="INTEGER"/>
|
<result property="sorts" column="sorts" jdbcType="INTEGER"/>
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
id
|
id
|
||||||
,name
|
,name
|
||||||
,bean_name
|
,bean_name
|
||||||
,interfac_name
|
,interface_name
|
||||||
,remark
|
,remark
|
||||||
,state
|
,state
|
||||||
,sorts
|
,sorts
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
<if test="id != null and id != ''">and id = #{id}</if>
|
<if test="id != null and id != ''">and id = #{id}</if>
|
||||||
<if test="name != null and name != ''">and name = #{name}</if>
|
<if test="name != null and name != ''">and name = #{name}</if>
|
||||||
<if test="beanName != null and beanName != ''">and bean_name = #{beanName}</if>
|
<if test="beanName != null and beanName != ''">and bean_name = #{beanName}</if>
|
||||||
<if test="interfacName != null and interfacName != ''">and interfac_name = #{interfacName}</if>
|
<if test="interfaceName != null and interfaceName != ''">and interface_name = #{interfaceName}</if>
|
||||||
<if test="remark != null and remark != ''">and remark = #{remark}</if>
|
<if test="remark != null and remark != ''">and remark = #{remark}</if>
|
||||||
<if test="state != null and state != ''">and state = #{state}</if>
|
<if test="state != null and state != ''">and state = #{state}</if>
|
||||||
<if test="sorts != null">and sorts = #{sorts}</if>
|
<if test="sorts != null">and sorts = #{sorts}</if>
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
<if test="id != null and id != ''">and id = #{id}</if>
|
<if test="id != null and id != ''">and id = #{id}</if>
|
||||||
<if test="name != null and name != ''">and name = #{name}</if>
|
<if test="name != null and name != ''">and name = #{name}</if>
|
||||||
<if test="beanName != null and beanName != ''">and bean_name = #{beanName}</if>
|
<if test="beanName != null and beanName != ''">and bean_name = #{beanName}</if>
|
||||||
<if test="interfacName != null and interfacName != ''">and interfac_name = #{interfacName}</if>
|
<if test="interfaceName != null and interfaceName != ''">and interface_name = #{interfaceName}</if>
|
||||||
<if test="remark != null and remark != ''">and remark = #{remark}</if>
|
<if test="remark != null and remark != ''">and remark = #{remark}</if>
|
||||||
<if test="state != null and state != ''">and state = #{state}</if>
|
<if test="state != null and state != ''">and state = #{state}</if>
|
||||||
<if test="sorts != null">and sorts = #{sorts}</if>
|
<if test="sorts != null">and sorts = #{sorts}</if>
|
||||||
|
@ -96,8 +96,8 @@
|
||||||
<if test="id != null and id != ''">and id like concat('%',#{id},'%')</if>
|
<if test="id != null and id != ''">and id like concat('%',#{id},'%')</if>
|
||||||
<if test="name != null and name != ''">and name like concat('%',#{name},'%')</if>
|
<if test="name != null and name != ''">and name like concat('%',#{name},'%')</if>
|
||||||
<if test="beanName != null and beanName != ''">and bean_name like concat('%',#{beanName},'%')</if>
|
<if test="beanName != null and beanName != ''">and bean_name like concat('%',#{beanName},'%')</if>
|
||||||
<if test="interfacName != null and interfacName != ''">and interfac_name like
|
<if test="interfaceName != null and interfaceName != ''">and interface_name like
|
||||||
concat('%',#{interfacName},'%')
|
concat('%',#{interfaceName},'%')
|
||||||
</if>
|
</if>
|
||||||
<if test="remark != null and remark != ''">and remark like concat('%',#{remark},'%')</if>
|
<if test="remark != null and remark != ''">and remark like concat('%',#{remark},'%')</if>
|
||||||
<if test="state != null and state != ''">and state like concat('%',#{state},'%')</if>
|
<if test="state != null and state != ''">and state like concat('%',#{state},'%')</if>
|
||||||
|
@ -129,7 +129,7 @@
|
||||||
<if test="id != null and id != ''">or id = #{id}</if>
|
<if test="id != null and id != ''">or id = #{id}</if>
|
||||||
<if test="name != null and name != ''">or name = #{name}</if>
|
<if test="name != null and name != ''">or name = #{name}</if>
|
||||||
<if test="beanName != null and beanName != ''">or bean_name = #{beanName}</if>
|
<if test="beanName != null and beanName != ''">or bean_name = #{beanName}</if>
|
||||||
<if test="interfacName != null and interfacName != ''">or interfac_name = #{interfacName}</if>
|
<if test="interfaceName != null and interfaceName != ''">or interface_name = #{interfaceName}</if>
|
||||||
<if test="remark != null and remark != ''">or remark = #{remark}</if>
|
<if test="remark != null and remark != ''">or remark = #{remark}</if>
|
||||||
<if test="state != null and state != ''">or state = #{state}</if>
|
<if test="state != null and state != ''">or state = #{state}</if>
|
||||||
<if test="sorts != null">or sorts = #{sorts}</if>
|
<if test="sorts != null">or sorts = #{sorts}</if>
|
||||||
|
@ -154,7 +154,7 @@
|
||||||
<if test="id != null and id != ''">id ,</if>
|
<if test="id != null and id != ''">id ,</if>
|
||||||
<if test="name != null and name != ''">name ,</if>
|
<if test="name != null and name != ''">name ,</if>
|
||||||
<if test="beanName != null and beanName != ''">bean_name ,</if>
|
<if test="beanName != null and beanName != ''">bean_name ,</if>
|
||||||
<if test="interfacName != null and interfacName != ''">interfac_name ,</if>
|
<if test="interfaceName != null and interfaceName != ''">interface_name ,</if>
|
||||||
<if test="remark != null and remark != ''">remark ,</if>
|
<if test="remark != null and remark != ''">remark ,</if>
|
||||||
<if test="state != null and state != ''">state ,</if>
|
<if test="state != null and state != ''">state ,</if>
|
||||||
<if test="sorts != null">sorts ,</if>
|
<if test="sorts != null">sorts ,</if>
|
||||||
|
@ -173,7 +173,7 @@
|
||||||
<if test="id != null and id != ''">#{id} ,</if>
|
<if test="id != null and id != ''">#{id} ,</if>
|
||||||
<if test="name != null and name != ''">#{name} ,</if>
|
<if test="name != null and name != ''">#{name} ,</if>
|
||||||
<if test="beanName != null and beanName != ''">#{beanName} ,</if>
|
<if test="beanName != null and beanName != ''">#{beanName} ,</if>
|
||||||
<if test="interfacName != null and interfacName != ''">#{interfacName} ,</if>
|
<if test="interfaceName != null and interfaceName != ''">#{interfaceName} ,</if>
|
||||||
<if test="remark != null and remark != ''">#{remark} ,</if>
|
<if test="remark != null and remark != ''">#{remark} ,</if>
|
||||||
<if test="state != null and state != ''">#{state} ,</if>
|
<if test="state != null and state != ''">#{state} ,</if>
|
||||||
<if test="sorts != null">#{sorts} ,</if>
|
<if test="sorts != null">#{sorts} ,</if>
|
||||||
|
@ -193,26 +193,26 @@
|
||||||
</insert>
|
</insert>
|
||||||
<!-- 批量新增 -->
|
<!-- 批量新增 -->
|
||||||
<insert id="entityInsertBatch" >
|
<insert id="entityInsertBatch" >
|
||||||
insert into sys_interface(name, bean_name, interfac_name, remark, state, create_user_id, create_time,
|
insert into sys_interface(name, bean_name, interface_name, remark, state, create_user_id, create_time,
|
||||||
modify_user_id, modify_time, sts, org_id, company_id, sts)
|
modify_user_id, modify_time, sts, org_id, company_id, sts)
|
||||||
values
|
values
|
||||||
<foreach collection="entities" item="entity" separator=",">
|
<foreach collection="entities" item="entity" separator=",">
|
||||||
(#{entity.name},#{entity.beanName},#{entity.interfacName},#{entity.remark},#{entity.state},#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id},#{entity.companyId},
|
(#{entity.name},#{entity.beanName},#{entity.interfaceName},#{entity.remark},#{entity.state},#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id},#{entity.companyId},
|
||||||
'Y')
|
'Y')
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
<!-- 批量新增或者修改-->
|
<!-- 批量新增或者修改-->
|
||||||
<insert id="entityInsertOrUpdateBatch" >
|
<insert id="entityInsertOrUpdateBatch" >
|
||||||
insert into sys_interface(name, bean_name, interfac_name, remark, state, create_user_id, create_time,
|
insert into sys_interface(name, bean_name, interface_name, remark, state, create_user_id, create_time,
|
||||||
modify_user_id, modify_time, sts, org_id, company_id)
|
modify_user_id, modify_time, sts, org_id, company_id)
|
||||||
values
|
values
|
||||||
<foreach collection="entities" item="entity" separator=",">
|
<foreach collection="entities" item="entity" separator=",">
|
||||||
(#{entity.name},#{entity.beanName},#{entity.interfacName},#{entity.remark},#{entity.state},#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id},#{entity.companyId})
|
(#{entity.name},#{entity.beanName},#{entity.interfaceName},#{entity.remark},#{entity.state},#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id},#{entity.companyId})
|
||||||
</foreach>
|
</foreach>
|
||||||
on duplicate key update
|
on duplicate key update
|
||||||
name = values(name),
|
name = values(name),
|
||||||
bean_name = values(bean_name),
|
bean_name = values(bean_name),
|
||||||
interfac_name = values(interfac_name),
|
interface_name = values(interface_name),
|
||||||
remark = values(remark),
|
remark = values(remark),
|
||||||
state = values(state),
|
state = values(state),
|
||||||
create_user_id = values(create_user_id),
|
create_user_id = values(create_user_id),
|
||||||
|
@ -229,7 +229,7 @@
|
||||||
<trim suffix="" suffixOverrides=",">
|
<trim suffix="" suffixOverrides=",">
|
||||||
<if test="name != null and name != ''">name = #{name},</if>
|
<if test="name != null and name != ''">name = #{name},</if>
|
||||||
<if test="beanName != null and beanName != ''">bean_name = #{beanName},</if>
|
<if test="beanName != null and beanName != ''">bean_name = #{beanName},</if>
|
||||||
<if test="interfacName != null and interfacName != ''">interfac_name = #{interfacName},</if>
|
<if test="interfaceName != null and interfaceName != ''">interface_name = #{interfaceName},</if>
|
||||||
<if test="remark != null and remark != ''">remark = #{remark},</if>
|
<if test="remark != null and remark != ''">remark = #{remark},</if>
|
||||||
<if test="state != null and state != ''">state = #{state},</if>
|
<if test="state != null and state != ''">state = #{state},</if>
|
||||||
<if test="create_user_id != null and create_user_id != ''">create_user_id = #{create_user_id},</if>
|
<if test="create_user_id != null and create_user_id != ''">create_user_id = #{create_user_id},</if>
|
||||||
|
@ -255,7 +255,7 @@ where id = #{id}
|
||||||
<if test="id != null and id != ''">and id = #{id}</if>
|
<if test="id != null and id != ''">and id = #{id}</if>
|
||||||
<if test="name != null and name != ''">and name = #{name}</if>
|
<if test="name != null and name != ''">and name = #{name}</if>
|
||||||
<if test="beanName != null and beanName != ''">and bean_name = #{beanName}</if>
|
<if test="beanName != null and beanName != ''">and bean_name = #{beanName}</if>
|
||||||
<if test="interfacName != null and interfacName != ''">and interfac_name = #{interfacName}</if>
|
<if test="interfaceName != null and interfaceName != ''">and interface_name = #{interfaceName}</if>
|
||||||
<if test="remark != null and remark != ''">and remark = #{remark}</if>
|
<if test="remark != null and remark != ''">and remark = #{remark}</if>
|
||||||
<if test="state != null and state != ''">and state = #{state}</if>
|
<if test="state != null and state != ''">and state = #{state}</if>
|
||||||
<if test="sorts != null">and sorts = #{sorts}</if>
|
<if test="sorts != null">and sorts = #{sorts}</if>
|
||||||
|
|
|
@ -98,7 +98,7 @@ public class SysInterfaceServiceImpl extends BaseService<SysInterfaceEntity, Str
|
||||||
if (entity.getBeanName() == null || "".equals(entity.getBeanName())) {
|
if (entity.getBeanName() == null || "".equals(entity.getBeanName())) {
|
||||||
return BaseResult.getFailureMessageEntity("请先输入服务名");
|
return BaseResult.getFailureMessageEntity("请先输入服务名");
|
||||||
}
|
}
|
||||||
if (entity.getInterfacName() == null || "".equals(entity.getInterfacName())) {
|
if (entity.getInterfaceName() == null || "".equals(entity.getInterfaceName())) {
|
||||||
return BaseResult.getFailureMessageEntity("请先输入方法名");
|
return BaseResult.getFailureMessageEntity("请先输入方法名");
|
||||||
}
|
}
|
||||||
if(!checksave(entity)){
|
if(!checksave(entity)){
|
||||||
|
@ -121,7 +121,7 @@ public class SysInterfaceServiceImpl extends BaseService<SysInterfaceEntity, Str
|
||||||
private boolean checksave(SysInterfaceEntity entity) {
|
private boolean checksave(SysInterfaceEntity entity) {
|
||||||
SysInterfaceEntity checkEntity = new SysInterfaceEntity();
|
SysInterfaceEntity checkEntity = new SysInterfaceEntity();
|
||||||
checkEntity.setBeanName(entity.getBeanName());
|
checkEntity.setBeanName(entity.getBeanName());
|
||||||
checkEntity.setInterfacName(entity.getInterfacName());
|
checkEntity.setInterfaceName(entity.getInterfaceName());
|
||||||
if(sysInterfaceDao.getCount(checkEntity) > 0){
|
if(sysInterfaceDao.getCount(checkEntity) > 0){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ public class SysInterfaceServiceImpl extends BaseService<SysInterfaceEntity, Str
|
||||||
if (entity.getBeanName() == null || "".equals(entity.getBeanName())) {
|
if (entity.getBeanName() == null || "".equals(entity.getBeanName())) {
|
||||||
return BaseResult.getFailureMessageEntity("请先输入服务名");
|
return BaseResult.getFailureMessageEntity("请先输入服务名");
|
||||||
}
|
}
|
||||||
if (entity.getInterfacName() == null || "".equals(entity.getInterfacName())) {
|
if (entity.getInterfaceName() == null || "".equals(entity.getInterfaceName())) {
|
||||||
return BaseResult.getFailureMessageEntity("请先输入方法名");
|
return BaseResult.getFailureMessageEntity("请先输入方法名");
|
||||||
}
|
}
|
||||||
entity.setUpdate();
|
entity.setUpdate();
|
||||||
|
|
|
@ -35,16 +35,16 @@ public class MyApplicationListener implements ApplicationListener<ApplicationRea
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
|
public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
|
||||||
logger.info("***初始化数据源*******");
|
//logger.info("***初始化数据源*******");
|
||||||
DynamicRoutingDataSource ds = (DynamicRoutingDataSource) dataSource;
|
//DynamicRoutingDataSource ds = (DynamicRoutingDataSource) dataSource;
|
||||||
DruidDataSource defaultDataSource = createDefaultDataSource(getDefaultDataSourceJsonObject());
|
//DruidDataSource defaultDataSource = createDefaultDataSource(getDefaultDataSourceJsonObject());
|
||||||
//创建SqlSessionFactory,添加到MAP缓存
|
////创建SqlSessionFactory,添加到MAP缓存
|
||||||
DataSourceUtil.createSqlSessionFactoryToCache("master", defaultDataSource);
|
//DataSourceUtil.createSqlSessionFactoryToCache("master", defaultDataSource);
|
||||||
ds.addDataSource("master", defaultDataSource);
|
//ds.addDataSource("master", defaultDataSource);
|
||||||
ds.setPrimary("master");
|
//ds.setPrimary("master");
|
||||||
ds.setStrict(true);
|
//ds.setStrict(true);
|
||||||
logger.info("***初始化数据源成功!数据源编码:master ya251 *********");
|
//logger.info("***初始化数据源成功!数据源编码:master ya251 *********");
|
||||||
//数据源初始化完成后,执行初始化定时任务
|
////数据源初始化完成后,执行初始化定时任务
|
||||||
initTask();
|
initTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,9 @@ public class EntranceServiceImpl implements IEntranceService {
|
||||||
String body = ServletUtil.getBody(servletRequest);
|
String body = ServletUtil.getBody(servletRequest);
|
||||||
//获取类
|
//获取类
|
||||||
Object object = null;
|
Object object = null;
|
||||||
|
if(service == null || "".equals(service) || serviceMethod == null || "".equals(serviceMethod)){
|
||||||
|
return BaseResult.getFailureMessageEntity("非法请求,请检查");
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
object = ApplicationContextUtil.getBeanByName(service);
|
object = ApplicationContextUtil.getBeanByName(service);
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import com.hzya.frame.datasource.DataSourceUtilProperties;
|
||||||
import com.hzya.frame.sys.dataSource.dao.ISysDataSourceDao;
|
import com.hzya.frame.sys.dataSource.dao.ISysDataSourceDao;
|
||||||
import com.hzya.frame.sys.dataSource.entity.SysDataSourceEntity;
|
import com.hzya.frame.sys.dataSource.entity.SysDataSourceEntity;
|
||||||
import com.hzya.frame.sys.dataSource.entity.SysDataSourceVo;
|
import com.hzya.frame.sys.dataSource.entity.SysDataSourceVo;
|
||||||
|
import com.hzya.frame.util.AESUtil;
|
||||||
import com.hzya.frame.web.entity.BaseEntity;
|
import com.hzya.frame.web.entity.BaseEntity;
|
||||||
import com.hzya.frame.web.exception.BaseSystemException;
|
import com.hzya.frame.web.exception.BaseSystemException;
|
||||||
import org.aspectj.lang.JoinPoint;
|
import org.aspectj.lang.JoinPoint;
|
||||||
|
@ -32,7 +33,6 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@Aspect
|
@Aspect
|
||||||
@Component
|
@Component
|
||||||
//@Order(1)
|
|
||||||
public class AopDynamicRoutingDataSourceInit {
|
public class AopDynamicRoutingDataSourceInit {
|
||||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -68,7 +68,7 @@ public class AopDynamicRoutingDataSourceInit {
|
||||||
entity.setSts("Y");
|
entity.setSts("Y");
|
||||||
entity.setUseState(1);
|
entity.setUseState(1);
|
||||||
entity.setSourceCode(dsValue);
|
entity.setSourceCode(dsValue);
|
||||||
List<SysDataSourceVo> sysDataSourceEntities = sysDataSourceDao.queryVoList(entity);
|
List<SysDataSourceVo> sysDataSourceEntities = sysDataSourceDao.queryDSBase(entity);
|
||||||
logger.info("beforeDynamicRoutingDataSourceInitMethod:根据dsValue获取数据源信息查询结果 sysDataSourceEntities.size:" + sysDataSourceEntities.size());
|
logger.info("beforeDynamicRoutingDataSourceInitMethod:根据dsValue获取数据源信息查询结果 sysDataSourceEntities.size:" + sysDataSourceEntities.size());
|
||||||
if (sysDataSourceEntities != null && sysDataSourceEntities.size() > 0) {
|
if (sysDataSourceEntities != null && sysDataSourceEntities.size() > 0) {
|
||||||
for (int i = 0; i < sysDataSourceEntities.size(); i++) {
|
for (int i = 0; i < sysDataSourceEntities.size(); i++) {
|
||||||
|
@ -77,14 +77,13 @@ public class AopDynamicRoutingDataSourceInit {
|
||||||
defaultDataSourceProperties.put("source_url", sysDataSourceEntities.get(i).getSourceUrl());
|
defaultDataSourceProperties.put("source_url", sysDataSourceEntities.get(i).getSourceUrl());
|
||||||
defaultDataSourceProperties.put("source_type", sysDataSourceEntities.get(i).getSourceTypeName());
|
defaultDataSourceProperties.put("source_type", sysDataSourceEntities.get(i).getSourceTypeName());
|
||||||
defaultDataSourceProperties.put("login_name", sysDataSourceEntities.get(i).getLoginName());
|
defaultDataSourceProperties.put("login_name", sysDataSourceEntities.get(i).getLoginName());
|
||||||
defaultDataSourceProperties.put("password", sysDataSourceEntities.get(i).getPassword());
|
defaultDataSourceProperties.put("password", AESUtil.decrypt(sysDataSourceEntities.get(i).getPassword()));
|
||||||
|
//defaultDataSourceProperties.put("password", sysDataSourceEntities.get(i).getPassword());
|
||||||
defaultDataSourceProperties.put("db_name", sysDataSourceEntities.get(i).getDbName());
|
defaultDataSourceProperties.put("db_name", sysDataSourceEntities.get(i).getDbName());
|
||||||
try {
|
try {
|
||||||
logger.info("***初始化数据源-{}:*********", sysDataSourceEntities.get(i).getSourceName());
|
logger.info("***初始化数据源-{}:*********", sysDataSourceEntities.get(i).getSourceName());
|
||||||
DruidDataSource dataSource = createDefaultDataSource(defaultDataSourceProperties);
|
DruidDataSource dataSource = createDefaultDataSource(defaultDataSourceProperties);
|
||||||
ds.addDataSource(sysDataSourceEntities.get(i).getSourceCode(), dataSource);
|
ds.addDataSource(sysDataSourceEntities.get(i).getSourceCode(), dataSource);
|
||||||
//把datasource放入缓存中
|
|
||||||
// DataSourceUtil.createSqlSessionFactoryToCache(sysDataSourceEntities.get(i).getSourceCode(),dataSource);
|
|
||||||
logger.info("***初始化数据源-{}成功:*********", sysDataSourceEntities.get(i).getSourceName());
|
logger.info("***初始化数据源-{}成功:*********", sysDataSourceEntities.get(i).getSourceName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.info("***初始化数据源-{}失败:*********", sysDataSourceEntities.get(i).getSourceName());
|
logger.info("***初始化数据源-{}失败:*********", sysDataSourceEntities.get(i).getSourceName());
|
||||||
|
|
|
@ -32,7 +32,6 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Order(999)
|
|
||||||
public class InitCommandLineRunner implements ApplicationListener<ApplicationReadyEvent> {
|
public class InitCommandLineRunner implements ApplicationListener<ApplicationReadyEvent> {
|
||||||
|
|
||||||
Logger logger = LoggerFactory.getLogger(InitCommandLineRunner.class);
|
Logger logger = LoggerFactory.getLogger(InitCommandLineRunner.class);
|
||||||
|
|
Loading…
Reference in New Issue