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