diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java b/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java index a4dd7b2462..c5daa21cde 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java @@ -389,4 +389,9 @@ public class ApiDefinitionController { apiDefinitionService.deleteApiDefinitionByVersion(refId, version); } + @GetMapping("/be/cited/scenario/{definitionId}") + public Integer getCitedScenarioCount(@PathVariable String definitionId) { + return apiDefinitionService.getCitedScenarioCount(definitionId); + } + } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java index 1c0ba55eff..924d13fbf9 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -170,9 +170,12 @@ public class ApiDefinitionService { private ApiAutomationService apiAutomationService; @Resource private FileAssociationService fileAssociationService; + @Resource + private ApiScenarioReferenceIdMapper apiScenarioReferenceIdMapper; private final ThreadLocal currentApiOrder = new ThreadLocal<>(); private final ThreadLocal currentApiCaseOrder = new ThreadLocal<>(); + private static final String COPY = "Copy"; public List list(ApiDefinitionRequest request) { request = this.initRequest(request, true, true); @@ -860,7 +863,7 @@ public class ApiDefinitionService { saveFollows(test.getId(), request.getFollows()); } // 存储附件关系 - fileAssociationService.saveApi(test.getId(), request.getRequest(),FileAssociationType.API.name()); + fileAssociationService.saveApi(test.getId(), request.getRequest(), FileAssociationType.API.name()); return getById(test.getId()); } @@ -938,7 +941,7 @@ public class ApiDefinitionService { for (int i = 0; i < caseList.size(); i++) { ApiTestCaseWithBLOBs apiTestCaseWithBLOBs = caseList.get(i); apiTestCaseWithBLOBs.setApiDefinitionId(apiDefinition.getId()); - if (apiDefinition.getToBeUpdated() && StringUtils.equalsIgnoreCase(apiTestCaseWithBLOBs.getVersionId(), "old_case")) { + if (apiDefinition.getToBeUpdated() != null && apiDefinition.getToBeUpdated() && StringUtils.equalsIgnoreCase(apiTestCaseWithBLOBs.getVersionId(), "old_case")) { apiTestCaseWithBLOBs.setToBeUpdated(true); } else { apiTestCaseWithBLOBs.setToBeUpdated(false); @@ -2695,4 +2698,11 @@ public class ApiDefinitionService { extApiDefinitionMapper.updateNoModuleApiToDefaultModule(projectId, protocol, status, versionId, id); } } + + public Integer getCitedScenarioCount(String testId) { + ApiScenarioReferenceIdExample apiScenarioReferenceIdExample = new ApiScenarioReferenceIdExample(); + apiScenarioReferenceIdExample.createCriteria().andDataTypeEqualTo(ReportTriggerMode.API.name()).andReferenceTypeEqualTo(COPY).andReferenceIdEqualTo(testId); + List apiScenarioReferenceIds = apiScenarioReferenceIdMapper.selectByExample(apiScenarioReferenceIdExample); + return apiScenarioReferenceIds.size(); + } } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java index 0821c9d691..288ac2face 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java @@ -1305,6 +1305,7 @@ public class ApiTestCaseService { Long toBeUpdatedTime = this.getToBeUpdatedTime(request.getProjectId()); if (toBeUpdatedTime != null) { request.setToBeUpdateTime(toBeUpdatedTime); + request.setUpdateTime(toBeUpdatedTime); } List syncRuleCaseStatus = apiTestCaseSyncService.getSyncRuleCaseStatus(request.getProjectId()); if (CollectionUtils.isEmpty(syncRuleCaseStatus)) { diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml index 1b36c234fe..7bc5089f9a 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml @@ -513,10 +513,11 @@ and t1.to_be_updated = #{request.toBeUpdated} - and (t1.to_be_update_time >= #{request.toBeUpdateTime} or t1.status in + and (t1.to_be_update_time >= #{request.toBeUpdateTime} or ( t1.status in #{value} - ) + + and t1.update_time>= #{request.updateTime} )) and t1.to_be_update_time >= #{request.toBeUpdateTime} diff --git a/frontend/src/business/components/api/definition/components/complete/EditCompleteHTTPApi.vue b/frontend/src/business/components/api/definition/components/complete/EditCompleteHTTPApi.vue index 4985a023cb..713f29d153 100644 --- a/frontend/src/business/components/api/definition/components/complete/EditCompleteHTTPApi.vue +++ b/frontend/src/business/components/api/definition/components/complete/EditCompleteHTTPApi.vue @@ -370,7 +370,8 @@ export default { syncCase: true, sendNotice: true, }, - noShowSyncRuleRelation: false + noShowSyncRuleRelation: false, + citedScenarioCount: 0 }; }, props: {moduleOptions: {}, request: {}, response: {}, basisData: {}, syncTabs: Array, projectId: String}, @@ -583,7 +584,7 @@ export default { this.httpForm.versionId = this.$refs.versionHistory.currentVersion.id; } } - if (hasLicense() && this.httpForm.caseTotal > 0 && !this.httpForm.isCopy) { + if (hasLicense() && (this.httpForm.caseTotal > 0 || this.citedScenarioCount > 0) && !this.httpForm.isCopy) { if ((this.httpForm.method !== this.beforeHttpForm.method) && !this.noShowSyncRuleRelation) { this.batchSyncApiVisible = true; } @@ -964,6 +965,13 @@ export default { this.noShowSyncRuleRelation = false; this.saveApi(); } + }, + getCitedScenarioCount() { + this.$get('/api/definition/be/cited/scenario/' + this.httpForm.id, response => { + if (response.data) { + this.citedScenarioCount = response.data; + } + }); } }, @@ -993,6 +1001,7 @@ export default { if (hasLicense()) { this.getVersionHistory(); this.getSyncRule(); + this.getCitedScenarioCount(); } }, mounted() {