reghao 5 سال پیش
والد
کامیت
46abb40c49

+ 13 - 18
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/FileController.java

@@ -1,10 +1,9 @@
 package cn.reghao.autodop.dmaster.app.controller;
 
+import cn.reghao.autodop.dmaster.common.config.SysConfig;
 import cn.reghao.autodop.dmaster.utils.SpringBootUtil;
 import cn.reghao.autodop.common.result.WebResult;
 import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.*;
@@ -12,6 +11,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.*;
+import java.net.URLEncoder;
 
 /**
  * @author reghao
@@ -20,20 +20,13 @@ import java.io.*;
 @Slf4j
 @Api(tags = "文件上传/下载接口")
 @RestController
-@RequestMapping("/api/app")
+@RequestMapping("/api/file")
 public class FileController {
-    @GetMapping("/test")
-    public String test() {
-        return WebResult.success("test api");
-    }
-
     @ApiOperation(value = "下载文件")
-    @ApiImplicitParams(
-            @ApiImplicitParam(name="oss_path", value="OSS 中的路径", paramType="query", dataType = "String")
-    )
-    @GetMapping("/file/dl/{filename}")
-    public String download(@PathVariable("filename") String filename, HttpServletResponse response) throws IOException {
-        /*String filepath = SysConfig.packDir + "/" + filename;
+    @GetMapping("/dl/{filename}")
+    public String download(@PathVariable("filename") String filename, HttpServletResponse response)
+            throws IOException {
+        String filepath = SysConfig.packDir + "/" + filename;
         File file = new File(filepath);
         if (file.exists()) {
             response.setHeader("content-type", "application/octet-stream");
@@ -49,14 +42,16 @@ public class FileController {
             while (i != -1) {
                 os.write(buffer, 0, i);
                 i = bis.read(buffer);
-            }*/
-
+            }
             return WebResult.success("文件已下载");
+        }
+
+        return WebResult.success("文件不存在");
     }
 
     @ApiOperation(value = "上传文件")
