fix(接口测试): 用例列表切换分页卡顿问题

--bug=1009377 --user=lyh
接口定义case列表使用多条分页时,需要等待好久才能顺利滑动
https://www.tapd.cn/55049933/s/1089521
This commit is contained in:
shiziyuan9527 2022-01-04 16:00:24 +08:00 committed by 刘瑞斌
parent 9f7e35cbd5
commit b5cc0dd4a7
5 changed files with 21 additions and 6 deletions

View File

@ -70,6 +70,7 @@ public class ApiTestCaseController {
@PostMapping("/list/{goPage}/{pageSize}")
public Pager<List<ApiTestCaseDTO>> listSimple(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiTestCaseRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
request.setSelectEnvironment(true);
return PageUtils.setPageInfo(page, apiTestCaseService.listSimple(request));
}

View File

@ -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;
}

View File

@ -39,4 +39,8 @@ public class ApiTestCaseRequest extends BaseQueryRequest {
* 检查待更新的近三天有更新的或者状态为error的
*/
private boolean toUpdate;
/**
* 是否需要查询环境字段
*/
private boolean selectEnvironment = false;
}

View File

@ -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<ApiTestCaseDTO> apiTestCases) {
for (ApiTestCaseDTO apiCase : apiTestCases) {
ApiTestEnvironment environment = getApiCaseEnvironment(apiCase.getId());
if (environment != null) {
apiCase.setEnvironment(environment.getName());
}
}
}
public List<String> idSimple(ApiTestCaseRequest request) {
request = this.initRequest(request, true, true);

View File

@ -154,7 +154,7 @@
prop="environment"
:field="item"
:fields-width="fieldsWidth"
:label="'运行环境'"
:label="$t('commons.environment')"
>
</ms-table-column>
@ -162,7 +162,7 @@
prop="createUser"
:field="item"
:fields-width="fieldsWidth"
:label="'创建人'"/>
:label="$t('commons.create_user')"/>
<ms-table-column
sortable="updateTime"
@ -633,10 +633,6 @@ export default {
if (item.status === 'Running') {
isNext = true;
}
this.$get('/api/testcase/get/env/' + item.id, res => {
let environment = res.data ? res.data.name : '-';
this.$set(item, 'environment', environment);
})
});
this.$nextTick(() => {
if (this.$refs.caseTable) {