feat(测试计划): 修复条件搜索测试集数量不正确问题

--bug=1042669 --user=王旭 【测试计划】计划详情-功能/接口/场景用例列表-搜索用例-搜索后左侧测试集数量未更新 https://www.tapd.cn/55049933/s/1532646
This commit is contained in:
WangXu10 2024-06-20 11:26:08 +08:00 committed by Craftsman
parent 969e7716ab
commit 9db8404d1c
9 changed files with 24 additions and 18 deletions

View File

@ -9,6 +9,7 @@ import io.metersphere.plan.dto.ApiCaseModuleDTO;
import io.metersphere.plan.dto.ResourceSelectParam;
import io.metersphere.plan.dto.TestPlanCaseRunResultCount;
import io.metersphere.plan.dto.request.TestPlanApiCaseBatchRequest;
import io.metersphere.plan.dto.request.TestPlanApiCaseModuleRequest;
import io.metersphere.plan.dto.request.TestPlanApiCaseRequest;
import io.metersphere.plan.dto.request.TestPlanApiRequest;
import io.metersphere.plan.dto.response.TestPlanApiCasePageResponse;
@ -55,7 +56,7 @@ public interface ExtTestPlanApiCaseMapper {
void batchUpdateExecutor(@Param("ids") List<String> ids, @Param("userId") String userId);
List<ModuleCountDTO> collectionCountByRequest(@Param("testPlanId") String testPlanId);
List<ModuleCountDTO> collectionCountByRequest(@Param("request") TestPlanApiCaseModuleRequest request);
Long getMaxPosByCollectionId(String collectionId);

View File

@ -641,18 +641,20 @@
</foreach>
</update>
<select id="collectionCountByRequest" parameterType="java.lang.String" resultType="io.metersphere.project.dto.ModuleCountDTO">
<select id="collectionCountByRequest" resultType="io.metersphere.project.dto.ModuleCountDTO">
SELECT
test_plan_api_case.test_plan_collection_id AS moduleId,
count( test_plan_api_case.id ) AS dataCount
t.test_plan_collection_id AS moduleId,
count( t.id ) AS dataCount
FROM
api_test_case
INNER JOIN test_plan_api_case ON api_test_case.id = test_plan_api_case.api_case_id
api_test_case atc
INNER JOIN test_plan_api_case t ON atc.id = t.api_case_id
INNER JOIN api_definition a on atc.api_definition_id = a.id
WHERE
api_test_case.deleted = FALSE
AND test_plan_api_case.test_plan_id = #{testPlanId}
atc.deleted = FALSE
AND t.test_plan_id = #{request.testPlanId}
<include refid="queryApiCaseWhereCondition"/>
GROUP BY
test_plan_api_case.test_plan_collection_id
t.test_plan_collection_id
</select>
<select id="getMaxPosByCollectionId" resultType="java.lang.Long">

View File

@ -44,7 +44,7 @@ public interface ExtTestPlanApiScenarioMapper {
List<String> selectIdByProjectIdAndTestPlanId(@Param("projectId") String projectId, @Param("testPlanId") String testPlanId);
List<ModuleCountDTO> collectionCountByRequest(@Param("testPlanId") String testPlanId);
List<ModuleCountDTO> collectionCountByRequest(@Param("request") TestPlanApiScenarioModuleRequest request);
List<ProjectOptionDTO> selectRootIdByTestPlanId(@Param("testPlanId") String testPlanId);

View File

@ -351,7 +351,7 @@
)
</select>
<select id="collectionCountByRequest" parameterType="java.lang.String" resultType="io.metersphere.project.dto.ModuleCountDTO">
<select id="collectionCountByRequest" resultType="io.metersphere.project.dto.ModuleCountDTO">
SELECT
test_plan_api_scenario.test_plan_collection_id AS moduleId,
count( test_plan_api_scenario.id ) AS dataCount
@ -360,7 +360,8 @@
INNER JOIN test_plan_api_scenario on api_scenario.id = test_plan_api_scenario.api_scenario_id
WHERE
api_scenario.deleted = FALSE
AND test_plan_api_scenario.test_plan_id = #{testPlanId}
AND test_plan_api_scenario.test_plan_id = #{request.testPlanId}
<include refid="queryApiScenarioWhereCondition"/>
GROUP BY
test_plan_api_scenario.test_plan_collection_id
</select>

View File

@ -7,6 +7,7 @@ import io.metersphere.plan.domain.TestPlanFunctionalCase;
import io.metersphere.plan.dto.ResourceSelectParam;
import io.metersphere.plan.dto.TestPlanCaseRunResultCount;
import io.metersphere.plan.dto.request.BasePlanCaseBatchRequest;
import io.metersphere.plan.dto.request.TestPlanCaseModuleRequest;
import io.metersphere.plan.dto.request.TestPlanCaseRequest;
import io.metersphere.plan.dto.response.TestPlanCasePageResponse;
import io.metersphere.project.dto.DropNode;
@ -62,5 +63,5 @@ public interface ExtTestPlanFunctionalCaseMapper {
Long getMaxPosByCollectionId(String collectionId);
List<ModuleCountDTO> collectionCountByRequest(@Param("testPlanId") String testPlanId);
List<ModuleCountDTO> collectionCountByRequest(@Param("request") TestPlanCaseModuleRequest request);
}

View File

@ -541,7 +541,7 @@
WHERE test_plan_collection_id = #{0}
</select>
<select id="collectionCountByRequest" parameterType="java.lang.String" resultType="io.metersphere.project.dto.ModuleCountDTO">
<select id="collectionCountByRequest" resultType="io.metersphere.project.dto.ModuleCountDTO">
SELECT
test_plan_functional_case.test_plan_collection_id AS moduleId,
count( test_plan_functional_case.id ) AS dataCount
@ -550,7 +550,8 @@
INNER JOIN test_plan_functional_case ON functional_case.id = test_plan_functional_case.functional_case_id
WHERE
functional_case.deleted = FALSE
AND test_plan_functional_case.test_plan_id = #{testPlanId}
AND test_plan_functional_case.test_plan_id = #{request.testPlanId}
<include refid="queryWhereCondition"/>
GROUP BY
test_plan_functional_case.test_plan_collection_id
</select>

View File

@ -344,7 +344,7 @@ public class TestPlanApiCaseService extends TestPlanResourceService {
private Map<String, Long> getCollectionCount(TestPlanApiCaseModuleRequest request) {
request.setCollectionId(null);
Map<String, Long> projectModuleCountMap = new HashMap<>();
List<ModuleCountDTO> list = extTestPlanApiCaseMapper.collectionCountByRequest(request.getTestPlanId());
List<ModuleCountDTO> list = extTestPlanApiCaseMapper.collectionCountByRequest(request);
list.forEach(item -> {
projectModuleCountMap.put(item.getModuleId(), (long) item.getDataCount());
});

View File

@ -478,7 +478,7 @@ public class TestPlanApiScenarioService extends TestPlanResourceService {
private Map<String, Long> getCollectionCount(TestPlanApiScenarioModuleRequest request) {
request.setCollectionId(null);
Map<String, Long> projectModuleCountMap = new HashMap<>();
List<ModuleCountDTO> list = extTestPlanApiScenarioMapper.collectionCountByRequest(request.getTestPlanId());
List<ModuleCountDTO> list = extTestPlanApiScenarioMapper.collectionCountByRequest(request);
list.forEach(item -> {
projectModuleCountMap.put(item.getModuleId(), (long) item.getDataCount());
});

View File

@ -371,7 +371,7 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
private Map<String, Long> getCollectionCount(TestPlanCaseModuleRequest request) {
request.setCollectionId(null);
Map<String, Long> projectModuleCountMap = new HashMap<>();
List<ModuleCountDTO> list = extTestPlanFunctionalCaseMapper.collectionCountByRequest(request.getTestPlanId());
List<ModuleCountDTO> list = extTestPlanFunctionalCaseMapper.collectionCountByRequest(request);
list.forEach(item -> {
projectModuleCountMap.put(item.getModuleId(), (long) item.getDataCount());
});