-    @PostMapping("/file/upload")
-    public String ossUpload(@RequestParam("file") MultipartFile file) {
+    @PostMapping("/upload")
+    public String upload(@RequestParam("file") MultipartFile file) {
         String filename = file.getOriginalFilename();
         String filePath = SpringBootUtil.saveFile(file, "/tmp");
         return WebResult.success(filePath);

+ 34 - 4
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/crud/BuildConfigCrudController.java

@@ -1,6 +1,8 @@
 package cn.reghao.autodop.dmaster.app.controller.crud;
 
 import cn.reghao.autodop.common.result.WebResult;
+import cn.reghao.autodop.dmaster.app.entity.BuildDir;
+import cn.reghao.autodop.dmaster.app.service.crud.build.BuildDirCrudService;
 import cn.reghao.autodop.dmaster.common.db.PageList;
 import cn.reghao.autodop.common.utils.serializer.JsonConverter;
 import cn.reghao.autodop.dmaster.app.entity.config.build.tools.CompilerConfig;
@@ -24,18 +26,49 @@ import org.springframework.web.bind.annotation.*;
 @RestController
 @RequestMapping("/api/config/build")
 public class BuildConfigCrudController {
+    private BuildDirCrudService buildDirCrudService;
     private RepoConfigCrudService repoConfigCrudService;
     private CompilerConfigCrudService compilerConfigCrudService;
     private PackerConfigCrudService packerConfigCrudService;
 
-    public BuildConfigCrudController(RepoConfigCrudService repoConfigCrudService,
+    public BuildConfigCrudController(BuildDirCrudService buildDirCrudService,
+                                     RepoConfigCrudService repoConfigCrudService,
                                      CompilerConfigCrudService compilerConfigCrudService,
                                      PackerConfigCrudService packerConfigCrudService) {
+        this.buildDirCrudService = buildDirCrudService;
         this.repoConfigCrudService = repoConfigCrudService;
         this.compilerConfigCrudService = compilerConfigCrudService;
         this.packerConfigCrudService = packerConfigCrudService;
     }
 
+    /* 构建目录配置 */
+    @ApiOperation(value = "添加本地目录配置")
+    @PostMapping(value = "/dir", consumes = "application/json")
+    public ResponseEntity<String> addLocalDir(@RequestBody String json) throws Exception {
+        return ResponseEntity.ok().body(WebResult.success("系统已自动创建..."));
+    }
+
+    @ApiOperation(value = "分页获取本地目录配置")
+    @GetMapping("/dir")
+    public ResponseEntity<String> getLocalDirByPage(@RequestParam("page") int page, @RequestParam("size") int size) {
+        PageList<BuildDir> pageList = buildDirCrudService.getByPage(page, size);
+        return ResponseEntity.ok().body(WebResult.success(pageList));
+    }
+
+    @ApiOperation(value = "修改本地目录配置")
+    @PutMapping("/dir")
+    public ResponseEntity<String> modifyLocalDir(@RequestBody String json) throws Exception {
+        BuildDir buildDir = (BuildDir) JsonConverter.jsonToObject(json, BuildDir.class);
+        buildDirCrudService.addOrUpdate(buildDir);
+        return ResponseEntity.ok().body(WebResult.success("ok"));
+    }
+
+    @ApiOperation(value = "删除本地目录配置")
+    @DeleteMapping("/dir/{uniqueKey}")
+    public ResponseEntity<String> deleteLocalDir(@PathVariable("uniqueKey") String uniqueKey) throws Exception {
+        return ResponseEntity.ok().body(WebResult.success("不允许删除..."));
+    }
+
     /* 仓库配置 */
     @ApiOperation(value = "添加仓库配置")
     @PostMapping(value = "/repo", consumes = "application/json")
@@ -128,7 +161,4 @@ public class BuildConfigCrudController {
         packerConfigCrudService.delete(uniqueKey);
         return ResponseEntity.ok().body(WebResult.success("ok"));
     }
-
-    /* 构建目录配置 */
-
 }

+ 1 - 33
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/crud/GlobalCrudController.java

@@ -3,9 +3,7 @@ package cn.reghao.autodop.dmaster.app.controller.crud;
 import cn.reghao.autodop.common.result.WebResult;
 import cn.reghao.autodop.dmaster.common.db.PageList;
 import cn.reghao.autodop.common.utils.serializer.JsonConverter;
-import cn.reghao.autodop.dmaster.app.entity.BuildDir;
 import cn.reghao.autodop.dmaster.app.entity.config.NotifierConfig;
-import cn.reghao.autodop.dmaster.app.service.crud.build.BuildDirCrudService;
 import cn.reghao.autodop.dmaster.app.service.crud.global.NotifierCrudService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -22,11 +20,9 @@ import org.springframework.web.bind.annotation.*;
 @RestController
 @RequestMapping("/api/config/global")
 public class GlobalCrudController {
-    private BuildDirCrudService buildDirCrudService;
     private NotifierCrudService notifierCrudService;
 
-    public GlobalCrudController(BuildDirCrudService buildDirCrudService, NotifierCrudService notifierCrudService) {
-        this.buildDirCrudService = buildDirCrudService;
+    public GlobalCrudController(NotifierCrudService notifierCrudService) {
         this.notifierCrudService = notifierCrudService;
     }
 
@@ -60,32 +56,4 @@ public class GlobalCrudController {
         notifierCrudService.delete(uniqueKey);
         return ResponseEntity.ok().body(WebResult.success("ok"));
     }
-    
-    /* 本地目录配置 */
-    @ApiOperation(value = "添加本地目录配置")
-    @PostMapping(value = "/localdir", consumes = "application/json")
-    public ResponseEntity<String> addLocalDir(@RequestBody String json) throws Exception {
-        return ResponseEntity.ok().body(WebResult.success("系统已自动创建..."));
-    }
-
-    @ApiOperation(value = "分页获取本地目录配置")
-    @GetMapping("/localdir")
-    public ResponseEntity<String> getLocalDirByPage(@RequestParam("page") int page, @RequestParam("size") int size) {
-        PageList<BuildDir> pageList = buildDirCrudService.getByPage(page, size);
-        return ResponseEntity.ok().body(WebResult.success(pageList));
-    }
-
-    @ApiOperation(value = "修改本地目录配置")
-    @PutMapping("/localdir")
-    public ResponseEntity<String> modifyLocalDir(@RequestBody String json) throws Exception {
-        BuildDir buildDir = (BuildDir) JsonConverter.jsonToObject(json, BuildDir.class);
-        buildDirCrudService.addOrUpdate(buildDir);
-        return ResponseEntity.ok().body(WebResult.success("ok"));
-    }
-
-    @ApiOperation(value = "删除本地目录配置")
-    @DeleteMapping("/localdir/{uniqueKey}")
-    public ResponseEntity<String> deleteLocalDir(@PathVariable("uniqueKey") String uniqueKey) throws Exception {
-        return ResponseEntity.ok().body(WebResult.success("不允许删除..."));
-    }
 }

+ 3 - 3
scripts/build_and_deploy.sh

@@ -9,14 +9,14 @@ set -e
 #sh deploy.sh autodop-dmaster 192.168.0.211 azy &
 
 # 构建
-sh build.sh test dagent
+#sh build.sh test dagent
 
 ##############################################################
 # 测试环境
 ##############################################################
-#sh deploy.sh autodop-dagent 192.168.0.171 azy &
+sh deploy.sh autodop-dagent 192.168.0.171 azy &
 sh deploy.sh autodop-dagent 192.168.0.172 azy &
-#sh deploy.sh autodop-dagent 192.168.0.173 azy &
+sh deploy.sh autodop-dagent 192.168.0.173 azy &
 sh deploy.sh autodop-dagent 192.168.0.174 azy &