Browse Source

替换测试环境css、index, 区分运行环境处理消息

wuweihao 3 years ago
parent
commit
db86e86d5b

+ 5 - 5
laser/src/main/java/com/fdkankan/indoor/core/controller/TestController.java

@@ -275,9 +275,9 @@ public class TestController {
      *  default/js/index.js   直接替换
      * @return
      */
-//    @ApiOperation(value = "2021-12-23,batch-更新default里的部分文件", notes = "str=0时进行批量修改")
-//    @GetMapping("batch/default")
-//    public Result batchDefault(String str){
-//        return owenService.batchDefault(str);
-//    }
+    @ApiOperation(value = "2021-12-23,batch-更新default里的部分文件", notes = "str=0时进行批量修改")
+    @GetMapping("batch/default")
+    public Result batchDefault(String str){
+        return owenService.batchDefault(str);
+    }
 }

+ 35 - 13
laser/src/main/java/com/fdkankan/indoor/core/service/impl/OwenServiceImpl.java

@@ -278,19 +278,41 @@ public class OwenServiceImpl implements OwenService {
         for (File file : faFiles) {
             String dirPath = file.getAbsolutePath();
             String dirName = file.getName();
-            if (FileUtil.isDirectory(dirPath) && dirName.startsWith("t-")){
-                log.info("场景码目录:{}", dirPath);
-                log.info("目录场景码: {}", dirName);
-
-                // 替换css
-                this.writeFile(baseCssPath, sDir + dirName + "/css/style.css");
-                this.writeFile(baseIndexJsPath, sDir + dirName + "/js/index.js");
-                String sceneCodeIndexHtmlPath = sDir + dirName + "/index.html";
-                String title = getTitleByIndexHtml(sceneCodeIndexHtmlPath);
-                this.writeIndexHtml(baseIndexHtmlPath, sceneCodeIndexHtmlPath, dirName, title);
-                this.copyImg(baseImgPath, sDir + dirName + "/img");
-                i ++;
-                log.info("替换第: {} 个, 场景码: {}", i, dirName);
+
+            if (FileUtil.isDirectory(dirPath) ){
+                boolean flag = false;
+                if ("pro".equals(configConstant.active)){ // 正式场景码
+                    if (dirName.length() == 10){  // 场景码长度为10
+                        String indexHtmlPath = dirPath + "/index.html";
+                        if (FileUtil.isFile(indexHtmlPath)){
+                            flag = true;
+                        }
+                    }
+
+
+                } else { // 测试场景码
+                    if(dirName.startsWith("t-")){
+                        flag = true;
+                    }
+                }
+
+
+                if (flag){
+                    log.info("场景码目录:{}", dirPath);
+                    log.info("目录场景码: {}", dirName);
+
+                    // 替换css
+                    this.writeFile(baseCssPath, sDir + dirName + "/css/style.css");
+                    this.writeFile(baseIndexJsPath, sDir + dirName + "/js/index.js");
+                    String sceneCodeIndexHtmlPath = sDir + dirName + "/index.html";
+                    String title = getTitleByIndexHtml(sceneCodeIndexHtmlPath);
+                    this.writeIndexHtml(baseIndexHtmlPath, sceneCodeIndexHtmlPath, dirName, title);
+                    this.copyImg(baseImgPath, sDir + dirName + "/img");
+                    i ++;
+                    log.info("替换第: {} 个, 场景码: {}", i, dirName);
+                }
+
+
             }
 
             if (!"0".equals(isBatch)){