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) {