fix(测试计划): 修复关联接口用例列表展示错误的问题

This commit is contained in:
shiziyuan9527 2021-03-20 11:02:15 +08:00
parent 78506f814f
commit e740d55ac8
2 changed files with 11 additions and 6 deletions

View File

@ -33,9 +33,7 @@ public class TestPlanApiCaseController {
@PostMapping("/relevance/list/{goPage}/{pageSize}") @PostMapping("/relevance/list/{goPage}/{pageSize}")
public Pager<List<ApiTestCaseDTO>> relevanceList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiTestCaseRequest request) { public Pager<List<ApiTestCaseDTO>> relevanceList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiTestCaseRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true); return testPlanApiCaseService.relevanceList(goPage, pageSize, request);
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
return PageUtils.setPageInfo(page, testPlanApiCaseService.relevanceList(request));
} }
@GetMapping("/delete/{id}") @GetMapping("/delete/{id}")

View File

@ -2,6 +2,8 @@ package io.metersphere.track.service;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.api.dto.definition.ApiTestCaseDTO; import io.metersphere.api.dto.definition.ApiTestCaseDTO;
import io.metersphere.api.dto.definition.ApiTestCaseRequest; import io.metersphere.api.dto.definition.ApiTestCaseRequest;
import io.metersphere.api.dto.definition.RunDefinitionRequest; import io.metersphere.api.dto.definition.RunDefinitionRequest;
@ -18,7 +20,10 @@ import io.metersphere.base.domain.TestPlanApiCase;
import io.metersphere.base.domain.TestPlanApiCaseExample; import io.metersphere.base.domain.TestPlanApiCaseExample;
import io.metersphere.base.mapper.TestPlanApiCaseMapper; import io.metersphere.base.mapper.TestPlanApiCaseMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanApiCaseMapper; import io.metersphere.base.mapper.ext.ExtTestPlanApiCaseMapper;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.commons.utils.ServiceUtils; import io.metersphere.commons.utils.ServiceUtils;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.track.request.testcase.TestPlanApiCaseBatchRequest; import io.metersphere.track.request.testcase.TestPlanApiCaseBatchRequest;
import org.apache.jmeter.testelement.TestElement; import org.apache.jmeter.testelement.TestElement;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
@ -61,13 +66,15 @@ public class TestPlanApiCaseService {
return extTestPlanApiCaseMapper.getExecResultByPlanId(plan); return extTestPlanApiCaseMapper.getExecResultByPlanId(plan);
} }
public List<ApiTestCaseDTO> relevanceList(ApiTestCaseRequest request) { public Pager<List<ApiTestCaseDTO>> relevanceList(int goPage, int pageSize, ApiTestCaseRequest request) {
List<String> ids = apiTestCaseService.selectIdsNotExistsInPlan(request.getProjectId(), request.getPlanId()); List<String> ids = apiTestCaseService.selectIdsNotExistsInPlan(request.getProjectId(), request.getPlanId());
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
if (CollectionUtils.isEmpty(ids)) { if (CollectionUtils.isEmpty(ids)) {
return new ArrayList<>(); return PageUtils.setPageInfo(page, new ArrayList<>());
} }
request.setIds(ids); request.setIds(ids);
return apiTestCaseService.listSimple(request); request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
return PageUtils.setPageInfo(page, apiTestCaseService.listSimple(request));
} }
public int delete(String id) { public int delete(String id) {