diff --git a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.java b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.java index e7b0f45798..3cfaec8df5 100644 --- a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.java +++ b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.java @@ -100,4 +100,6 @@ public interface ExtApiTestCaseMapper { List relevanceApiList(@Param("request") ApiTestCaseRequest request); List selectBaseCaseByProjectId(@Param("projectId") String projectId); + + int getCaseCountById(String id); } diff --git a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml index d4fde38e4c..69f0b241a8 100644 --- a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml +++ b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml @@ -1220,4 +1220,14 @@ GROUP BY ${apiCaseGroupColumn} + + diff --git a/api-test/backend/src/main/java/io/metersphere/controller/definition/ApiTestCaseController.java b/api-test/backend/src/main/java/io/metersphere/controller/definition/ApiTestCaseController.java index d4c820beff..7b6502e9bf 100644 --- a/api-test/backend/src/main/java/io/metersphere/controller/definition/ApiTestCaseController.java +++ b/api-test/backend/src/main/java/io/metersphere/controller/definition/ApiTestCaseController.java @@ -266,4 +266,9 @@ public class ApiTestCaseController { public List getScenarioCaseByIds(@RequestBody ApiCaseExportJmxRequest request) { return apiTestCaseService.exportJmx(request.getCaseIds(), request.getEnvId()); } + + @PostMapping("/case-count") + public int getCaseCountById(@RequestBody SaveApiTestCaseRequest request) { + return apiTestCaseService.getCaseCountById(request.getId()); + } } diff --git a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiTestCaseService.java b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiTestCaseService.java index 06d3a7fc6b..2f07f00095 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiTestCaseService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiTestCaseService.java @@ -1233,4 +1233,8 @@ public class ApiTestCaseService { jmxInfoDTO.setName(apiTestCase.getName()); return jmxInfoDTO; } + + public int getCaseCountById(String id) { + return extApiTestCaseMapper.getCaseCountById(id); + } } diff --git a/api-test/frontend/src/api/api-test-case.js b/api-test/frontend/src/api/api-test-case.js index 9ba4003228..92a5ef4617 100644 --- a/api-test/frontend/src/api/api-test-case.js +++ b/api-test/frontend/src/api/api-test-case.js @@ -81,3 +81,7 @@ export function createApiCase(file, files, params) { export function editApiCase(url, file, files, params) { return fileUpload(url, file, files, params); } + +export function apiTestCaseCount(param) { + return post('/api/testcase/case-count',param); +} diff --git a/api-test/frontend/src/business/definition/components/complete/EditCompleteDubboApi.vue b/api-test/frontend/src/business/definition/components/complete/EditCompleteDubboApi.vue index 268fb0b5ce..a010c66db4 100644 --- a/api-test/frontend/src/business/definition/components/complete/EditCompleteDubboApi.vue +++ b/api-test/frontend/src/business/definition/components/complete/EditCompleteDubboApi.vue @@ -96,6 +96,7 @@ import {createComponent} from ".././jmeter/components"; import {TYPE_TO_C} from "@/business/automation/scenario/Setting"; import MsDialogFooter from "metersphere-frontend/src/components/MsDialogFooter"; import {useApiStore} from "@/store"; +import {apiTestCaseCount} from "@/api/api-test-case"; const store = useApiStore(); const {Body} = require("@/business/definition/model/ApiTestModel"); @@ -345,18 +346,23 @@ export default { // 创建新版本 this.basisData.versionId = row.id; this.basisData.versionName = row.name; - this.$set(this.basisData, 'newVersionRemark', !!this.basisData.remark); - this.$set(this.basisData, 'newVersionDeps', this.$refs.apiOtherInfo.relationshipCount > 0); - this.$set(this.basisData, 'newVersionCase', this.basisData.caseTotal > 0); - - if (this.$refs.apiOtherInfo.relationshipCount > 0 || this.basisData.remark || this.basisData.newVersionCase) { - this.createNewVersionVisible = true; - } else { - this.saveApi(); - if (this.$refs.versionHistory) { - this.$refs.versionHistory.loading = false; + apiTestCaseCount({id: this.basisData.id}).then(response => { + if (response.data > 0) { + this.basisData.caseTotal = response.data; } - } + this.$set(this.basisData, 'newVersionRemark', !!this.basisData.remark); + this.$set(this.basisData, 'newVersionDeps', this.$refs.apiOtherInfo.relationshipCount > 0); + this.$set(this.basisData, 'newVersionCase', this.basisData.caseTotal > 0); + + if (this.$refs.apiOtherInfo.relationshipCount > 0 || this.basisData.remark || this.basisData.newVersionCase) { + this.createNewVersionVisible = true; + } else { + this.saveApi(); + if (this.$refs.versionHistory) { + this.$refs.versionHistory.loading = false; + } + } + }); }, del(row) { this.$alert(this.$t('api_test.definition.request.delete_confirm') + ' ' + row.name + " ?", '', { diff --git a/api-test/frontend/src/business/definition/components/complete/EditCompleteHTTPApi.vue b/api-test/frontend/src/business/definition/components/complete/EditCompleteHTTPApi.vue index 49147353a9..ef4b9771d9 100644 --- a/api-test/frontend/src/business/definition/components/complete/EditCompleteHTTPApi.vue +++ b/api-test/frontend/src/business/definition/components/complete/EditCompleteHTTPApi.vue @@ -210,6 +210,7 @@ import { getMockEnvironment, updateDefinitionFollows } from "@/api/definition"; +import {apiTestCaseCount} from "@/api/api-test-case"; import {relationGet, updateRuleRelation} from "@/api/xpack"; import MsApiRequestForm from "../request/http/ApiHttpRequestForm"; import MsResponseText from "../response/ResponseText"; @@ -787,25 +788,30 @@ export default { // 创建新版本 this.httpForm.versionId = row.id; this.httpForm.versionName = row.name; - this.$set(this.httpForm, 'newVersionRemark', !!this.httpForm.remark); - this.$set(this.httpForm, 'newVersionDeps', this.$refs.apiOtherInfo.relationshipCount > 0); - this.$set(this.httpForm, 'newVersionCase', this.httpForm.caseTotal > 0); - createMockConfig({projectId: this.projectId, apiId: this.httpForm.id}).then(response => { - this.$set(this.httpForm, 'newVersionMock', response.data.mockExpectConfigList.length > 0); + apiTestCaseCount({id: this.httpForm.id}).then(response => { + if (response.data > 0) { + this.httpForm.caseTotal = response.data; + } + this.$set(this.httpForm, 'newVersionRemark', !!this.httpForm.remark); + this.$set(this.httpForm, 'newVersionDeps', this.$refs.apiOtherInfo.relationshipCount > 0); + this.$set(this.httpForm, 'newVersionCase', this.httpForm.caseTotal > 0); + createMockConfig({projectId: this.projectId, apiId: this.httpForm.id}).then(response => { + this.$set(this.httpForm, 'newVersionMock', response.data.mockExpectConfigList.length > 0); - if (this.$refs.apiOtherInfo.relationshipCount > 0 || this.httpForm.remark || - this.httpForm.newVersionCase || this.httpForm.newVersionMock) { - this.createNewVersionVisible = true; - } else { - this.saveApi(); + if (this.$refs.apiOtherInfo.relationshipCount > 0 || this.httpForm.remark || + this.httpForm.newVersionCase || this.httpForm.newVersionMock) { + this.createNewVersionVisible = true; + } else { + this.saveApi(); + if (this.$refs.versionHistory) { + this.$refs.versionHistory.loading = false; + } + } + }, error => { if (this.$refs.versionHistory) { this.$refs.versionHistory.loading = false; } - } - }, error => { - if (this.$refs.versionHistory) { - this.$refs.versionHistory.loading = false; - } + }); }); }, del(row) { diff --git a/api-test/frontend/src/business/definition/components/complete/EditCompleteSQLApi.vue b/api-test/frontend/src/business/definition/components/complete/EditCompleteSQLApi.vue index e3986f4f1a..24dd1f62ed 100644 --- a/api-test/frontend/src/business/definition/components/complete/EditCompleteSQLApi.vue +++ b/api-test/frontend/src/business/definition/components/complete/EditCompleteSQLApi.vue @@ -82,7 +82,8 @@ import { definitionFollow, delDefinitionByRefId, - getDefinitionById, getDefinitionByIdAndRefId, + getDefinitionById, + getDefinitionByIdAndRefId, getDefinitionVersions, updateDefinitionFollows } from "@/api/definition"; @@ -97,6 +98,7 @@ import {createComponent} from ".././jmeter/components"; import {TYPE_TO_C} from "@/business/automation/scenario/Setting"; import MsDialogFooter from "metersphere-frontend/src/components/MsDialogFooter"; import {useApiStore} from "@/store"; +import {apiTestCaseCount} from "@/api/api-test-case"; const store = useApiStore(); const {Body} = require("@/business/definition/model/ApiTestModel"); @@ -358,18 +360,23 @@ export default { // 创建新版本 this.basisData.versionId = row.id; this.basisData.versionName = row.name; - this.$set(this.basisData, 'newVersionRemark', !!this.basisData.remark); - this.$set(this.basisData, 'newVersionDeps', this.$refs.apiOtherInfo.relationshipCount > 0); - this.$set(this.basisData, 'newVersionCase', this.basisData.caseTotal > 0); - - if (this.$refs.apiOtherInfo.relationshipCount > 0 || this.basisData.remark || this.basisData.newVersionCase) { - this.createNewVersionVisible = true; - } else { - this.saveApi(); - if (this.$refs.versionHistory) { - this.$refs.versionHistory.loading = false; + apiTestCaseCount({id: this.basisData.id}).then(response => { + if (response.data > 0) { + this.basisData.caseTotal = response.data; } - } + this.$set(this.basisData, 'newVersionRemark', !!this.basisData.remark); + this.$set(this.basisData, 'newVersionDeps', this.$refs.apiOtherInfo.relationshipCount > 0); + this.$set(this.basisData, 'newVersionCase', this.basisData.caseTotal > 0); + + if (this.$refs.apiOtherInfo.relationshipCount > 0 || this.basisData.remark || this.basisData.newVersionCase) { + this.createNewVersionVisible = true; + } else { + this.saveApi(); + if (this.$refs.versionHistory) { + this.$refs.versionHistory.loading = false; + } + } + }); }, del(row) { this.$alert(this.$t('api_test.definition.request.delete_confirm') + ' ' + row.name + " ?", '', { diff --git a/api-test/frontend/src/business/definition/components/complete/EditCompleteTCPApi.vue b/api-test/frontend/src/business/definition/components/complete/EditCompleteTCPApi.vue index 4216ba1d16..e9a0f6c2f7 100644 --- a/api-test/frontend/src/business/definition/components/complete/EditCompleteTCPApi.vue +++ b/api-test/frontend/src/business/definition/components/complete/EditCompleteTCPApi.vue @@ -114,6 +114,7 @@ import {createComponent} from ".././jmeter/components"; import {TYPE_TO_C} from "@/business/automation/scenario/Setting"; import MsDialogFooter from "metersphere-frontend/src/components/MsDialogFooter"; import {useApiStore} from "@/store"; +import {apiTestCaseCount} from "@/api/api-test-case"; const store = useApiStore(); const {Body} = require("@/business/definition/model/ApiTestModel"); @@ -460,22 +461,27 @@ export default { // 创建新版本 this.basisData.versionId = row.id; this.basisData.versionName = row.name; - this.$set(this.basisData, 'newVersionRemark', !!this.basisData.remark); - this.$set(this.basisData, 'newVersionDeps', this.$refs.apiOtherInfo.relationshipCount > 0); - this.$set(this.basisData, 'newVersionCase', this.basisData.caseTotal > 0); - - createMockConfig({projectId: this.projectId, apiId: this.basisData.id}).then(response => { - this.$set(this.basisData, 'newVersionMock', response.data.mockExpectConfigList.length > 0); - - if (this.$refs.apiOtherInfo.relationshipCount > 0 || this.basisData.remark || - this.basisData.newVersionCase || this.basisData.newVersionMock) { - this.createNewVersionVisible = true; - } else { - this.saveApi(); - if (this.$refs.versionHistory) { - this.$refs.versionHistory.loading = false; - } + apiTestCaseCount({id: this.basisData.id}).then(response => { + if (response.data > 0) { + this.basisData.caseTotal = response.data; } + this.$set(this.basisData, 'newVersionRemark', !!this.basisData.remark); + this.$set(this.basisData, 'newVersionDeps', this.$refs.apiOtherInfo.relationshipCount > 0); + this.$set(this.basisData, 'newVersionCase', this.basisData.caseTotal > 0); + + createMockConfig({projectId: this.projectId, apiId: this.basisData.id}).then(response => { + this.$set(this.basisData, 'newVersionMock', response.data.mockExpectConfigList.length > 0); + + if (this.$refs.apiOtherInfo.relationshipCount > 0 || this.basisData.remark || + this.basisData.newVersionCase || this.basisData.newVersionMock) { + this.createNewVersionVisible = true; + } else { + this.saveApi(); + if (this.$refs.versionHistory) { + this.$refs.versionHistory.loading = false; + } + } + }); }); }, del(row) {