fix(测试跟踪): 修复最近测试计划查询问题

This commit is contained in:
shiziyuan9527 2021-01-25 18:37:56 +08:00
parent df783efd09
commit 9990aa90b9
4 changed files with 17 additions and 22 deletions

View File

@ -1,5 +1,6 @@
package io.metersphere.base.mapper.ext;
import io.metersphere.base.domain.TestPlan;
import io.metersphere.track.dto.TestPlanDTO;
import io.metersphere.track.dto.TestPlanDTOWithMetric;
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
@ -32,4 +33,6 @@ public interface ExtTestPlanMapper {
String findScheduleCreateUserById(String testPlanId);
List<String> findIdByPerformanceReportId(String reportId);
List<TestPlan> listRecent(@Param("userId") String userId, @Param("projectId") String currentProjectId);
}

View File

@ -240,5 +240,16 @@
WHERE reportData.performance_info like CONCAT('%', #{0},'%')
AND report.is_performance_executing = true;
</select>
<select id="listRecent" resultType="io.metersphere.base.domain.TestPlan">
select distinct test_plan.*
from test_plan
<where>
<if test="projectId != null">
and test_plan.project_id = #{projectId}
</if>
and (test_plan.creator = #{userId} or test_plan.principal = #{userId})
</where>
order by test_plan.update_time desc
</select>
</mapper>

View File

@ -66,9 +66,8 @@ public class TestPlanController {
@GetMapping("recent/{count}")
public List<TestPlan> recentTestPlans(@PathVariable int count) {
String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId();
PageHelper.startPage(1, count, true);
return testPlanService.recentTestPlans(currentWorkspaceId);
return testPlanService.recentTestPlans();
}
@PostMapping("/get/{testPlanId}")

View File

@ -467,26 +467,8 @@ public class TestPlanService {
}
}
public List<TestPlan> recentTestPlans(String currentWorkspaceId) {
if (StringUtils.isBlank(currentWorkspaceId)) {
return null;
}
if (StringUtils.isNotBlank(SessionUtils.getCurrentProjectId())) {
TestPlanExample testPlanExample = new TestPlanExample();
TestPlanExample.Criteria criteria = testPlanExample.createCriteria();
criteria.andProjectIdEqualTo(SessionUtils.getCurrentProjectId());
List<TestPlan> testPlans = testPlanMapper.selectByExample(testPlanExample);
if (!CollectionUtils.isEmpty(testPlans)) {
List<String> testPlanIds = testPlans.stream().map(TestPlan::getId).collect(Collectors.toList());
TestPlanExample testPlanTestCaseExample = new TestPlanExample();
testPlanTestCaseExample.createCriteria().andWorkspaceIdEqualTo(currentWorkspaceId)
.andIdIn(testPlanIds)
.andPrincipalEqualTo(SessionUtils.getUserId());
testPlanTestCaseExample.setOrderByClause("update_time desc");
return testPlanMapper.selectByExample(testPlanTestCaseExample);
}
}
return new ArrayList<>();
public List<TestPlan> recentTestPlans() {
return extTestPlanMapper.listRecent(SessionUtils.getUserId(), SessionUtils.getCurrentProjectId());
}
public List<TestPlan> listTestAllPlan(String currentWorkspaceId) {