From 63b71d5bc49d61cc12a4a6a23665163e15563754 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Fri, 6 Jan 2023 15:20:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A5=E5=8F=A3=E5=92=8C=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E5=A4=8D=E5=88=B6=E7=9A=84=E6=97=B6=E5=80=99=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=B2=A1=E6=9C=89=E5=90=8C=E6=AD=A5=E5=A4=8D?= =?UTF-8?q?=E5=88=B6=E7=9A=84=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1021383 --user=宋天阳 【接口测试】复制了一个带文件的接口定义,复制完后文件还显示,但是执行提示找不到文件 https://www.tapd.cn/55049933/s/1323440 --- .../api/dto/definition/SaveApiTestCaseRequest.java | 3 +++ .../metersphere/service/definition/ApiTestCaseService.java | 7 ++++++- .../src/business/definition/components/ApiConfig.vue | 1 - .../definition/components/list/ApiCaseSimpleList.vue | 7 +++++-- .../src/business/definition/components/list/ApiList.vue | 1 + 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/SaveApiTestCaseRequest.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/SaveApiTestCaseRequest.java index e0fcca5384..87f248b689 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/SaveApiTestCaseRequest.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/SaveApiTestCaseRequest.java @@ -24,4 +24,7 @@ public class SaveApiTestCaseRequest extends ApiTestCase { private List follows; private String versionId; + + //复制用例时的源ID。主要用于复制本地文件等操作。 + private String sourceIdByCopy; } 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 6c8dcddb7c..0563e4c77c 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 @@ -438,7 +438,12 @@ public class ApiTestCaseService { checkNameExist(request); ApiFileUtil.createBodyFiles(request.getId(), bodyFiles); request.setRequest(tcpApiParamService.parseMsTestElement(request.getRequest())); - ApiFileUtil.copyBdyFile(request.getApiDefinitionId(), request.getId()); + if (StringUtils.isNotBlank(request.getSourceIdByCopy())) { + ApiFileUtil.copyBdyFile(request.getSourceIdByCopy(), request.getId()); + } else { + ApiFileUtil.copyBdyFile(request.getApiDefinitionId(), request.getId()); + } + final ApiTestCaseWithBLOBs test = new ApiTestCaseWithBLOBs(); test.setId(request.getId()); diff --git a/api-test/frontend/src/business/definition/components/ApiConfig.vue b/api-test/frontend/src/business/definition/components/ApiConfig.vue index f3ca8162ed..59c4355e75 100644 --- a/api-test/frontend/src/business/definition/components/ApiConfig.vue +++ b/api-test/frontend/src/business/definition/components/ApiConfig.vue @@ -403,7 +403,6 @@ export default { data.request.protocol = this.currentProtocol; } if (data.isCopy) { - data.sourceId = data.id; data.id = getUUID(); data.request.id = data.id; } else { diff --git a/api-test/frontend/src/business/definition/components/list/ApiCaseSimpleList.vue b/api-test/frontend/src/business/definition/components/list/ApiCaseSimpleList.vue index 4ad639b980..2de4fd59c5 100644 --- a/api-test/frontend/src/business/definition/components/list/ApiCaseSimpleList.vue +++ b/api-test/frontend/src/business/definition/components/list/ApiCaseSimpleList.vue @@ -992,7 +992,7 @@ export default { getDefinitionById(row.apiDefinitionId).then((response) => { let api = response.data; if (api) { - this.getCaseAndOpen(row.id, api.name, row.apiDefinitionId); + this.getCaseAndOpen(row.id, api.name, row.apiDefinitionId, true); } }); }, @@ -1004,7 +1004,7 @@ export default { } }); }, - getCaseAndOpen(id, apiName, apiId) { + getCaseAndOpen(id, apiName, apiId, isCopyCase) { getCaseById(id).then((response) => { let data = response.data; let uuid = getUUID(); @@ -1030,6 +1030,9 @@ export default { url: apiCaseRequest.path, uuid: uuid, }; + if (isCopyCase) { + obj.sourceIdByCopy = id; + } this.$refs.caseList.copy(obj); }); }, diff --git a/api-test/frontend/src/business/definition/components/list/ApiList.vue b/api-test/frontend/src/business/definition/components/list/ApiList.vue index cbd4dc8750..50413e6186 100644 --- a/api-test/frontend/src/business/definition/components/list/ApiList.vue +++ b/api-test/frontend/src/business/definition/components/list/ApiList.vue @@ -879,6 +879,7 @@ export default { handleCopy(row) { let obj = JSON.parse(JSON.stringify(row)); obj.isCopy = true; + obj.sourceId = row.id; delete obj.id; this.$emit('copyApi', obj); },