fix(高级查询): 修复部分高级查询报错的bug

This commit is contained in:
q4speed 2020-07-23 10:20:40 +08:00
parent 78ccfcd99b
commit b316344788
4 changed files with 24 additions and 37 deletions

View File

@ -137,20 +137,15 @@
<select id="list" resultType="io.metersphere.track.dto.TestCaseDTO"> <select id="list" resultType="io.metersphere.track.dto.TestCaseDTO">
select test_case.* from test_case select test_case.* from test_case
<where> <where>
<choose> <if test="request.combine != null">
<!--高级-->
<when test="request.combine != null">
<include refid="combine"> <include refid="combine">
<property name="condition" value="request.combine"/> <property name="condition" value="request.combine"/>
<property name="name" value="request.name"/>
</include> </include>
</when> </if>
<!--普通-->
<otherwise>
<if test="request.name != null"> <if test="request.name != null">
and test_case.name like CONCAT('%', #{request.name},'%') and test_case.name like CONCAT('%', #{request.name},'%')
</if> </if>
</otherwise>
</choose>
<if test="request.nodeIds != null and request.nodeIds.size() > 0"> <if test="request.nodeIds != null and request.nodeIds.size() > 0">
and test_case.node_id in and test_case.node_id in
<foreach collection="request.nodeIds" item="nodeId" separator="," open="(" close=")"> <foreach collection="request.nodeIds" item="nodeId" separator="," open="(" close=")">

View File

@ -1,9 +1,8 @@
package io.metersphere.base.mapper.ext; 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.TestCaseReportStatusResultDTO;
import io.metersphere.track.dto.TestPlanCaseDTO; import io.metersphere.track.dto.TestPlanCaseDTO;
import io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;

View File

@ -46,7 +46,7 @@
</sql> </sql>
<sql id="combine"> <sql id="combine">
<if test="${condition}.name != null"> <if test='${condition}.name != null and (${name} == null or ${name} == "")'>
and test_case.name and test_case.name
<include refid="condition"> <include refid="condition">
<property name="object" value="${condition}.name"/> <property name="object" value="${condition}.name"/>
@ -119,20 +119,15 @@
from test_plan_test_case from test_plan_test_case
inner join test_case on test_plan_test_case.case_id = test_case.id inner join test_case on test_plan_test_case.case_id = test_case.id
<where> <where>
<choose> <if test="request.combine != null">
<!--高级-->
<when test="request.combine != null">
<include refid="combine"> <include refid="combine">
<property name="condition" value="request.combine"/> <property name="condition" value="request.combine"/>
<property name="name" value="request.name"/>
</include> </include>
</when> </if>
<!--普通-->
<otherwise>
<if test="request.name != null"> <if test="request.name != null">
and test_case.name like CONCAT('%', #{request.name},'%') and test_case.name like CONCAT('%', #{request.name},'%')
</if> </if>
</otherwise>
</choose>
<if test="request.id != null"> <if test="request.id != null">
and test_case.id = #{request.id} and test_case.id = #{request.id}
</if> </if>

View File

@ -266,19 +266,17 @@
this.isTestManagerOrTestUser = checkoutTestManagerOrTestUser(); this.isTestManagerOrTestUser = checkoutTestManagerOrTestUser();
}, },
methods: { methods: {
initTableData(combine) { initTableData() {
// combine
let condition = combine ? {combine: combine} : this.condition;
if (this.planId) { if (this.planId) {
// param.planId = this.planId; // param.planId = this.planId;
condition.planId = this.planId; this.condition.planId = this.planId;
} }
if (this.selectNodeIds && this.selectNodeIds.length > 0) { if (this.selectNodeIds && this.selectNodeIds.length > 0) {
// param.nodeIds = this.selectNodeIds; // param.nodeIds = this.selectNodeIds;
condition.nodeIds = this.selectNodeIds; this.condition.nodeIds = this.selectNodeIds;
} }
if (this.planId) { if (this.planId) {
this.result = this.$post(this.buildPagePath('/test/plan/case/list'), condition, response => { this.result = this.$post(this.buildPagePath('/test/plan/case/list'), this.condition, response => {
let data = response.data; let data = response.data;
this.total = data.itemCount; this.total = data.itemCount;
this.tableData = data.listObject; this.tableData = data.listObject;