From c824ae45ab1c1adb5ffc28767a6183b26ea1a33f Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Wed, 17 Aug 2022 19:44:34 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=BC=B9=E7=AA=97=E5=8A=A0=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=E5=A4=8D=E5=88=B6=E5=88=A4=E6=96=AD=E4=BB=A5=E5=8F=8A=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E5=8F=B0=E5=8A=A0=E6=9B=B4=E6=96=B0=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --user=郭雨琦 --- .../api/controller/ApiDefinitionController.java | 5 +++++ .../api/service/ApiDefinitionService.java | 14 ++++++++++++-- .../api/service/ApiTestCaseService.java | 1 + .../base/mapper/ext/ExtApiTestCaseMapper.xml | 5 +++-- .../components/complete/EditCompleteHTTPApi.vue | 13 +++++++++++-- 5 files changed, 32 insertions(+), 6 deletions(-) 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() {