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 b2351b1111..1938aa170c 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 @@ -300,4 +300,12 @@ public class ApiTestCaseController { StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "id desc"); return PageUtils.setPageInfo(page, apiTestCaseService.getReference(request)); } + + @GetMapping("/api-change/clear/{id}") + @Operation(summary = "清除接口参数变更标识") + @RequiresPermissions(logical = Logical.OR, value = {PermissionConstants.PROJECT_API_DEFINITION_CASE_ADD, PermissionConstants.PROJECT_API_DEFINITION_CASE_UPDATE}) + @CheckOwner(resourceId = "#id", resourceType = "api_test_case") + public void clearApiChange(@PathVariable String id) { + apiTestCaseService.clearApiChange(id); + } } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseService.java index 67e3e7a45b..c0fb63d822 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseService.java @@ -944,4 +944,11 @@ public class ApiTestCaseService extends MoveNodeService { } } + public void clearApiChange(String id) { + checkResourceExist(id); + ApiTestCase apiTestCase = new ApiTestCase(); + apiTestCase.setId(id); + apiTestCase.setApiChange(false); + apiTestCaseMapper.updateByPrimaryKeySelective(apiTestCase); + } } diff --git a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiTestCaseControllerTests.java b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiTestCaseControllerTests.java index ec4c2c9a2a..9d513e370f 100644 --- a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiTestCaseControllerTests.java +++ b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiTestCaseControllerTests.java @@ -113,6 +113,7 @@ public class ApiTestCaseControllerTests extends BaseTest { private static final String RUN_GET = "run/{0}"; private static final String RUN_POST = "run"; private static final String BATCH_RUN = "batch/run"; + private static final String API_CHANGE_CLEAR = "api-change/clear/{id}"; private static final ResultMatcher ERROR_REQUEST_MATCHER = status().is5xxServerError(); private static ApiTestCase apiTestCase; @@ -432,6 +433,21 @@ public class ApiTestCaseControllerTests extends BaseTest { Assertions.assertEquals(apiTestCaseMapper.selectByPrimaryKey(apiTestCase.getId()).getApiChange(), true); } + @Test + @Order(3) + public void clearApiChange() throws Exception { + ApiTestCase updateCase = new ApiTestCase(); + updateCase.setApiChange(true); + updateCase.setId(apiTestCase.getId()); + apiTestCaseMapper.updateByPrimaryKeySelective(updateCase); + this.requestGetWithOk(API_CHANGE_CLEAR, apiTestCase.getId()); + Assertions.assertFalse(apiTestCaseMapper.selectByPrimaryKey(apiTestCase.getId()).getApiChange()); + + // @@校验权限 + requestGetPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_CASE_ADD, API_CHANGE_CLEAR, apiTestCase.getId()); + requestGetPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_CASE_UPDATE, API_CHANGE_CLEAR, apiTestCase.getId()); + } + /** * 测试关联的文件更新 *