|
@@ -1,5 +1,6 @@
|
|
|
package com.qmth.boot.data.upgrade.config;
|
|
|
|
|
|
+import com.qmth.boot.data.upgrade.utils.VersionComparator;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.boot.jdbc.DatabaseDriver;
|
|
|
import org.springframework.core.env.ConfigurableEnvironment;
|
|
@@ -21,6 +22,21 @@ public class DataUpgradeProperties implements DataUpgradeConstants {
|
|
|
*/
|
|
|
private Boolean firstInstall;
|
|
|
|
|
|
+ /**
|
|
|
+ * “应用信息表”不存在时,是否指定基线数据,默认值为false
|
|
|
+ */
|
|
|
+ private Boolean baseline;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 指定基线数据时,基线-应用码
|
|
|
+ */
|
|
|
+ private String baselineAppCode;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 指定基线数据时,基线-应用版本号
|
|
|
+ */
|
|
|
+ private String baselineAppVersion;
|
|
|
+
|
|
|
/**
|
|
|
* DB用户名
|
|
|
*/
|
|
@@ -59,16 +75,31 @@ public class DataUpgradeProperties implements DataUpgradeConstants {
|
|
|
}
|
|
|
|
|
|
this.basePackage = environment.getProperty(BASE_PACKAGE, String.class, "com.qmth");
|
|
|
+
|
|
|
this.firstInstall = environment.getProperty(FIRST_INSTALL, Boolean.class, false);
|
|
|
|
|
|
+ this.baseline = environment.getProperty(BASELINE, Boolean.class, false);
|
|
|
+ this.baselineAppCode = environment.getProperty(BASELINE_APP_CODE, String.class);
|
|
|
+ this.baselineAppVersion = environment.getProperty(BASELINE_APP_VERSION, String.class);
|
|
|
+
|
|
|
+ if (baseline) {
|
|
|
+ if (StringUtils.isBlank(baselineAppCode)) {
|
|
|
+ throw new RuntimeException(BASELINE_APP_CODE + " 配置值不能为空!");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!VersionComparator.isValidVersion(baselineAppVersion)) {
|
|
|
+ throw new RuntimeException(BASELINE_APP_VERSION + "=" + baselineAppVersion + " 配置格式不正确!要求格式如:数字.数字.数字");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
this.appCode = environment.getProperty(APP_CODE, String.class);
|
|
|
if (StringUtils.isBlank(appCode)) {
|
|
|
throw new RuntimeException(APP_CODE + " 配置值不能为空!");
|
|
|
}
|
|
|
|
|
|
this.appVersion = environment.getProperty(APP_VERSION, String.class);
|
|
|
- if (StringUtils.isBlank(appVersion)) {
|
|
|
- throw new RuntimeException(APP_VERSION + " 配置值不能为空!");
|
|
|
+ if (!VersionComparator.isValidVersion(appVersion)) {
|
|
|
+ throw new RuntimeException(APP_VERSION + "=" + appVersion + " 配置格式不正确!要求格式如:数字.数字.数字");
|
|
|
}
|
|
|
|
|
|
this.dbUsername = environment.getProperty(DB_USERNAME, String.class);
|
|
@@ -117,6 +148,18 @@ public class DataUpgradeProperties implements DataUpgradeConstants {
|
|
|
return firstInstall;
|
|
|
}
|
|
|
|
|
|
+ public Boolean getBaseline() {
|
|
|
+ return baseline;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getBaselineAppCode() {
|
|
|
+ return baselineAppCode;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getBaselineAppVersion() {
|
|
|
+ return baselineAppVersion;
|
|
|
+ }
|
|
|
+
|
|
|
public String getDbUsername() {
|
|
|
return dbUsername;
|
|
|
}
|