♻️ Refactoring code. pigx-common-ds 依赖项调整
This commit is contained in:
1 parent
431687b00e
commit
660cc073e9
6 files changed
+22
-65
No files matched your search
@@ -17,70 +17,16 @@
|
||||
<description>pigx 动态切换数据源</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-webmvc</artifactId>
|
||||
</dependency>
|
||||
<!--common-->
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-core</artifactId>
|
||||
</dependency>
|
||||
<!--mybatis-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
<!-- druid 连接池 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<!--swagger-->
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-swagger</artifactId>
|
||||
</dependency>
|
||||
<!--安全模块-->
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-log</artifactId>
|
||||
</dependency>
|
||||
<!--代码生成模板引擎-->
|
||||
<dependency>
|
||||
<artifactId>velocity</artifactId>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<version>${velocity.version}</version>
|
||||
</dependency>
|
||||
<!--web 模块-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<!--undertow容器-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-undertow</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
+17
-1
@@ -14,13 +14,29 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
@ConfigurationProperties("spring.datasource.druid")
|
||||
public class DruidDataSourceProperties {
|
||||
|
||||
/**
|
||||
* 数据源用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 数据源密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* jdbcurl
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 数据源驱动
|
||||
*/
|
||||
private String driverClassName;
|
||||
|
||||
/**
|
||||
* 查询数据源的SQL
|
||||
*/
|
||||
private String queryDsSql;
|
||||
private String queryDsSql = "select * from gen_datasource_conf where del_flag = 0";
|
||||
}
|
||||
+1
-4
@@ -17,7 +17,6 @@
|
||||
|
||||
package com.pig4cloud.pigx.common.datasource.config;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.dynamic.datasource.provider.AbstractJdbcDataSourceProvider;
|
||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty;
|
||||
import com.pig4cloud.pigx.common.datasource.support.DataSourceConstants;
|
||||
@@ -54,9 +53,7 @@ public class JdbcDynamicDataSourceProvider extends AbstractJdbcDataSourceProvide
|
||||
*/
|
||||
@Override
|
||||
protected Map<String, DataSourceProperty> executeStmt(Statement statement) throws SQLException {
|
||||
ResultSet rs = statement.executeQuery(StrUtil.isBlank(properties.getQueryDsSql())
|
||||
? DataSourceConstants.QUERY_DS_SQL
|
||||
: properties.getQueryDsSql());
|
||||
ResultSet rs = statement.executeQuery(properties.getQueryDsSql());
|
||||
|
||||
Map<String, DataSourceProperty> map = new HashMap<>(8);
|
||||
while (rs.next()) {
|
||||
|
||||
-4
@@ -7,10 +7,6 @@ package com.pig4cloud.pigx.common.datasource.support;
|
||||
* 数据源相关常量
|
||||
*/
|
||||
public interface DataSourceConstants {
|
||||
/**
|
||||
* 查询数据源的SQL
|
||||
*/
|
||||
String QUERY_DS_SQL = "select * from gen_datasource_conf where del_flag = 0";
|
||||
|
||||
/**
|
||||
* 数据源名称
|
||||
|
||||
+2
@@ -48,6 +48,7 @@ public interface GeneratorMapper {
|
||||
* 查询表信息
|
||||
*
|
||||
* @param tableName 表名称
|
||||
* @param dsName 数据源名称
|
||||
* @return
|
||||
*/
|
||||
@DS("#last")
|
||||
@@ -57,6 +58,7 @@ public interface GeneratorMapper {
|
||||
* 查询表列信息
|
||||
*
|
||||
* @param tableName 表名称
|
||||
* @param dsName 数据源名称
|
||||
* @return
|
||||
*/
|
||||
@DS("#last")
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<spring-boot-admin.version>2.2.2</spring-boot-admin.version>
|
||||
<hutool.version>5.1.5</hutool.version>
|
||||
<hutool.version>5.2.0</hutool.version>
|
||||
<kaptcha.version>1.6.2</kaptcha.version>
|
||||
<swagger.fox.version>2.9.2</swagger.fox.version>
|
||||
<knife4j.version>2.0.2</knife4j.version>
|
||||
|
||||
Reference in new issue
Block a user