|
|
@ -1,7 +1,6 @@ |
|
|
|
package com.inscloudtech.functional.controller; |
|
|
|
|
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission; |
|
|
|
import com.inscloudtech.common.annotation.Log; |
|
|
|
import com.inscloudtech.common.annotation.RepeatSubmit; |
|
|
|
import com.inscloudtech.common.config.ProjectConfig; |
|
|
|
import com.inscloudtech.common.core.controller.BaseController; |
|
|
@ -9,7 +8,6 @@ import com.inscloudtech.common.core.domain.PageQuery; |
|
|
|
import com.inscloudtech.common.core.domain.R; |
|
|
|
import com.inscloudtech.common.core.page.TableDataInfo; |
|
|
|
import com.inscloudtech.common.core.validate.AddGroup; |
|
|
|
import com.inscloudtech.common.enums.BusinessType; |
|
|
|
import com.inscloudtech.common.utils.StringUtils; |
|
|
|
import com.inscloudtech.common.utils.file.FileUtils; |
|
|
|
import com.inscloudtech.functional.domain.FuncCarApi; |
|
|
@ -39,6 +37,8 @@ public class FuncCarApiController extends BaseController { |
|
|
|
|
|
|
|
private final ProjectConfig projectConfig; |
|
|
|
|
|
|
|
private final static String JMETER_FILE_NAME = "apache-jmeter.zip"; |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询API接口在不同操作系统、不同浏览器、不同设备以及不同网络环境下的兼容性测试结果列表 |
|
|
|
*/ |
|
|
@ -64,23 +64,7 @@ public class FuncCarApiController extends BaseController { |
|
|
|
*/ |
|
|
|
@GetMapping("/jmDownload") |
|
|
|
public void jmDownload(HttpServletResponse response, HttpServletRequest request) { |
|
|
|
String fileName = "apache-jmeter-5.6.3.zip"; |
|
|
|
try { |
|
|
|
if (!FileUtils.checkAllowDownload(fileName)) { |
|
|
|
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName)); |
|
|
|
} |
|
|
|
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1); |
|
|
|
String filePath = projectConfig.getDownloadPath() + fileName; |
|
|
|
|
|
|
|
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); |
|
|
|
FileUtils.setAttachmentResponseHeader(response, realFileName); |
|
|
|
FileUtils.writeBytes(filePath, response.getOutputStream()); |
|
|
|
// if (delete) { |
|
|
|
// FileUtils.deleteFile(filePath); |
|
|
|
// } |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
doDownLoad(JMETER_FILE_NAME,response); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -98,13 +82,16 @@ public class FuncCarApiController extends BaseController { |
|
|
|
*/ |
|
|
|
@GetMapping("/protocolToolDownload") |
|
|
|
public void protocolToolDownload(HttpServletResponse response, HttpServletRequest request) { |
|
|
|
String fileName = "apache-jmeter-5.6.3.zip"; |
|
|
|
doDownLoad(JMETER_FILE_NAME,response); |
|
|
|
} |
|
|
|
|
|
|
|
void doDownLoad(String filename,HttpServletResponse response){ |
|
|
|
try { |
|
|
|
if (!FileUtils.checkAllowDownload(fileName)) { |
|
|
|
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName)); |
|
|
|
if (!FileUtils.checkAllowDownload(filename)) { |
|
|
|
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", filename)); |
|
|
|
} |
|
|
|
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1); |
|
|
|
String filePath = projectConfig.getDownloadPath() + fileName; |
|
|
|
String realFileName = System.currentTimeMillis() + filename.substring(filename.indexOf("_") + 1); |
|
|
|
String filePath = projectConfig.getDownloadPath() + filename; |
|
|
|
|
|
|
|
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); |
|
|
|
FileUtils.setAttachmentResponseHeader(response, realFileName); |
|
|
|