fix: 模块树简单优化(测试用例,场景测试)

This commit is contained in:
wenyann 2021-05-26 16:12:31 +08:00 committed by 刘瑞斌
parent f05b8052df
commit 6e68f86553
8 changed files with 43 additions and 37 deletions

View File

@ -92,15 +92,11 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
scenarioNodes = this.nodeList(nodes, node.getId(), scenarioNodes);
scenarioNodes.add(node.getId());
request.setModuleIds(scenarioNodes);
int num = this.getCaseNum(request);
node.setCaseNum(num);
node.setCaseNum(extApiScenarioMapper.listModule(request));
});
return getNodeTrees(nodes);
}
private int getCaseNum(ApiScenarioRequest request) {
return extApiScenarioMapper.list(request).size();
}
public static List<String> nodeList(List<ApiScenarioModuleDTO> nodes, String pid, List<String> list) {
for (ApiScenarioModuleDTO node : nodes) {

View File

@ -12,6 +12,9 @@ import java.util.List;
public interface ExtApiScenarioMapper {
List<ApiScenarioDTO> list(@Param("request") ApiScenarioRequest request);
int listModule(@Param("request") ApiScenarioRequest request);
List<ApiScenarioDTO> listReview(@Param("request") ApiScenarioRequest request);
List<ApiScenarioWithBLOBs> selectByTagId(@Param("id") String id);

View File

@ -132,8 +132,13 @@
</if>
</sql>
<select id="listModule" resultType="java.lang.Integer">
select count(id) from api_scenario
<include refid="queryWhereCondition"/>
</select>
<select id="list" resultMap="BaseResultMap">
select api_scenario.id, api_scenario.project_id, api_scenario.tags, api_scenario.user_id, api_scenario.num, api_scenario.custom_num,
select api_scenario.id, api_scenario.project_id, api_scenario.tags, api_scenario.user_id, api_scenario.num,
api_scenario.custom_num,
api_scenario.api_scenario_module_id,api_scenario.module_path, api_scenario.name, api_scenario.level,
api_scenario.status, api_scenario.principal, api_scenario.step_total, api_scenario.follow_people,
api_scenario.last_result,api_scenario.pass_rate,api_scenario.report_id,
@ -165,9 +170,6 @@
<if test="request.workspaceId != null">
AND project.workspace_id = #{request.workspaceId}
</if>
<if test="request.projectId != null">
AND project.id = #{request.projectId}
</if>
<if test="request.id != null">
AND api_scenario.id = #{request.id}
</if>
@ -189,12 +191,17 @@
#{itemId}
</foreach>
</if>
<if test="request.moduleIds != null and request.moduleIds.size() > 0">
AND api_scenario.api_scenario_module_id in
<foreach collection="request.moduleIds" item="nodeId" separator="," open="(" close=")">
#{nodeId}
</foreach>
</if>
<choose>
<when test="request.moduleIds != null and request.moduleIds.size() > 0">
AND api_scenario.api_scenario_module_id in
<foreach collection="request.moduleIds" item="nodeId" separator="," open="(" close=")">
#{nodeId}
</foreach>
</when>
<when test="request.projectId != null">
AND project.id = #{request.projectId}
</when>
</choose>
<if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0">

View File

@ -18,6 +18,8 @@ public interface ExtTestCaseMapper {
List<TestCaseDTO> list(@Param("request") QueryTestCaseRequest request);
int moduleCount(@Param("request") QueryTestCaseRequest request);
List<TestCaseDTO> listIds(@Param("request") QueryTestCaseRequest request);
List<TestCaseDTO> listByMethod(@Param("request") QueryTestCaseRequest request);

View File

@ -172,6 +172,10 @@
<include refid="queryWhereCondition"/>
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/>
</select>
<select id="moduleCount" resultType="java.lang.Integer">
select count(id) from test_case
<include refid="queryWhereCondition"/>
</select>
<select id="listIds" resultType="io.metersphere.track.dto.TestCaseDTO">
select
<if test="request.selectFields != null and request.selectFields.size() > 0">
@ -324,20 +328,23 @@
or test_case.custom_num like CONCAT('%', #{request.name},'%'))
</if>
<if test="request.relevanceCreateTime >0">
and test_case.id in (select test_case_id from test_case_test where test_case_test.create_time >= #{request.createTime})
and test_case.id in (select test_case_id from test_case_test where test_case_test.create_time >=
#{request.createTime})
</if>
<if test="request.createTime >0">
and test_case.create_time >= #{request.createTime}
</if>
<if test="request.nodeIds != null and request.nodeIds.size() > 0">
and test_case.node_id in
<foreach collection="request.nodeIds" item="nodeId" separator="," open="(" close=")">
#{nodeId}
</foreach>
</if>
<if test="request.projectId != null">
and test_case.project_id = #{request.projectId}
</if>
<choose>
<when test="request.nodeIds != null and request.nodeIds.size() > 0">
and test_case.node_id in
<foreach collection="request.nodeIds" item="nodeId" separator="," open="(" close=")">
#{nodeId}
</foreach>
</when>
<when test="request.projectId != null">
and test_case.project_id = #{request.projectId}
</when>
</choose>
<include refid="filters"/>
<if test="request.caseCoverage == 'uncoverage' ">
and test_case.id not in (select distinct test_case_test.test_case_id from test_case_test)

View File

@ -147,8 +147,7 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
nodeIds = this.nodeList(testCaseNodes, node.getId(), nodeIds);
nodeIds.add(node.getId());
request.setNodeIds(nodeIds);
int num = this.getCaseNum(request);
node.setCaseNum(num);
node.setCaseNum(extTestCaseMapper.moduleCount(request));
}
return getNodeTrees(testCaseNodes);
}
@ -162,19 +161,9 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
nodeList(testCaseNodes, node.getId(), list);
}
}
/*if(null==list||list.size()==0){
list.add(pid);
}*/
return list;
}
//获取模块下用例数
public int getCaseNum(QueryTestCaseRequest request) {
List<TestCaseDTO> list = extTestCaseMapper.list(request);
return list.size();
}
public int editNode(DragNodeRequest request) {
request.setUpdateTime(System.currentTimeMillis());
checkTestCaseNodeExist(request);

View File

@ -315,6 +315,7 @@ import MsEditApiScenario from "./scenario/EditApiScenario";
refresh(data) {
this.setTabTitle(data);
this.$refs.apiScenarioList.search(data);
this.$refs.nodeTree.list();
},
refreshAll() {
this.$refs.nodeTree.list();

View File

@ -454,6 +454,7 @@ export default {
},
refresh(data) {
this.$refs.apiList[0].initTable(data);
this.$refs.nodeTree.list();
},
setTabTitle(data) {
for (let index in this.apiTabs) {