From 431687b00ef26a11cd0be4b703d46ac0232c6fa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Wed, 11 Mar 2020 15:34:05 +0800 Subject: [PATCH] =?UTF-8?q?:recycle:=20Refactoring=20code.=20=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=BA=90=E7=AE=A1=E7=90=86=EF=BC=8C=E4=B8=8D=E5=9C=A8?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=BC=95=E5=85=A5=E6=95=B0=E6=8D=AE=E6=BA=90?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/8pigxx_codegen.sql | 11 ----------- .../config/JdbcDynamicDataSourceProvider.java | 7 +++++++ .../datasource/support/DataSourceConstants.java | 5 +++++ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/db/8pigxx_codegen.sql b/db/8pigxx_codegen.sql index 86a79313e..47da6fc18 100644 --- a/db/8pigxx_codegen.sql +++ b/db/8pigxx_codegen.sql @@ -20,17 +20,6 @@ CREATE TABLE `gen_datasource_conf` ( PRIMARY KEY (`id`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='数据源表'; --- ---------------------------- --- Records of gen_datasource_conf --- ---------------------------- -BEGIN; -INSERT INTO `gen_datasource_conf` VALUES (1, 'master', 'jdbc:mysql://pigx-mysql:3306/pigxx_codegen?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true', 'root', 'hyxlg2iaqpDLOe9qEcv2xQ==', '2019-08-12 15:47:39', '2019-08-12 15:47:39', '0', 1); -INSERT INTO `gen_datasource_conf` VALUES (2, 'pigxx_core', 'jdbc:mysql://pigx-mysql:3306/pigxx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true', 'root', 'Cx+ocw0iFCpae4Qo4IoFmQ==', '2019-03-31 16:40:43', '2019-06-13 03:07:24', '0', 1); -INSERT INTO `gen_datasource_conf` VALUES (3, 'pigxx_ac', 'jdbc:mysql://pigx-mysql:3306/pigxx_ac?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8', 'root', 'Cx+ocw0iFCpae4Qo4IoFmQ==', '2019-03-31 17:53:25', '2019-06-13 03:07:25', '0', 1); -INSERT INTO `gen_datasource_conf` VALUES (4, 'pigxx_job', 'jdbc:mysql://pigx-mysql:3306/pigxx_job?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8', 'root', 'Cx+ocw0iFCpae4Qo4IoFmQ==', '2019-03-31 17:53:25', '2019-06-13 03:07:26', '0', 1); -INSERT INTO `gen_datasource_conf` VALUES (5, 'pigxx_mp', 'jdbc:mysql://pigx-mysql:3306/pigxx_mp?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8', 'root', 'Cx+ocw0iFCpae4Qo4IoFmQ==', '2019-03-31 17:53:25', '2019-06-13 03:07:28', '0', 1); -INSERT INTO `gen_datasource_conf` VALUES (6, 'pigxx_pay', 'jdbc:mysql://pigx-mysql:3306/pigxx_pay?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8', 'root', 'Cx+ocw0iFCpae4Qo4IoFmQ==', '2019-03-31 17:53:25', '2019-06-13 03:07:30', '0', 1); -COMMIT; -- ---------------------------- -- Table structure for gen_form_conf diff --git a/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/JdbcDynamicDataSourceProvider.java b/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/JdbcDynamicDataSourceProvider.java index b8706e57e..621426c87 100644 --- a/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/JdbcDynamicDataSourceProvider.java +++ b/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/JdbcDynamicDataSourceProvider.java @@ -70,6 +70,13 @@ public class JdbcDynamicDataSourceProvider extends AbstractJdbcDataSourceProvide property.setUrl(url); map.put(name, property); } + + // 添加默认主数据源 + DataSourceProperty property = new DataSourceProperty(); + property.setUsername(properties.getUsername()); + property.setPassword(properties.getPassword()); + property.setUrl(properties.getUrl()); + map.put(DataSourceConstants.DS_MASTER, property); return map; } } diff --git a/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/support/DataSourceConstants.java b/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/support/DataSourceConstants.java index 3d23df3e8..620554711 100644 --- a/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/support/DataSourceConstants.java +++ b/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/support/DataSourceConstants.java @@ -17,6 +17,11 @@ public interface DataSourceConstants { */ String DS_NAME = "name"; + /** + * 默认数据源(master) + */ + String DS_MASTER = "master"; + /** * jdbcurl */