|
|
@ -3,11 +3,18 @@ package com.inscloudtech.functional.controller; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Arrays; |
|
|
|
|
|
|
|
import com.inscloudtech.common.config.ProjectConfig; |
|
|
|
import com.inscloudtech.common.utils.StringUtils; |
|
|
|
import com.inscloudtech.common.utils.file.FileUtils; |
|
|
|
import com.inscloudtech.functional.domain.FuncCarApi; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import javax.validation.constraints.*; |
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.http.MediaType; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
import com.inscloudtech.common.annotation.RepeatSubmit; |
|
|
@ -36,8 +43,10 @@ public class FuncCarApiController extends BaseController { |
|
|
|
|
|
|
|
private final IFuncCarApiService iFuncCarApiService; |
|
|
|
|
|
|
|
private final ProjectConfig projectConfig; |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询兼容可靠性测试系统-API接口兼容性测试工具列表 |
|
|
|
* 查询API接口在不同操作系统、不同浏览器、不同设备以及不同网络环境下的兼容性测试结果列表 |
|
|
|
*/ |
|
|
|
@SaCheckPermission("functional:CarApi:list") |
|
|
|
@GetMapping("/list") |
|
|
@ -45,31 +54,9 @@ public class FuncCarApiController extends BaseController { |
|
|
|
return iFuncCarApiService.queryPageList(bo, pageQuery); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 导出兼容可靠性测试系统-API接口兼容性测试工具列表 |
|
|
|
*/ |
|
|
|
@SaCheckPermission("functional:CarApi:export") |
|
|
|
@Log(title = "兼容可靠性测试系统-API接口兼容性测试工具", businessType = BusinessType.EXPORT) |
|
|
|
@PostMapping("/export") |
|
|
|
public void export(FuncCarApi bo, HttpServletResponse response) { |
|
|
|
List<FuncCarApiVo> list = iFuncCarApiService.queryList(bo); |
|
|
|
ExcelUtil.exportExcel(list, "兼容可靠性测试系统-API接口兼容性测试工具", FuncCarApiVo.class, response); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取兼容可靠性测试系统-API接口兼容性测试工具详细信息 |
|
|
|
* |
|
|
|
* @param operId 主键 |
|
|
|
*/ |
|
|
|
@SaCheckPermission("functional:CarApi:query") |
|
|
|
@GetMapping("/{operId}") |
|
|
|
public R<FuncCarApiVo> getInfo(@NotNull(message = "主键不能为空") |
|
|
|
@PathVariable Long operId) { |
|
|
|
return R.ok(iFuncCarApiService.queryById(operId)); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 兼容可靠性测试系统-API接口兼容性测试工具 |
|
|
|
* 测试API接口在不同操作系统、不同浏览器、不同设备以及不同网络环境下的兼容性 |
|
|
|
*/ |
|
|
|
@SaCheckPermission("functional:CarApi:add") |
|
|
|
@Log(title = "兼容可靠性测试系统-API接口兼容性测试工具", businessType = BusinessType.INSERT) |
|
|
@ -80,26 +67,63 @@ public class FuncCarApiController extends BaseController { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 修改兼容可靠性测试系统-API接口兼容性测试工具 |
|
|
|
* 模拟高并发、高负载情况下的API接口性能和稳定性测试工具下载 |
|
|
|
*/ |
|
|
|
@SaCheckPermission("functional:CarApi:edit") |
|
|
|
@Log(title = "兼容可靠性测试系统-API接口兼容性测试工具", businessType = BusinessType.UPDATE) |
|
|
|
@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(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 检查API接口参数的正确性、完整性和有效性 |
|
|
|
*/ |
|
|
|
@SaCheckPermission("functional:CarApi:add") |
|
|
|
@Log(title = "兼容可靠性测试系统-API接口兼容性测试工具", businessType = BusinessType.INSERT) |
|
|
|
@RepeatSubmit() |
|
|
|
@PutMapping() |
|
|
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody FuncCarApi bo) { |
|
|
|
return toAjax(iFuncCarApiService.updateByBo(bo)); |
|
|
|
@PostMapping("/checkApi") |
|
|
|
public R checkApi(@Validated(AddGroup.class) @RequestBody FuncCarApi bo) { |
|
|
|
return R.ok(iFuncCarApiService.checkApi(bo)); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 删除兼容可靠性测试系统-API接口兼容性测试工具 |
|
|
|
* |
|
|
|
* @param operIds 主键串 |
|
|
|
* API接口协议(如REST、SOAP、XML-RPC等),测试工具可提供对应的协议测试工具, |
|
|
|
*/ |
|
|
|
@SaCheckPermission("functional:CarApi:remove") |
|
|
|
@Log(title = "兼容可靠性测试系统-API接口兼容性测试工具", businessType = BusinessType.DELETE) |
|
|
|
@DeleteMapping("/{operIds}") |
|
|
|
public R<Void> remove(@NotEmpty(message = "主键不能为空") |
|
|
|
@PathVariable Long[] operIds) { |
|
|
|
return toAjax(iFuncCarApiService.deleteWithValidByIds(Arrays.asList(operIds), true)); |
|
|
|
@GetMapping("/protocolToolDownload") |
|
|
|
public void protocolToolDownload(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(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |