🎨 Improving structure / format of the code.

This commit is contained in:
萌萌哒Sakura酱 committed 2019-04-20 17:41:00 +08:00
1 parent 5c11d79deb
commit 1964b7f7c9
7 files changed
+27 -56

No files matched your search

+2 -2
View File
@@ -10,8 +10,8 @@ create database `pigxx_zipkin` default character set utf8mb4 collate utf8mb4_gen
-- pigx 任务相关库
create database `pigxx_job` default character set utf8mb4 collate utf8mb4_general_ci;
-- pigx 公众号管理模块
-- pigx 公众号管理相关库
create database `pigxx_mp` default character set utf8mb4 collate utf8mb4_general_ci;
-- pigx 公众号管理模块
-- pigx nacos配置相关库
create database `pigxx_config` default character set utf8mb4 collate utf8mb4_general_ci;
@@ -16,7 +16,7 @@
package com.alibaba.nacos;
import com.alibaba.nacos.console.config.ConfigConstant;
import com.alibaba.nacos.console.config.ConfigConstants;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
@@ -32,7 +32,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
public class PigxNacosApplication {
public static void main(String[] args) {
System.setProperty(ConfigConstant.STANDALONE_MODE, "true");
System.setProperty(ConfigConstants.STANDALONE_MODE, "true");
SpringApplication.run(PigxNacosApplication.class, args);
}
}
@@ -1,40 +0,0 @@
package com.alibaba.nacos.console.config;
/**
* @author lengleng
* @date 2019-04-19
* <p>
* 覆盖nacos 默认配置
*/
public interface ConfigConstant {
/**
* The System property name of Standalone mode
*/
String STANDALONE_MODE = "nacos.standalone";
/**
* 环境变量
*/
String USER_HOME = "user.home";
/**
* nacos 日志路径配置
*/
String NACOS_LOGS_PATH = "nacos.logs.path";
/**
* nacos 家目录
*/
String NACOS_HOME = "nacos.home";
/**
* tomcat 目录
*/
String TOMCAT_DIR = "server.tomcat.basedir";
/**
* tomcat 日志配置
*/
String TOMCAT_ACCESS_LOG = "server.tomcat.accesslog.enabled";
}
@@ -0,0 +1,15 @@
package com.alibaba.nacos.console.config;
/**
* @author lengleng
* @date 2019-04-19
* <p>
* 覆盖nacos 默认配置
*/
public interface ConfigConstants {
/**
* The System property name of Standalone mode
*/
String STANDALONE_MODE = "nacos.standalone";
}
@@ -1,5 +1,4 @@
nacos:
port: 8849
cmdb:
dumpTaskInterval: 3600
eventTaskInterval: 10
@@ -14,12 +13,9 @@ db:
url:
0: jdbc:mysql://127.0.0.1:3306/pigxx_config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
# 关闭nacos 登录
spring:
datasource:
platform: mysql
security:
enabled: false
server:
tomcat:
@@ -1,7 +1,7 @@
package com.pig4cloud.pigx.codegen.config;
import com.mysql.cj.jdbc.Driver;
import com.pig4cloud.pigx.codegen.util.DataSourceConstant;
import com.pig4cloud.pigx.codegen.util.DataSourceConstants;
import com.zaxxer.hikari.HikariDataSource;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -60,18 +60,18 @@ public class DynamicDataSourceConfig implements TransactionManagementConfigurer
dds.setUsername(dataSourceProperties.getUsername());
dds.setPassword(dataSourceProperties.getPassword());
List<Map<String, Object>> dbList = new JdbcTemplate(dds).queryForList(DataSourceConstant.QUERY_DS_SQL);
List<Map<String, Object>> dbList = new JdbcTemplate(dds).queryForList(DataSourceConstants.QUERY_DS_SQL);
log.info("开始 -> 初始化动态数据源");
Optional.of(dbList).ifPresent(list -> list.forEach(db -> {
log.info("数据源:{}", db.get(DataSourceConstant.DS_NAME));
log.info("数据源:{}", db.get(DataSourceConstants.DS_NAME));
HikariDataSource ds = new HikariDataSource();
ds.setJdbcUrl(String.valueOf(db.get(DataSourceConstant.DS_JDBC_URL)));
ds.setJdbcUrl(String.valueOf(db.get(DataSourceConstants.DS_JDBC_URL)));
ds.setDriverClassName(Driver.class.getName());
ds.setUsername((String) db.get(DataSourceConstant.DS_USER_NAME));
ds.setUsername((String) db.get(DataSourceConstants.DS_USER_NAME));
String decPwd = stringEncryptor.decrypt((String) db.get(DataSourceConstant.DS_USER_PWD));
String decPwd = stringEncryptor.decrypt((String) db.get(DataSourceConstants.DS_USER_PWD));
ds.setPassword(decPwd);
dataSourceMap.put(db.get(DataSourceConstant.DS_ROUTE_KEY), ds);
dataSourceMap.put(db.get(DataSourceConstants.DS_ROUTE_KEY), ds);
}));
log.info("完毕 -> 初始化动态数据源,共计 {} 条", dataSourceMap.size());
@@ -6,7 +6,7 @@ package com.pig4cloud.pigx.codegen.util;
* <p>
* 数据源相关常量
*/
public interface DataSourceConstant {
public interface DataSourceConstants {
/**
* 查询数据源的SQL
*/