From 3e3014c7ff6256b0c6528657b38a00895c093a99 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Mon, 13 Sep 2021 14:21:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=80=9A=E7=9F=A5=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ApiAutomationController.java | 6 ++ .../controller/ApiDefinitionController.java | 7 ++- .../api/service/ApiAutomationService.java | 10 ++- .../api/service/ApiDefinitionService.java | 10 +++ .../automation/scenario/ApiScenarioList.vue | 63 +++++++++++-------- .../api/definition/ApiDefinition.vue | 7 +++ .../components/list/ApiCaseSimpleList.vue | 6 ++ .../definition/components/list/ApiList.vue | 7 +++ .../src/business/components/notice/util.js | 14 +++-- 9 files changed, 94 insertions(+), 36 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java b/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java index c537af5acb..bf99442619 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java @@ -56,6 +56,12 @@ public class ApiAutomationController { return apiAutomationService.list(request); } + @GetMapping("/get/{id}") + @RequiresPermissions("PROJECT_API_SCENARIO:READ") + public ApiScenarioDTO getById(@PathVariable String id) { + return apiAutomationService.getDto(id); + } + @PostMapping("/list/all") @RequiresPermissions("PROJECT_API_SCENARIO:READ") public List listAll(@RequestBody ApiScenarioBatchRequest request) { 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 67e28802ec..7d15fb739c 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java @@ -161,8 +161,9 @@ public class ApiDefinitionController { } @GetMapping("/get/{id}") - public ApiDefinition get(@PathVariable String id) { - return apiDefinitionService.get(id); + @RequiresPermissions("PROJECT_API_DEFINITION:READ") + public ApiDefinitionResult getApiDefinitionResult(@PathVariable String id) { + return apiDefinitionService.getById(id); } @PostMapping(value = "/run/debug", consumes = {"multipart/form-data"}) @@ -179,7 +180,7 @@ public class ApiDefinitionController { } @GetMapping("/report/get/{testId}/{test}") - public APIReportResult get(@PathVariable String testId, @PathVariable String test) { + public APIReportResult getResult(@PathVariable String testId, @PathVariable String test) { return apiDefinitionService.getResult(testId, test); } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index 15c29d00d0..bba2b80c55 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -137,8 +137,14 @@ public class ApiAutomationService { @Resource private ExtTestPlanScenarioCaseMapper extTestPlanScenarioCaseMapper; - public ApiScenarioWithBLOBs getDto(String id) { - return apiScenarioMapper.selectByPrimaryKey(id); + public ApiScenarioDTO getDto(String id) { + ApiScenarioRequest request = new ApiScenarioRequest(); + request.setId(id); + List list = extApiScenarioMapper.list(request); + if (CollectionUtils.isNotEmpty(list)) { + return list.get(0); + } + return null; } public ApiTestEnvironment get(String id) { 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 7dcd453cdc..d75138d88d 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -1379,4 +1379,14 @@ public class ApiDefinitionService { extApiDefinitionMapper::getLastOrder, apiDefinitionMapper::updateByPrimaryKeySelective); } + + public ApiDefinitionResult getById(String id) { + ApiDefinitionRequest request = new ApiDefinitionRequest(); + request.setId(id); + List list = list(request); + if (CollectionUtils.isNotEmpty(list)) { + return list.get(0); + } + return null; + } } diff --git a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue index 32cc2eb351..ce97623b0d 100644 --- a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue +++ b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue @@ -182,10 +182,14 @@ @@ -206,10 +211,12 @@ - + - @@ -235,9 +242,7 @@ import {downloadFile, getCurrentProjectID, getUUID, strMapToObj} from "@/common/ import {API_SCENARIO_CONFIGS} from "@/business/components/common/components/search/search-components"; import {API_SCENARIO_LIST} from "../../../../../common/js/constants"; -import { - getCustomTableHeader, getCustomTableWidth, getLastTableSortField, handleRowDrop, saveLastTableSortField -} from "@/common/js/tableUtils"; +import {getCustomTableHeader, getCustomTableWidth, getLastTableSortField, handleRowDrop} from "@/common/js/tableUtils"; import {API_SCENARIO_FILTERS} from "@/common/js/table-constants"; import {scenario} from "@/business/components/track/plan/event-bus"; import MsTable from "@/business/components/common/components/table/MsTable"; @@ -467,7 +472,7 @@ export default { created() { scenario.$on('hide', id => { this.hideStopBtn(id); - }) + }); this.projectId = getCurrentProjectID(); if (!this.projectName || this.projectName === "") { this.getProjectName(); @@ -490,15 +495,21 @@ export default { } - if(this.trashEnable){ - this.condition.orders = [{"name":"delete_time","type":"desc"}]; - }else { + if (this.trashEnable) { + this.condition.orders = [{"name": "delete_time", "type": "desc"}]; + } else { this.condition.orders = getLastTableSortField(this.tableHeaderKey); } this.search(); this.getPrincipalOptions([]); + // 通知过来的数据跳转到编辑 + if (this.$route.query.resourceId) { + this.$get('/api/automation/get/' + this.$route.query.resourceId, (response) => { + this.edit(response.data); + }); + } }, beforeDestroy() { scenario.$off("hide"); @@ -804,19 +815,19 @@ export default { this.search(); }); return; - }else { + } else { let param = {}; this.buildBatchParam(param); this.$post('/api/automation/checkBeforeDelete/', param, response => { let checkResult = response.data; let alertMsg = this.$t('load_test.delete_threadgroup_confirm') + " ?"; - if(!checkResult.deleteFlag){ + if (!checkResult.deleteFlag) { alertMsg = ""; checkResult.checkMsg.forEach(item => { - alertMsg+=item+";"; + alertMsg += item + ";"; }); - if(alertMsg === ""){ + if (alertMsg === "") { alertMsg = this.$t('load_test.delete_threadgroup_confirm') + " ?"; } else { alertMsg += this.$t('api_test.is_continue') + " ?"; @@ -885,20 +896,20 @@ export default { this.search(); }); return; - }else { + } else { let param = {}; this.buildBatchParam(param); param.ids = [row.id]; this.$post('/api/automation/checkBeforeDelete/', param, response => { let checkResult = response.data; - let alertMsg = this.$t('load_test.delete_threadgroup_confirm') +" ?"; - if(!checkResult.deleteFlag){ + let alertMsg = this.$t('load_test.delete_threadgroup_confirm') + " ?"; + if (!checkResult.deleteFlag) { alertMsg = ""; checkResult.checkMsg.forEach(item => { - alertMsg+=item+";"; + alertMsg += item + ";"; }); - if(alertMsg === ""){ - alertMsg = this.$t('load_test.delete_threadgroup_confirm') +" ?"; + if (alertMsg === "") { + alertMsg = this.$t('load_test.delete_threadgroup_confirm') + " ?"; } else { alertMsg += this.$t('api_test.is_continue') + " ?"; } @@ -1021,10 +1032,10 @@ export default { this.buildBatchParam(param); this.$post('/api/automation/batchCopy', param, response => { let copyResult = response.data; - if(copyResult.result){ + if (copyResult.result) { this.$success(this.$t('api_test.definition.request.batch_copy_end')); - }else { - this.$error(this.$t('commons.already_exists')+":"+copyResult.errorMsg); + } else { + this.$error(this.$t('commons.already_exists') + ":" + copyResult.errorMsg); } this.search(); diff --git a/frontend/src/business/components/api/definition/ApiDefinition.vue b/frontend/src/business/components/api/definition/ApiDefinition.vue index 2556e08d5c..a97f3cc6eb 100644 --- a/frontend/src/business/components/api/definition/ApiDefinition.vue +++ b/frontend/src/business/components/api/definition/ApiDefinition.vue @@ -389,6 +389,13 @@ export default { }, created() { this.getEnv(); + // 通知过来的数据跳转到编辑 + if (this.$route.query.caseId) { + this.activeDom = 'middle'; + // this.$get('/api/testcase/findById/' + this.$route.query.caseId, (response) => { + // this.edit(response.data); + // }); + } }, methods: { setEnvironment(data) { diff --git a/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue b/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue index 7a30b2a38a..4abc68cc5f 100644 --- a/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue +++ b/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue @@ -388,6 +388,12 @@ export default { } this.initTable(); + // 通知过来的数据跳转到编辑 + if (this.$route.query.caseId) { + this.$get('/api/testcase/findById/' + this.$route.query.caseId, (response) => { + this.handleTestCase(response.data); + }); + } }, watch: { selectNodeIds() { 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 9ad4d7b162..ccfa5dff77 100644 --- a/frontend/src/business/components/api/definition/components/list/ApiList.vue +++ b/frontend/src/business/components/api/definition/components/list/ApiList.vue @@ -437,6 +437,13 @@ export default { this.initTable(); this.getMaintainerOptions(); + + // 通知过来的数据跳转到编辑 + if (this.$route.query.resourceId) { + this.$get('/api/definition/get/' + this.$route.query.resourceId, (response) => { + this.editApi(response.data); + }); + } }, watch: { selectNodeIds() { diff --git a/frontend/src/business/components/notice/util.js b/frontend/src/business/components/notice/util.js index 784eb4ec88..9e1b3a7c3b 100644 --- a/frontend/src/business/components/notice/util.js +++ b/frontend/src/business/components/notice/util.js @@ -118,10 +118,10 @@ export function getUrl(d) { url += "/track/plan/all"; break; case "TEST_PLAN_TASK" : - url += "/track/plan/all"; + url += "/track/plan/view/" + d.resourceId; break; case "REVIEW_TASK" : - url += "/track/review/all"; + url += "/track/review/view/" + d.resourceId; break; case "DEFECT_TASK" : url += "/track/issue"; @@ -130,10 +130,14 @@ export function getUrl(d) { url += "/api/definition"; break; case "API_AUTOMATION_TASK" : - url += "/api/automation"; + url += "/api/automation?resourceId=" + d.resourceId; break; case "API_DEFINITION_TASK" : - url += "/api/definition"; + if (d.operation.startsWith('CASE_')) { + url += "/api/definition?caseId=" + d.resourceId; + } else { + url += "/api/definition?resourceId=" + d.resourceId; + } break; case "API_HOME_TASK" : url += "/api/home"; @@ -145,7 +149,7 @@ export function getUrl(d) { url += "/performance/report/all"; break; case "PERFORMANCE_TEST_TASK" : - url += "/performance/test/all"; + url += "/performance/test/edit/" + d.resourceId; break; case "TRACK_TEST_CASE_TASK" : url += "/track/case/all";