matianxiang 1 mês atrás
pai
commit
9691bac492

+ 5 - 10
eitc-admin/src/main/java/com/eitc/web/controller/common/DownloadController.java

@@ -5,14 +5,11 @@ import com.eitc.common.constant.Constants;
5 5
 import com.eitc.common.core.controller.BaseController;
6 6
 import com.eitc.common.utils.StringUtils;
7 7
 import com.eitc.common.utils.file.FileUtils;
8
-import org.slf4j.Logger;
9
-import org.slf4j.LoggerFactory;
10 8
 import org.springframework.http.MediaType;
11 9
 import org.springframework.web.bind.annotation.GetMapping;
12 10
 import org.springframework.web.bind.annotation.RequestMapping;
13 11
 import org.springframework.web.bind.annotation.RestController;
14 12
 
15
-import javax.servlet.http.HttpServletRequest;
16 13
 import javax.servlet.http.HttpServletResponse;
17 14
 
18 15
 
@@ -29,24 +26,24 @@ public class DownloadController extends BaseController {
29 26
      * 硬件app
30 27
      */
31 28
     @GetMapping("/hardware")
32
-    public void hardware(HttpServletRequest request, HttpServletResponse response) throws Exception {
29
+    public void hardware(HttpServletResponse response) throws Exception {
33 30
         String resource = "/profile/app/huishitong.apk";
34
-        resourceDownload(resource, response);
31
+        resourceDownload("慧视通APP.apk", resource, response);
35 32
     }
36 33
 
37 34
     @GetMapping("/hospital")
38 35
     public void hospital(HttpServletResponse response) throws Exception {
39 36
         String resource = "/profile/app/kouqiangyiyuan_1.0.0_1_240830_release.apk";
40
-        resourceDownload(resource, response);
37
+        resourceDownload("口腔医院.apk", resource, response);
41 38
     }
42 39
 
43 40
     @GetMapping("/document")
44 41
     public void document(HttpServletResponse response) throws Exception {
45 42
         String resource = "/profile/app/document.pdf";
46
-        resourceDownload(resource, response);
43
+        resourceDownload("慧视通APP操作乎册.pdf", resource, response);
47 44
     }
48 45
 
49
-    public void resourceDownload(String resource, HttpServletResponse response) throws Exception {
46
+    public void resourceDownload(String downloadName, String resource, HttpServletResponse response) throws Exception {
50 47
         // 禁止目录上跳级别
51 48
         if (StringUtils.contains(resource, "..")) {
52 49
             throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource));
@@ -55,8 +52,6 @@ public class DownloadController extends BaseController {
55 52
         String localPath = EitcConfig.getProfile();
56 53
         // 数据库资源地址
57 54
         String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX);
58
-        // 下载名称
59
-        String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
60 55
         response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
61 56
         FileUtils.setAttachmentResponseHeader(response, downloadName);
62 57
         FileUtils.writeBytes(downloadPath, response.getOutputStream());