diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/controller/definition/ApiDefinitionModuleController.java b/backend/services/api-test/src/main/java/io/metersphere/api/controller/definition/ApiDefinitionModuleController.java index 65ebf327aa..f45eee10ef 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/controller/definition/ApiDefinitionModuleController.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/controller/definition/ApiDefinitionModuleController.java @@ -30,7 +30,7 @@ public class ApiDefinitionModuleController { @Operation(summary = "接口测试-接口管理-模块-查找模块") @RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ) public List getTree(@RequestBody @Validated ApiModuleRequest request) { - return apiDefinitionModuleService.getTree(request); + return apiDefinitionModuleService.getTree(request, false); } @PostMapping("/add") @@ -66,6 +66,20 @@ public class ApiDefinitionModuleController { @Operation(summary = "接口测试-接口管理-模块-统计模块数量") @RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ) public Map moduleCount(@Validated @RequestBody ApiModuleRequest request) { - return apiDefinitionModuleService.moduleCount(request); + return apiDefinitionModuleService.moduleCount(request, false); + } + + @PostMapping("/trash/count") + @Operation(summary = "接口测试-接口管理-模块-统计回收站模块数量") + @RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ) + public Map moduleCountTrash(@Validated @RequestBody ApiModuleRequest request) { + return apiDefinitionModuleService.moduleCount(request, true); + } + + @PostMapping("/trash/tree") + @Operation(summary = "接口测试-接口管理-模块-查找模块") + @RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ) + public List getTrashTree(@RequestBody @Validated ApiModuleRequest request) { + return apiDefinitionModuleService.getTree(request, true); } } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/controller/definition/ApiTestCaseController.java b/backend/services/api-test/src/main/java/io/metersphere/api/controller/definition/ApiTestCaseController.java index 27a8ea164f..bb3d3b32ca 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/controller/definition/ApiTestCaseController.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/controller/definition/ApiTestCaseController.java @@ -112,7 +112,7 @@ public class ApiTestCaseController { public Pager> page(@Validated @RequestBody ApiTestCasePageRequest request) { Page page = PageHelper.startPage(request.getCurrent(), request.getPageSize(), StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "create_time desc"); - return PageUtils.setPageInfo(page, apiTestCaseService.page(request)); + return PageUtils.setPageInfo(page, apiTestCaseService.page(request, false)); } @PostMapping("/batch/delete") @@ -133,5 +133,13 @@ public class ApiTestCaseController { apiTestCaseService.batchEdit(request, SessionUtils.getUserId()); } + @PostMapping(value = "/trash/page") + @Operation(summary = "接口测试-接口管理-接口用例-回收站-分页查询") + @RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_CASE_READ) + public Pager> pageTrash(@Validated @RequestBody ApiTestCasePageRequest request) { + Page page = PageHelper.startPage(request.getCurrent(), request.getPageSize(), + StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "create_time desc"); + return PageUtils.setPageInfo(page, apiTestCaseService.page(request, true)); + } } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseAddRequest.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseAddRequest.java index 9fb01fbf48..def25f96fe 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseAddRequest.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseAddRequest.java @@ -7,6 +7,7 @@ import lombok.Data; import java.io.Serializable; import java.util.LinkedHashSet; +import java.util.List; @Data public class ApiTestCaseAddRequest implements Serializable { @@ -49,4 +50,8 @@ public class ApiTestCaseAddRequest implements Serializable { @Schema(description = "请求内容") @NotBlank private String request; + + @Schema(description = "接口用例所需的所有文件资源ID") + private List fileIds; + } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseDTO.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseDTO.java index c26db527c0..54db6eae74 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseDTO.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseDTO.java @@ -83,4 +83,7 @@ public class ApiTestCaseDTO { @Schema(description = "请求内容") private AbstractMsTestElement request; + + @Schema(description = "接口用例所关联的文件ID列表,修改时需要作为参数传入") + private List fileIds; } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseUpdateRequest.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseUpdateRequest.java index 8de042a8db..746ed3cb34 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseUpdateRequest.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseUpdateRequest.java @@ -45,4 +45,15 @@ public class ApiTestCaseUpdateRequest implements Serializable { @NotBlank private String request; + @Schema(description = "接口用例所需的所有文件资源ID") + private List fileIds; + + /** + * 新上传的文件ID + * 为了解决文件名称重复的问题,需要把文件和ID一一对应 + * 创建时先按ID创建目录,再把文件放入目录 + */ + @Schema(description = "新上传的文件ID,与上传的文件顺序保持一致") + private List addFileIds; + } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionMapper.xml b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionMapper.xml index 0e53b0b3c9..06e164f6f7 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionMapper.xml +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionMapper.xml @@ -5,7 +5,7 @@ update api_definition - set delete_user = #{userId},delete_time = #{time}, deleted = 1 + set delete_user = #{userId},delete_time = #{time}, deleted = 1 , module_id = 'root' where ref_id in #{v} @@ -39,7 +39,7 @@ api_test_case t1 LEFT JOIN api_report t2 ON t1.last_report_id = t2.id WHERE - t1.project_id = #{projectId} and t1.deleted = 0 + t1.project_id = #{projectId} and t1.deleted = 0 GROUP BY t1.api_definition_id @@ -55,7 +55,7 @@ FROM api_definition WHERE project_id = #{projectId} ORDER BY pos DESC - LIMIT 1; + LIMIT 1;