Эх сурвалжийг харах

修改默认配置,及允许指定用默认配置修改数据配置

suntg 7 жил өмнө
parent
commit
cb4d905ba6

+ 13 - 0
src/main/java/com/uas/erp/schedular/init/DefaultInitializer.java

@@ -22,6 +22,8 @@ public class DefaultInitializer implements CommandLineRunner {
 
     @Override
     public void run(String... strings) throws Exception {
+        // 用默认数据重置数据库配置
+        String[] resetDefaultKeys = {"api.b2b.url", "api.publicinquiry.url", "api.publicproduct.url"};
         // 默认数据
         String settingsStr = StringUtil.copyResource("init/setting.json");
         if (!StringUtils.isEmpty(settingsStr)) {
@@ -30,7 +32,18 @@ public class DefaultInitializer implements CommandLineRunner {
                 Setting oldOne = settingService.findOne(setting.getKey());
                 if (null == oldOne) {
                     settingService.save(setting);
+                } else {
+                    if (resetDefaultKeys.length > 0) {
+                        for (String key : resetDefaultKeys) {
+                            // 需要用默认配置重置数据库配置,修改数据库配置内容
+                            if (key.equals(setting.getKey())) {
+                                oldOne.setKey(setting.getKey());
+                                settingService.save(oldOne);
+                            }
+                        }
+                    }
                 }
+
                 // 不修改已设置项
             }
         }

+ 2 - 2
src/main/resources/init/setting.json

@@ -45,7 +45,7 @@
 },{
   "key": "api.publicinquiry.url",
   "description": "公共询价正式地址",
-  "value": "https://api-inquiry.usoftchina.com/"
+  "value": "http://api-inquiry.usoftchina.com/"
 },{
   "key": "api.publicproduct.test.url",
   "description": "公共物料测试地址",
@@ -53,5 +53,5 @@
 },{
   "key": "api.publicproduct.url",
   "description": "公共物料正式地址",
-  "value": "https://api-product.usoftchina.com/"
+  "value": "http://api-product.usoftchina.com/"
 }]