Selaa lähdekoodia

添加构建包下载接口

reghao 4 vuotta sitten
vanhempi
commit
f3c4d1ae8e

+ 21 - 3
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/BuildDeployController.java

@@ -1,6 +1,8 @@
 package cn.reghao.autodop.dmaster.app.controller;
 
+import cn.reghao.autodop.dmaster.app.model.po.config.build.LocalBuildDir;
 import cn.reghao.autodop.dmaster.app.service.BuildDeployService;
+import cn.reghao.autodop.dmaster.util.UploadDownload;
 import cn.reghao.jdkutil.result.WebBody;
 import cn.reghao.autodop.dmaster.app.service.BuildDeployDispatcher;
 import io.swagger.annotations.Api;
@@ -11,6 +13,12 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+
 /**
  * @author reghao
  * @date 2019-08-30 18:49:15
@@ -20,12 +28,13 @@ import org.springframework.web.bind.annotation.*;
 @RestController
 @RequestMapping("/api/app/bd")
 public class BuildDeployController {
-    private final BuildDeployService buildDeployService;
+    private BuildDeployService buildDeployService;
     private final BuildDeployDispatcher buildDeployDispatcher;
+    private final UploadDownload uploadDownload;
 
-    public BuildDeployController(BuildDeployService buildDeployService, BuildDeployDispatcher buildDeployDispatcher) {
-        this.buildDeployService = buildDeployService;
+    public BuildDeployController(BuildDeployDispatcher buildDeployDispatcher, UploadDownload uploadDownload) {
         this.buildDeployDispatcher = buildDeployDispatcher;
+        this.uploadDownload = uploadDownload;
     }
 
     @ApiOperation(value = "构建部署应用")
@@ -77,4 +86,13 @@ public class BuildDeployController {
         buildDeployDispatcher.clear();
         return WebBody.success();
     }
+
+    @ApiOperation(value = "构建包下载接口")
+    @GetMapping("/dl/{filename}")
+    public void dlPackage(@PathVariable("filename") String filename, HttpServletResponse response) throws IOException {
+        String filePath = LocalBuildDir.packDir + File.separator + filename;
+        FileInputStream fileInputStream = new FileInputStream(filePath);
+        BufferedInputStream bis = new BufferedInputStream(fileInputStream);
+        uploadDownload.download(filename, bis, response);
+    }
 }

+ 1 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/util/buildtool/packer/ZipPack.java

@@ -15,7 +15,7 @@ import java.io.File;
 @Slf4j
 public class ZipPack implements CodePacker {
     private final String targetPath;
-    private String binfilesDirname;
+    private final String binfilesDirname;
 
     public ZipPack(PackerConfig packerConfig) {
         this.targetPath = packerConfig.getType().equals(PackType.zip.getName()) ?

+ 0 - 23
dmaster/src/main/java/cn/reghao/autodop/dmaster/sys/controller/SysController.java

@@ -1,7 +1,5 @@
 package cn.reghao.autodop.dmaster.sys.controller;
 
-import cn.reghao.autodop.dmaster.app.model.po.config.build.LocalBuildDir;
-import cn.reghao.autodop.dmaster.util.UploadDownload;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -9,12 +7,6 @@ import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import javax.servlet.http.HttpServletResponse;
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-
 /**
  * @author reghao
  * @date 2021-09-24 11:19:05
@@ -23,19 +15,4 @@ import java.io.IOException;
 @RestController
 @RequestMapping("/api/sys")
 public class SysController {
-    private final UploadDownload uploadDownload;
-
-    public SysController(UploadDownload uploadDownload) {
-        this.uploadDownload = uploadDownload;
-    }
-
-    @ApiOperation(value = "下载构建的应用")
-    @GetMapping("/package/{filename}")
-    public void downloadPackage(@PathVariable("filename") String filename, HttpServletResponse response)
-            throws IOException {
-        String filePath = LocalBuildDir.packDir + File.separator + filename;
-        FileInputStream fileInputStream = new FileInputStream(filePath);
-        BufferedInputStream bis = new BufferedInputStream(fileInputStream);
-        uploadDownload.download(filename, bis, response);
-    }
 }