|
@@ -40,6 +40,11 @@ public class SystemInit {
|
|
@Value("${app.debug:false}")
|
|
@Value("${app.debug:false}")
|
|
private boolean debug = true;
|
|
private boolean debug = true;
|
|
|
|
|
|
|
|
+ @Value("${app.enable-flyway:false}")
|
|
|
|
+ private boolean enableFlyway = false;
|
|
|
|
+ @Value("${app.enable-reset-config:false}")
|
|
|
|
+ private boolean enableResetConfig = false;
|
|
|
|
+
|
|
public SystemInit(ResourcePatternResolver resourcePatternResolver) {
|
|
public SystemInit(ResourcePatternResolver resourcePatternResolver) {
|
|
this.resourcePatternResolver = resourcePatternResolver;
|
|
this.resourcePatternResolver = resourcePatternResolver;
|
|
}
|
|
}
|
|
@@ -52,7 +57,14 @@ public class SystemInit {
|
|
Config.setCenterConnectionStr(DataEncryptionUtil.decryptRSAByPrivateKey(centerConfig));
|
|
Config.setCenterConnectionStr(DataEncryptionUtil.decryptRSAByPrivateKey(centerConfig));
|
|
Config.setSecurityConnectionStr(DataEncryptionUtil.decryptRSAByPrivateKey(securityConfig));
|
|
Config.setSecurityConnectionStr(DataEncryptionUtil.decryptRSAByPrivateKey(securityConfig));
|
|
// 初始化数据结构
|
|
// 初始化数据结构
|
|
-// migrateDB();
|
|
|
|
|
|
+ if (enableFlyway) {
|
|
|
|
+ migrateDB();
|
|
|
|
+ }
|
|
|
|
+ if (enableResetConfig) {
|
|
|
|
+ cleanRemoteConfig(Config.getCenterConnectionStr(), "classpath:sql/systemset/*");
|
|
|
|
+ cleanRemoteConfig(Config.getSecurityConnectionStr(), "classpath:sql/uniauth/*");
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
// 日志配置初始化
|
|
// 日志配置初始化
|
|
Config.targets.addAll(DataBase.query(Config.getCenterConnectionStr(), "select * from systeminfo"));
|
|
Config.targets.addAll(DataBase.query(Config.getCenterConnectionStr(), "select * from systeminfo"));
|
|
@@ -61,10 +73,9 @@ public class SystemInit {
|
|
ControlService.startServiceByContainerCode();
|
|
ControlService.startServiceByContainerCode();
|
|
// 日志任务
|
|
// 日志任务
|
|
ScheduleUtil.startService(LoggerService::sendMessage, 100);
|
|
ScheduleUtil.startService(LoggerService::sendMessage, 100);
|
|
-// LoggerService.logSystemError(LocalDateTime.now(), "", "");
|
|
|
|
- LoggerService.log(LoggerService.LogType.SYSTEM, new HashMap<>() {{
|
|
|
|
- put("occurrencetime", LocalDateTime.now());
|
|
|
|
- }});
|
|
|
|
|
|
+ HashMap<String, Object> occurrencetime = new HashMap<>();
|
|
|
|
+ occurrencetime.put("occurrencetime", LocalDateTime.now());
|
|
|
|
+ LoggerService.log(LoggerService.LogType.SYSTEM, occurrencetime);
|
|
}
|
|
}
|
|
|
|
|
|
private void initializeSystemEnvironment() throws Exception {
|
|
private void initializeSystemEnvironment() throws Exception {
|
|
@@ -89,8 +100,6 @@ public class SystemInit {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
readConfigFile();
|
|
readConfigFile();
|
|
-// cleanRemoteConfig(Config.getCenterConnectionStr(),"classpath:sql/systemset/*");
|
|
|
|
-// cleanRemoteConfig(Config.getSecurityConnectionStr(),"classpath:sql/uniauth/*");
|
|
|
|
ControlService.startServiceByContainerCode();
|
|
ControlService.startServiceByContainerCode();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -115,7 +124,7 @@ public class SystemInit {
|
|
/**
|
|
/**
|
|
* 清理远程数据配置
|
|
* 清理远程数据配置
|
|
*/
|
|
*/
|
|
- private void cleanRemoteConfig(String connection,String path) throws Exception {
|
|
|
|
|
|
+ private void cleanRemoteConfig(String connection, String path) throws Exception {
|
|
|
|
|
|
|
|
|
|
Resource[] resources = resourcePatternResolver.getResources(path);
|
|
Resource[] resources = resourcePatternResolver.getResources(path);
|
|
@@ -132,7 +141,7 @@ public class SystemInit {
|
|
}
|
|
}
|
|
for (String sql : stringBuilder.toString().split(";")) {
|
|
for (String sql : stringBuilder.toString().split(";")) {
|
|
if (!sql.trim().isEmpty()) {
|
|
if (!sql.trim().isEmpty()) {
|
|
- if(Config.isDebug()) {
|
|
|
|
|
|
+ if (Config.isDebug()) {
|
|
System.out.printf("执行语句:%s%n", sql);
|
|
System.out.printf("执行语句:%s%n", sql);
|
|
}
|
|
}
|
|
DataBase.update(connection, sql);
|
|
DataBase.update(connection, sql);
|