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 afd5c407e0..fed3aa2ee6 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 @@ -319,11 +319,11 @@ public class ApiTestCaseController { } @GetMapping("/api-change/ignore/{id}") - @Operation(summary = "清除接口参数变更标识") + @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 ignoreApiChange(@PathVariable String id) { - apiTestCaseService.ignoreApiChange(id); + public void ignoreApiChange(@PathVariable String id, @RequestParam(name = "ignore") boolean ignore) { + apiTestCaseService.ignoreApiChange(id, ignore); } @GetMapping("/api/compare/{id}") 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 64e109abca..d5ea223a78 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 @@ -101,6 +101,9 @@ public class ApiTestCaseDTO { @Schema(description = "与接口定义不一致") private Boolean inconsistentWithApi; + @Schema(description = "忽略接口与用例参数不一致") + private Boolean ignoreApiDiff; + @Schema(description = "忽略接口定义参数变更") private Boolean ignoreApiChange; } 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 7bc214995b..e62b4f5d4c 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 @@ -980,13 +980,17 @@ public class ApiTestCaseService extends MoveNodeService { return ApiDataUtils.parseObject(new String(apiTestCaseBlob.getRequest()), AbstractMsTestElement.class); } - public void ignoreApiChange(String id) { + public void ignoreApiChange(String id, boolean ignore) { checkResourceExist(id); ApiTestCase apiTestCase = new ApiTestCase(); apiTestCase.setId(id); - apiTestCase.setApiChange(false); - apiTestCase.setIgnoreApiDiff(true); - apiTestCase.setIgnoreApiChange(true); + if (ignore) { + apiTestCase.setApiChange(false); + apiTestCase.setIgnoreApiDiff(true); + apiTestCase.setIgnoreApiChange(true); + } else { + apiTestCase.setIgnoreApiChange(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 e1b7b9864f..58221e234f 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 @@ -111,7 +111,7 @@ public class ApiTestCaseControllerTests extends BaseTest { 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/{0}"; - private static final String API_CHANGE_IGNORE = "api-change/ignore/{0}"; + private static final String API_CHANGE_IGNORE = "api-change/ignore/{0}?ignore={1}"; private static final String API_CHANGE_SYNC = "batch/api-change/sync"; private static final String API_COMPARE = "api/compare/{0}"; @@ -478,14 +478,18 @@ public class ApiTestCaseControllerTests extends BaseTest { updateCase.setApiChange(true); updateCase.setId(apiTestCase.getId()); apiTestCaseMapper.updateByPrimaryKeySelective(updateCase); - this.requestGetWithOk(API_CHANGE_IGNORE, apiTestCase.getId()); + this.requestGetWithOk(API_CHANGE_IGNORE, apiTestCase.getId(), true); Assertions.assertFalse(apiTestCaseMapper.selectByPrimaryKey(apiTestCase.getId()).getApiChange()); Assertions.assertTrue(apiTestCaseMapper.selectByPrimaryKey(apiTestCase.getId()).getIgnoreApiDiff()); Assertions.assertTrue(apiTestCaseMapper.selectByPrimaryKey(apiTestCase.getId()).getIgnoreApiChange()); + this.requestGetWithOk(API_CHANGE_IGNORE, apiTestCase.getId(), false); + Assertions.assertFalse(apiTestCaseMapper.selectByPrimaryKey(apiTestCase.getId()).getApiChange()); + Assertions.assertTrue(apiTestCaseMapper.selectByPrimaryKey(apiTestCase.getId()).getIgnoreApiDiff()); + Assertions.assertFalse(apiTestCaseMapper.selectByPrimaryKey(apiTestCase.getId()).getIgnoreApiChange()); // @@校验权限 - requestGetPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_CASE_ADD, API_CHANGE_IGNORE, apiTestCase.getId()); - requestGetPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_CASE_UPDATE, API_CHANGE_IGNORE, apiTestCase.getId()); + requestGetPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_CASE_ADD, API_CHANGE_IGNORE, apiTestCase.getId(), true); + requestGetPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_CASE_UPDATE, API_CHANGE_IGNORE, apiTestCase.getId(), false); } @Test