fix 首页报错

This commit is contained in:
chenjianxing 2020-05-19 19:53:52 +08:00
parent ef4f372c08
commit 58ace8e0e8
4 changed files with 16 additions and 6 deletions

View File

@ -1,5 +1,6 @@
package io.metersphere.base.mapper.ext;
import io.metersphere.base.domain.Workspace;
import io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest;
import io.metersphere.track.dto.TestCaseReportStatusResultDTO;
import io.metersphere.track.dto.TestPlanCaseDTO;
@ -15,7 +16,7 @@ public interface ExtTestPlanTestCaseMapper {
List<TestPlanCaseDTO> list(@Param("request") QueryTestPlanCaseRequest request);
List<String> findRelateTestPlanId(String userId);
List<String> findRelateTestPlanId(@Param("userId") String userId, @Param("workspaceId") String workspaceId);
List<TestPlanCaseDTO> getRecentTestedTestCase(@Param("request") QueryTestPlanCaseRequest request);

View File

@ -62,7 +62,11 @@
</select>
<select id="findRelateTestPlanId" resultType="java.lang.String">
select distinct plan_id from test_plan_test_case where executor = #{userId}
select distinct plan_id from test_plan_test_case
inner join test_plan
on test_plan_test_case.plan_id = test_plan.id
where test_plan_test_case.executor = #{userId}
and test_plan.workspace_id = #{workspaceId}
</select>
<select id="getRecentTestedTestCase" resultType="io.metersphere.track.dto.TestPlanCaseDTO">
select test_plan_test_case.*, test_case.*

View File

@ -162,7 +162,7 @@ public class TestPlanService {
QueryTestPlanRequest request = new QueryTestPlanRequest();
request.setPrincipal(user.getId());
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
request.setPlanIds(extTestPlanTestCaseMapper.findRelateTestPlanId(user.getId()));
request.setPlanIds(extTestPlanTestCaseMapper.findRelateTestPlanId(user.getId(), SessionUtils.getCurrentWorkspaceId()));
List<String> projectIds = extProjectMapper.getProjectIdByWorkspaceId(SessionUtils.getCurrentOrganizationId());
@ -329,7 +329,7 @@ public class TestPlanService {
}
}
public List<TestPlan> getTestPlanByTestIds(List<String> planIds) {
public List<TestPlan> getTestPlanByIds(List<String> planIds) {
TestPlanExample example = new TestPlanExample();
example.createCriteria().andIdIn(planIds);
return testPlanMapper.selectByExample(example);

View File

@ -80,10 +80,15 @@ public class TestPlanTestCaseService {
if (request.getPlanIds().isEmpty()) {
return new ArrayList<>();
}
List<TestPlanCaseDTO> recentTestedTestCase = extTestPlanTestCaseMapper.getRecentTestedTestCase(request);
List<String> planIds = recentTestedTestCase.stream().map(TestPlanCaseDTO::getPlanId).collect(Collectors.toList());
Map<String, String> testPlanMap = testPlanService.getTestPlanByTestIds(planIds).stream()
if (planIds.isEmpty()) {
return new ArrayList<>();
}
Map<String, String> testPlanMap = testPlanService.getTestPlanByIds(planIds).stream()
.collect(Collectors.toMap(TestPlan::getId, TestPlan::getName));
recentTestedTestCase.forEach(testCase -> {
@ -102,7 +107,7 @@ public class TestPlanTestCaseService {
public void buildQueryRequest(QueryTestPlanCaseRequest request, int count) {
SessionUser user = SessionUtils.getUser();
List<String> relateTestPlanIds = extTestPlanTestCaseMapper.findRelateTestPlanId(user.getId());
List<String> relateTestPlanIds = extTestPlanTestCaseMapper.findRelateTestPlanId(user.getId(), SessionUtils.getCurrentWorkspaceId());
PageHelper.startPage(1, count, true);
request.setPlanIds(relateTestPlanIds);
request.setExecutor(user.getId());