From 1ec251c65af9ed946858ff4ce8c621250639c85f Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Wed, 13 Jan 2021 11:20:27 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=B5=8B=E8=AF=95=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E5=88=97=E8=A1=A8=E9=A1=B5=E9=9D=A2=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/ApiTestCaseController.java | 9 +++++---- .../metersphere/api/service/ApiTestCaseService.java | 7 ++++--- .../api/definition/components/case/ApiCaseItem.vue | 9 ++++++--- .../components/reference/ReferenceView.vue | 12 ++++++++++-- .../components/api/homepage/ApiTestHomePage.vue | 6 +++--- .../components/dragbar/MsBottom2TopDragBar.vue | 2 +- 6 files changed, 29 insertions(+), 16 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java b/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java index e74246f3f8..26d20b7aae 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java @@ -5,6 +5,7 @@ import com.github.pagehelper.PageHelper; import io.metersphere.api.dto.ApiCaseBatchRequest; import io.metersphere.api.dto.definition.*; import io.metersphere.api.service.ApiTestCaseService; +import io.metersphere.base.domain.ApiTestCase; import io.metersphere.base.domain.ApiTestCaseWithBLOBs; import io.metersphere.commons.constants.RoleConstants; import io.metersphere.commons.utils.PageUtils; @@ -61,13 +62,13 @@ public class ApiTestCaseController { } @PostMapping(value = "/create", consumes = {"multipart/form-data"}) - public void create(@RequestPart("request") SaveApiTestCaseRequest request, @RequestPart(value = "files") List bodyFiles) { - apiTestCaseService.create(request, bodyFiles); + public ApiTestCase create(@RequestPart("request") SaveApiTestCaseRequest request, @RequestPart(value = "files") List bodyFiles) { + return apiTestCaseService.create(request, bodyFiles); } @PostMapping(value = "/update", consumes = {"multipart/form-data"}) - public void update(@RequestPart("request") SaveApiTestCaseRequest request, @RequestPart(value = "files") List bodyFiles) { - apiTestCaseService.update(request, bodyFiles); + public ApiTestCase update(@RequestPart("request") SaveApiTestCaseRequest request, @RequestPart(value = "files") List bodyFiles) { + return apiTestCaseService.update(request, bodyFiles); } @GetMapping("/delete/{id}") 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 bf62372aba..b3b5fb7621 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java @@ -116,10 +116,11 @@ public class ApiTestCaseService { return apiTestCaseMapper.selectByPrimaryKey(id); } - public void create(SaveApiTestCaseRequest request, List bodyFiles) { + public ApiTestCase create(SaveApiTestCaseRequest request, List bodyFiles) { List bodyUploadIds = new ArrayList<>(request.getBodyUploadIds()); ApiTestCase test = createTest(request); createBodyFiles(test, bodyUploadIds, bodyFiles); + return test; } private void checkQuota() { @@ -129,13 +130,13 @@ public class ApiTestCaseService { } } - public void update(SaveApiTestCaseRequest request, List bodyFiles) { - + public ApiTestCase update(SaveApiTestCaseRequest request, List bodyFiles) { deleteFileByTestId(request.getId()); List bodyUploadIds = new ArrayList<>(request.getBodyUploadIds()); request.setBodyUploadIds(null); ApiTestCase test = updateTest(request); createBodyFiles(test, bodyUploadIds, bodyFiles); + return test; } private void createBodyFiles(ApiTestCase test, List bodyUploadIds, List bodyFiles) { diff --git a/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue b/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue index e2d383b5bb..1c026f4873 100644 --- a/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue +++ b/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue @@ -16,7 +16,7 @@ @click="active(apiCase)"/> + @blur="saveTestCase(apiCase)" :placeholder="$t('commons.input_name')"/> {{ apiCase.id ? apiCase.name : '' }} @@ -211,9 +211,12 @@ export default { if (tmp.tags instanceof Array) { tmp.tags = JSON.stringify(tmp.tags); } - this.$fileUpload(url, null, bodyFiles, tmp, () => { + this.$fileUpload(url, null, bodyFiles, tmp, (response) => { + let data = response.data; + row.id = data.id; + row.createTime = data.createTime; + row.updateTime = data.updateTime; this.$success(this.$t('commons.save_success')); - this.$emit('refresh'); }); }, showInput(row) { diff --git a/frontend/src/business/components/api/definition/components/reference/ReferenceView.vue b/frontend/src/business/components/api/definition/components/reference/ReferenceView.vue index c3c14f7860..30602db2b0 100644 --- a/frontend/src/business/components/api/definition/components/reference/ReferenceView.vue +++ b/frontend/src/business/components/api/definition/components/reference/ReferenceView.vue @@ -3,12 +3,20 @@ :modal="false" width="45%" :destroy-on-close="true"> {{ $t('api_test.automation.scenario_ref') }}:
-
{{ item.name }}
+
+ + {{ item.name }} + +
{{ $t('api_test.automation.plan_ref') }}:
-
{{ item.name }}
+
+ + {{ item.name }} + +