From 637a640c426b67ef2529f889ce20974a5ddbf814 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Wed, 27 Oct 2021 13:47:02 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20#1007479#1007454=20=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E9=9B=86=E6=88=90=E4=B8=AD=E7=9A=84=E6=8F=90=E7=A4=BA=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E6=97=A0=E6=B3=95=E6=98=BE=E7=A4=BA=20=E3=80=90?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E7=BB=9F=E8=AE=A1=E3=80=91=E5=B7=A6=E4=BE=A7?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E6=A0=91=E7=BB=9F=E8=AE=A1=E6=95=B0=E9=87=8F?= =?UTF-8?q?=EF=BC=8C=E5=8F=AA=E6=9C=89=E5=9C=BA=E6=99=AF=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E4=BA=86,=E4=BF=AE=E5=A4=8Dmock=E6=9C=9F=E6=9C=9B=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E6=97=B6=E5=8F=82=E6=95=B0=E8=8E=B7=E5=8F=96=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E5=AF=BC=E8=87=B4=E7=9A=84=E5=8C=B9=E9=85=8D=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1007479 --user=宋天阳 服务集成中的提示图片无法显示 https://www.tapd.cn/55049933/s/1059464;--bug=1007454 --user=宋天阳 【模块统计】左侧模块树统计数量,只有场景统计了 https://www.tapd.cn/55049933/s/1059466,修复mock期望匹配时参数获取错误导致的匹配失败问题 --- .../api/controller/ApiModuleController.java | 7 +++++++ .../api/dto/mock/MockApiUtils.java | 19 ++++++++----------- .../api/service/ApiDefinitionService.java | 1 - .../api/service/ApiModuleService.java | 8 ++++++++ .../controller/TestCaseNodeController.java | 6 ++++++ .../track/service/TestCaseNodeService.java | 6 ++++++ .../api/definition/ApiDefinition.vue | 9 +++++++++ .../definition/components/list/ApiList.vue | 1 + .../components/module/ApiModule.vue | 2 ++ .../components/module/ApiModuleHeader.vue | 3 ++- .../reportstatistics/ReportAnalysis.vue | 2 +- .../TestCaseCountContainer.vue | 2 +- .../chart/TestCaseCountChart.vue | 0 .../filter/TestCaseCountFilter.vue | 0 .../table/TestCaseCountTable.vue | 0 .../workspace/components/JiraSetting.vue | 4 ++-- .../components/track/case/TestCase.vue | 9 +++++++++ .../track/case/components/TestCaseList.vue | 1 + .../track/common/TestCaseNodeTree.vue | 3 ++- 19 files changed, 65 insertions(+), 18 deletions(-) rename frontend/src/business/components/reportstatistics/{testCaseCount => casecount}/TestCaseCountContainer.vue (99%) rename frontend/src/business/components/reportstatistics/{testCaseCount => casecount}/chart/TestCaseCountChart.vue (100%) rename frontend/src/business/components/reportstatistics/{testCaseCount => casecount}/filter/TestCaseCountFilter.vue (100%) rename frontend/src/business/components/reportstatistics/{testCaseCount => casecount}/table/TestCaseCountTable.vue (100%) diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiModuleController.java b/backend/src/main/java/io/metersphere/api/controller/ApiModuleController.java index 3c6a5cf0b5..acd147e829 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiModuleController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiModuleController.java @@ -31,6 +31,13 @@ public class ApiModuleController { return apiModuleService.getNodeTreeByProjectId(projectId, protocol); } + @GetMapping("/trashCount/{projectId}/{protocol}") + public long trashCount(@PathVariable String projectId, @PathVariable String protocol) { + String userId = SessionUtils.getUserId(); + ApiDefinitionDefaultApiTypeUtil.addUserSelectApiType(userId, protocol); + return apiModuleService.countTrashApiData(projectId, protocol); + } + @GetMapping("/getModuleByName/{projectId}/{protocol}") public ApiModule getModuleByName(@PathVariable String projectId, @PathVariable String protocol) { // checkPermissionService.checkProjectOwner(projectId); diff --git a/backend/src/main/java/io/metersphere/api/dto/mock/MockApiUtils.java b/backend/src/main/java/io/metersphere/api/dto/mock/MockApiUtils.java index 0e024fb545..785d59a050 100644 --- a/backend/src/main/java/io/metersphere/api/dto/mock/MockApiUtils.java +++ b/backend/src/main/java/io/metersphere/api/dto/mock/MockApiUtils.java @@ -446,12 +446,16 @@ public class MockApiUtils { RequestMockParams returnParams = getGetParamMap(urlParams,apiPath,queryParamsObject); if(paramJson != null){ if (paramJson instanceof JSONObject) { - JSONArray paramsArray = new JSONArray(); - paramsArray.add(paramJson); - returnParams.setBodyParams(paramsArray); + if(!((JSONObject) paramJson).isEmpty()){ + JSONArray paramsArray = new JSONArray(); + paramsArray.add(paramJson); + returnParams.setBodyParams(paramsArray); + } } else if (paramJson instanceof JSONArray) { JSONArray paramArray = (JSONArray) paramJson; - returnParams.setBodyParams(paramArray); + if(!paramArray.isEmpty()){ + returnParams.setBodyParams(paramArray); + } } } return returnParams; @@ -527,13 +531,6 @@ public class MockApiUtils { if(StringUtils.isNotEmpty(bodyParam)){ object.put("raw",bodyParam); } - - Enumeration paramNameItor = request.getParameterNames(); - while (paramNameItor.hasMoreElements()) { - String key = paramNameItor.nextElement(); - String value = request.getParameter(key); - object.put(key, value); - } return object; } } 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 9fa0fdc237..6c94aec44c 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -217,7 +217,6 @@ public class ApiDefinitionService { return resList; } - /** * 初始化部分参数 * diff --git a/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java b/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java index d4b8b1afc4..8cb6f30304 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java @@ -43,6 +43,8 @@ public class ApiModuleService extends NodeTreeService { @Resource private ExtApiDefinitionMapper extApiDefinitionMapper; @Resource + private ApiDefinitionMapper apiDefinitionMapper; + @Resource private TestPlanProjectService testPlanProjectService; @Resource private ProjectService projectService; @@ -539,4 +541,10 @@ public class ApiModuleService extends NodeTreeService { return list.get(0); } } + + public long countTrashApiData(String projectId, String protocol) { + ApiDefinitionExample example = new ApiDefinitionExample(); + example.createCriteria().andProjectIdEqualTo(projectId).andProtocolEqualTo(protocol).andStatusEqualTo("Trash"); + return apiDefinitionMapper.countByExample(example); + } } diff --git a/backend/src/main/java/io/metersphere/track/controller/TestCaseNodeController.java b/backend/src/main/java/io/metersphere/track/controller/TestCaseNodeController.java index 9382227e35..a9b13e6422 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestCaseNodeController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestCaseNodeController.java @@ -29,6 +29,12 @@ public class TestCaseNodeController { return testCaseNodeService.getNodeTreeByProjectId(projectId); } + @GetMapping("/trashCount/{projectId}") + public long trashCount(@PathVariable String projectId) { + checkPermissionService.checkProjectOwner(projectId); + return testCaseNodeService.trashCount(projectId); + } + /*模块列表列表*/ @PostMapping("/list/all/plan") public List getAllNodeByPlanId(@RequestBody QueryNodeRequest request) { diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseNodeService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseNodeService.java index 0e13bd0017..d0afcd86ed 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseNodeService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseNodeService.java @@ -764,4 +764,10 @@ public class TestCaseNodeService extends NodeTreeService { } return returnList; } + + public long trashCount(String projectId) { + TestCaseExample testCaseExample = new TestCaseExample(); + testCaseExample.createCriteria().andProjectIdEqualTo(projectId).andStatusEqualTo("Trash"); + return testCaseMapper.countByExample(testCaseExample); + } } diff --git a/frontend/src/business/components/api/definition/ApiDefinition.vue b/frontend/src/business/components/api/definition/ApiDefinition.vue index 923347d00e..bf2bcac6cf 100644 --- a/frontend/src/business/components/api/definition/ApiDefinition.vue +++ b/frontend/src/business/components/api/definition/ApiDefinition.vue @@ -16,6 +16,7 @@ @schedule="handleTabsEdit($t('api_test.api_import.timing_synchronization'), 'SCHEDULE')" :type="'edit'" page-source="definition" + :total='total' ref="nodeTree"/> @@ -46,6 +47,7 @@ v-if="trashActiveDom==='left'" @runTest="runTest" @refreshTree="refreshTree" + @getTrashApi="getTrashApi" :module-tree="nodeTree" :module-options="moduleOptions" :current-protocol="currentProtocol" @@ -101,6 +103,7 @@ { }); }, + getTrashApi(){ + this.$get("/api/module/trashCount/"+this.projectId +"/"+this.currentProtocol, response => { + this.total = response.data; + }); + }, getEnv() { this.$get("/api/definition/env/get/" + getCurrentUserId(), response => { let env = response.data; diff --git a/frontend/src/business/components/api/definition/components/list/ApiList.vue b/frontend/src/business/components/api/definition/components/list/ApiList.vue index cb70a5acef..f1aeece5df 100644 --- a/frontend/src/business/components/api/definition/components/list/ApiList.vue +++ b/frontend/src/business/components/api/definition/components/list/ApiList.vue @@ -574,6 +574,7 @@ export default { item.tags = JSON.parse(item.tags); } }); + this.$emit('getTrashApi'); }); } if (this.needRefreshModule()) { diff --git a/frontend/src/business/components/api/definition/components/module/ApiModule.vue b/frontend/src/business/components/api/definition/components/module/ApiModule.vue index afe4efc286..1a414e68ad 100644 --- a/frontend/src/business/components/api/definition/components/module/ApiModule.vue +++ b/frontend/src/business/components/api/definition/components/module/ApiModule.vue @@ -30,6 +30,7 @@ :is-read-only="isReadOnly" :moduleOptions="data" :options="options" + :total="total" @exportAPI="exportAPI" @saveAsEdit="saveAsEdit" @refreshTable="$emit('refreshTable')" @@ -88,6 +89,7 @@ relevanceProjectId: String, reviewId: String, pageSource:String, + total: Number, options: { type: Array, default() { diff --git a/frontend/src/business/components/api/definition/components/module/ApiModuleHeader.vue b/frontend/src/business/components/api/definition/components/module/ApiModuleHeader.vue index cc6ba34ae5..0f845d0776 100644 --- a/frontend/src/business/components/api/definition/components/module/ApiModuleHeader.vue +++ b/frontend/src/business/components/api/definition/components/module/ApiModuleHeader.vue @@ -20,7 +20,7 @@ - + import TestCaseCountChart from "./chart/TestCaseCountChart"; -import TestCaseCountTable from "@/business/components/reportstatistics/testCaseCount/table/TestCaseCountTable"; +import TestCaseCountTable from "@/business/components/reportstatistics/casecount/table/TestCaseCountTable"; import TestCaseCountFilter from "./filter/TestCaseCountFilter"; import {exportPdf,getCurrentProjectID} from "@/common/js/utils"; import html2canvas from 'html2canvas'; diff --git a/frontend/src/business/components/reportstatistics/testCaseCount/chart/TestCaseCountChart.vue b/frontend/src/business/components/reportstatistics/casecount/chart/TestCaseCountChart.vue similarity index 100% rename from frontend/src/business/components/reportstatistics/testCaseCount/chart/TestCaseCountChart.vue rename to frontend/src/business/components/reportstatistics/casecount/chart/TestCaseCountChart.vue diff --git a/frontend/src/business/components/reportstatistics/testCaseCount/filter/TestCaseCountFilter.vue b/frontend/src/business/components/reportstatistics/casecount/filter/TestCaseCountFilter.vue similarity index 100% rename from frontend/src/business/components/reportstatistics/testCaseCount/filter/TestCaseCountFilter.vue rename to frontend/src/business/components/reportstatistics/casecount/filter/TestCaseCountFilter.vue diff --git a/frontend/src/business/components/reportstatistics/testCaseCount/table/TestCaseCountTable.vue b/frontend/src/business/components/reportstatistics/casecount/table/TestCaseCountTable.vue similarity index 100% rename from frontend/src/business/components/reportstatistics/testCaseCount/table/TestCaseCountTable.vue rename to frontend/src/business/components/reportstatistics/casecount/table/TestCaseCountTable.vue diff --git a/frontend/src/business/components/settings/workspace/components/JiraSetting.vue b/frontend/src/business/components/settings/workspace/components/JiraSetting.vue index 2eaca312db..e094a141d6 100644 --- a/frontend/src/business/components/settings/workspace/components/JiraSetting.vue +++ b/frontend/src/business/components/settings/workspace/components/JiraSetting.vue @@ -17,7 +17,7 @@ @@ -25,7 +25,7 @@ diff --git a/frontend/src/business/components/track/case/TestCase.vue b/frontend/src/business/components/track/case/TestCase.vue index fb07151c85..4d8c407e47 100644 --- a/frontend/src/business/components/track/case/TestCase.vue +++ b/frontend/src/business/components/track/case/TestCase.vue @@ -13,6 +13,7 @@ @refreshAll="refreshAll" @enableTrash="enableTrash" :type="'edit'" + :total='total' ref="nodeTree" /> @@ -29,6 +30,7 @@ @testCaseEdit="editTestCase" @testCaseCopy="copyTestCase" @testCaseDetail="showTestCaseDetail" + @getTrashList="getTrashList" @refresh="refresh" @refreshAll="refreshAll" @setCondition="setCondition" @@ -55,6 +57,7 @@ @testCaseEdit="editTestCase" @testCaseCopy="copyTestCase" @testCaseDetail="showTestCaseDetail" + @getTrashList="getTrashList" @refresh="refresh" @refreshAll="refreshAll" @setCondition="setCondition" @@ -163,6 +166,7 @@ export default { type: '', activeDom: 'left', tmpActiveDom: null, + total: 0 }; }, mounted() { @@ -246,6 +250,11 @@ export default { break; } }, + getTrashList(){ + this.$get("/case/node/trashCount/"+this.projectId , response => { + this.total = response.data; + }); + }, updateActiveDom(activeDom) { let isTestCaseMinderChanged = this.$store.state.isTestCaseMinderChanged; if (this.activeDom !== 'left' && activeDom === 'left' && isTestCaseMinderChanged) { diff --git a/frontend/src/business/components/track/case/components/TestCaseList.vue b/frontend/src/business/components/track/case/components/TestCaseList.vue index fbf2d60c83..727eafbf67 100644 --- a/frontend/src/business/components/track/case/components/TestCaseList.vue +++ b/frontend/src/business/components/track/case/components/TestCaseList.vue @@ -622,6 +622,7 @@ export default { }); }); + this.$emit("getTrashList"); } }, search() { diff --git a/frontend/src/business/components/track/common/TestCaseNodeTree.vue b/frontend/src/business/components/track/common/TestCaseNodeTree.vue index 7e12edf782..ee6f91ca4b 100644 --- a/frontend/src/business/components/track/common/TestCaseNodeTree.vue +++ b/frontend/src/business/components/track/common/TestCaseNodeTree.vue @@ -23,7 +23,7 @@ :show-operator="showOperator" :condition="condition" :commands="operators"/> - + @@ -91,6 +91,7 @@ export default { default: "view" }, showOperator: Boolean, + total: Number, }, watch: { treeNodes() {