From b5cc0dd4a79eb38a50ee3895402caa5300c974c4 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Tue, 4 Jan 2022 16:00:24 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E5=88=97=E8=A1=A8=E5=88=87=E6=8D=A2=E5=88=86?= =?UTF-8?q?=E9=A1=B5=E5=8D=A1=E9=A1=BF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1009377 --user=lyh 接口定义case列表使用多条分页时,需要等待好久才能顺利滑动 https://www.tapd.cn/55049933/s/1089521 --- .../api/controller/ApiTestCaseController.java | 1 + .../api/dto/definition/ApiTestCaseDTO.java | 1 + .../api/dto/definition/ApiTestCaseRequest.java | 4 ++++ .../metersphere/api/service/ApiTestCaseService.java | 13 +++++++++++++ .../components/list/ApiCaseSimpleList.vue | 8 ++------ 5 files changed, 21 insertions(+), 6 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 8a40e1be44..b6e7c3eebb 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java @@ -70,6 +70,7 @@ public class ApiTestCaseController { @PostMapping("/list/{goPage}/{pageSize}") public Pager> listSimple(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiTestCaseRequest request) { Page page = PageHelper.startPage(goPage, pageSize, true); + request.setSelectEnvironment(true); return PageUtils.setPageInfo(page, apiTestCaseService.listSimple(request)); } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseDTO.java b/backend/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseDTO.java index d8afc9784a..f457790204 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseDTO.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseDTO.java @@ -16,6 +16,7 @@ public class ApiTestCaseDTO extends ApiTestCase { private String apiName; private String passRate; private String projectName; + private String environment; private String execResult; private String versionName; } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseRequest.java b/backend/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseRequest.java index 2081a87648..c0d0093334 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseRequest.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseRequest.java @@ -39,4 +39,8 @@ public class ApiTestCaseRequest extends BaseQueryRequest { * 检查待更新的(近三天有更新的或者状态为error的) */ private boolean toUpdate; + /** + * 是否需要查询环境字段 + */ + private boolean selectEnvironment = false; } 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 ad7f9a80d6..29f81f7fc2 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java @@ -36,6 +36,7 @@ import io.metersphere.service.UserService; import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest; import io.metersphere.track.service.TestPlanService; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.SqlSession; @@ -129,10 +130,22 @@ public class ApiTestCaseService { if (CollectionUtils.isEmpty(apiTestCases)) { return apiTestCases; } + if (BooleanUtils.isTrue(request.isSelectEnvironment())) { + setCaseEnvironment(apiTestCases); + } buildUserInfo(apiTestCases); return apiTestCases; } + public void setCaseEnvironment(List apiTestCases) { + for (ApiTestCaseDTO apiCase : apiTestCases) { + ApiTestEnvironment environment = getApiCaseEnvironment(apiCase.getId()); + if (environment != null) { + apiCase.setEnvironment(environment.getName()); + } + } + } + public List idSimple(ApiTestCaseRequest request) { request = this.initRequest(request, true, true); 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 12c4987a9f..4f7bac93b9 100644 --- a/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue +++ b/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue @@ -154,7 +154,7 @@ prop="environment" :field="item" :fields-width="fieldsWidth" - :label="'运行环境'" + :label="$t('commons.environment')" > @@ -162,7 +162,7 @@ prop="createUser" :field="item" :fields-width="fieldsWidth" - :label="'创建人'"/> + :label="$t('commons.create_user')"/> { - let environment = res.data ? res.data.name : '-'; - this.$set(item, 'environment', environment); - }) }); this.$nextTick(() => { if (this.$refs.caseTable) {