refactor(测试计划): 优化高级搜索部分字段SQL查询
--task=1016645 --user=宋昌昌 【接口测试】接口文档-后端 https://www.tapd.cn/55049933/s/1591755
This commit is contained in:
parent
5bcc5caa5d
commit
b5eb31f348
|
@ -5,10 +5,12 @@ import com.github.pagehelper.PageHelper;
|
|||
import io.metersphere.api.domain.ApiDocShare;
|
||||
import io.metersphere.api.dto.definition.ApiDocShareDTO;
|
||||
import io.metersphere.api.dto.definition.ApiDocShareDetail;
|
||||
import io.metersphere.api.dto.definition.ApiModuleRequest;
|
||||
import io.metersphere.api.dto.definition.request.ApiDocShareCheckRequest;
|
||||
import io.metersphere.api.dto.definition.request.ApiDocShareEditRequest;
|
||||
import io.metersphere.api.dto.definition.request.ApiDocShareModuleRequest;
|
||||
import io.metersphere.api.dto.definition.request.ApiDocSharePageRequest;
|
||||
import io.metersphere.api.service.definition.ApiDefinitionModuleService;
|
||||
import io.metersphere.api.service.definition.ApiDocShareLogService;
|
||||
import io.metersphere.api.service.definition.ApiDocShareService;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
|
@ -44,6 +46,8 @@ public class ApiDocShareController {
|
|||
|
||||
@Resource
|
||||
private ApiDocShareService apiDocShareService;
|
||||
@Resource
|
||||
private ApiDefinitionModuleService apiDefinitionModuleService;
|
||||
|
||||
@PostMapping(value = "/page")
|
||||
@Operation(summary = "接口测试-接口管理-接口定义-分页获取分享列表")
|
||||
|
@ -98,8 +102,8 @@ public class ApiDocShareController {
|
|||
|
||||
@PostMapping("/module/tree")
|
||||
@Operation(summary = "接口测试-接口管理-接口定义-模块树")
|
||||
public List<BaseTreeNode> getShareDocTree(@Validated @RequestBody ApiDocShareModuleRequest request) {
|
||||
return apiDocShareService.getShareTree(request);
|
||||
public List<BaseTreeNode> getShareDocTree(@Validated @RequestBody ApiModuleRequest request) {
|
||||
return apiDefinitionModuleService.getTree(request, false, true);
|
||||
}
|
||||
|
||||
@PostMapping("/module/count")
|
||||
|
|
|
@ -192,6 +192,13 @@
|
|||
<property name="condition" value="condition"/>
|
||||
<property name="tablePrefix" value="m"/>
|
||||
</include>
|
||||
<!-- ID -->
|
||||
<if test="condition.name == 'expectNum'">
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="m.expect_num"/>
|
||||
</include>
|
||||
</if>
|
||||
<!-- 协议 -->
|
||||
<if test="condition.name == 'protocol'">
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
|
@ -200,14 +207,14 @@
|
|||
</include>
|
||||
</if>
|
||||
<!-- 请求类型 -->
|
||||
<if test="condition.name == 'method'">
|
||||
<if test="condition.name == 'apiMethod'">
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="d.method"/>
|
||||
</include>
|
||||
</if>
|
||||
<!-- 状态 -->
|
||||
<if test="condition.name == 'status'">
|
||||
<if test="condition.name == 'enable'">
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="m.enable"/>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<select id="list" resultType="io.metersphere.api.dto.definition.ApiDocShareDTO">
|
||||
select id, name, is_private isPrivate, create_user createUser, create_time createTime,
|
||||
api_range apiRange, range_match_symbol rangeMatchSymbol, range_match_val rangeMatchVal,
|
||||
invalid_time invalidTime, invalid_unit invalidUnit, project_id projectId
|
||||
invalid_time invalidTime, invalid_unit invalidUnit, project_id projectId, password
|
||||
from api_doc_share
|
||||
<include refid="queryWhereCondition"/>
|
||||
</select>
|
||||
|
|
|
@ -340,7 +340,7 @@
|
|||
</include>
|
||||
</if>
|
||||
<!-- 执行结果 -->
|
||||
<if test="condition.name == 'lastExecuteResult'">
|
||||
<if test="condition.name == 'lastReportStatus'">
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="api_scenario.last_report_status"/>
|
||||
|
@ -354,24 +354,27 @@
|
|||
</include>
|
||||
</if>
|
||||
<!-- 通过率 -->
|
||||
<if test="condition.name == 'passRate'">
|
||||
<if test="condition.name == 'requestPassRate'">
|
||||
<choose>
|
||||
<when test="condition.operator == 'NOT_EMPTY'">
|
||||
api_scenario.request_pass_rate is not null and api_scenario.request_pass_rate != '' and api_scenario.request_pass_rate != 'Calculating'
|
||||
</when>
|
||||
<when test="condition.operator == 'EMPTY'">
|
||||
api_scenario.request_pass_rate is null or api_scenario.request_pass_rate == '' or api_scenario.request_pass_rate == 'Calculating'
|
||||
api_scenario.request_pass_rate is null or api_scenario.request_pass_rate = '' or api_scenario.request_pass_rate = 'Calculating'
|
||||
</when>
|
||||
<when test="(condition.operator == 'LT' and condition.value == 0) or (condition.operator == 'GT' and condition.value > 100 )">
|
||||
1=2
|
||||
</when>
|
||||
<otherwise>
|
||||
api_scenario.request_pass_rate ${condition.operator} #{condition.value}
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="api_scenario.request_pass_rate"/>
|
||||
</include>
|
||||
</otherwise>
|
||||
</choose>
|
||||
</if>
|
||||
<!-- 环境 -->
|
||||
<if test="condition.name == 'env'">
|
||||
<if test="condition.name == 'environmentName'">
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="api_scenario.environment_id"/>
|
||||
|
|
|
@ -658,26 +658,28 @@
|
|||
</when>
|
||||
<otherwise>
|
||||
atc.id in (
|
||||
select atcr.api_test_case_id as id, format(sum(if(ar.`status` = 'success', 1, 0)) / count(ar.id) * 100, 2) as passRate
|
||||
from api_report ar left join api_test_case_record atcr on atcr.api_report_id = ar.id
|
||||
group by atcr.api_test_case_id having
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="passRate"/>
|
||||
</include>
|
||||
select rate_tmp.id from (
|
||||
select atcr.api_test_case_id as id, format(sum(if(ar.`status` = 'success', 1, 0)) / count(ar.id) * 100, 2) as passRate
|
||||
from api_report ar left join api_test_case_record atcr on atcr.api_report_id = ar.id
|
||||
group by atcr.api_test_case_id having
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="passRate"/>
|
||||
</include>
|
||||
) rate_tmp
|
||||
)
|
||||
</otherwise>
|
||||
</choose>
|
||||
</if>
|
||||
<!-- 用例环境 -->
|
||||
<if test="condition.name == 'env'">
|
||||
<if test="condition.name == 'environmentName'">
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="atc.environment_id"/>
|
||||
</include>
|
||||
</if>
|
||||
<!-- 执行结果 -->
|
||||
<if test="condition.name == 'lastExecuteResult'">
|
||||
<if test="condition.name == 'lastReportStatus'">
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="atc.last_report_status"/>
|
||||
|
|
|
@ -16,7 +16,6 @@ import io.metersphere.sdk.dto.CombineSearch;
|
|||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.dto.sdk.BaseTreeNode;
|
||||
import io.metersphere.system.uid.IDGenerator;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@ -124,16 +123,6 @@ public class ApiDocShareService {
|
|||
return detail;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分享左侧模块树
|
||||
* @param request 请求参数
|
||||
* @return 模块树
|
||||
*/
|
||||
public List<BaseTreeNode> getShareTree(ApiDocShareModuleRequest request) {
|
||||
ApiDocShare docShare = checkExit(request.getShareId());
|
||||
return apiDefinitionModuleService.getTree(buildModuleParam(request, docShare), false, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分享左侧模块树节点数量
|
||||
* @param request 请求参数
|
||||
|
@ -167,7 +156,14 @@ public class ApiDocShareService {
|
|||
StringBuilder condition = new StringBuilder();
|
||||
if (!StringUtils.equals(docShare.getApiRange(), RANGE_ALL) && !StringUtils.isBlank(docShare.getRangeMatchVal())) {
|
||||
switch (docShare.getApiRange()) {
|
||||
case "MODULE" -> condition.append("module_id = '").append(docShare.getRangeMatchVal()).append("'");
|
||||
case "MODULE" -> {
|
||||
String[] moduleIds = StringUtils.split(docShare.getRangeMatchVal(), ",");
|
||||
condition.append("module_id in (");
|
||||
for (String moduleId : moduleIds) {
|
||||
condition.append("\"").append(moduleId).append("\", ");
|
||||
}
|
||||
condition.replace(condition.lastIndexOf(","), condition.length() - 1, ")");
|
||||
}
|
||||
case "PATH" -> {
|
||||
if (StringUtils.equals(docShare.getRangeMatchSymbol(), MsAssertionCondition.EQUALS.name())) {
|
||||
condition.append("path = '").append(docShare.getRangeMatchVal()).append("'");
|
||||
|
@ -201,7 +197,11 @@ public class ApiDocShareService {
|
|||
if (!StringUtils.equals(docShare.getApiRange(), RANGE_ALL) && !StringUtils.isBlank(docShare.getRangeMatchVal())) {
|
||||
CombineSearch combineSearch = new CombineSearch();
|
||||
switch (docShare.getApiRange()) {
|
||||
case "MODULE" -> request.setModuleIds(List.of(docShare.getRangeMatchVal()));
|
||||
case "MODULE" -> {
|
||||
String[] moduleIds = StringUtils.split(docShare.getRangeMatchVal(), ",");
|
||||
CombineCondition condition = buildModuleCondition("moduleId", Arrays.asList(moduleIds), "IN");
|
||||
combineSearch.setConditions(List.of(condition));
|
||||
}
|
||||
case "PATH" -> {
|
||||
if (StringUtils.equals(docShare.getRangeMatchSymbol(), MsAssertionCondition.EQUALS.name())) {
|
||||
CombineCondition condition = buildModuleCondition("path", docShare.getRangeMatchVal(), MsAssertionCondition.EQUALS.name());
|
||||
|
|
|
@ -252,6 +252,13 @@
|
|||
<property name="condition" value="condition"/>
|
||||
<property name="tablePrefix" value="b"/>
|
||||
</include>
|
||||
<!-- 标题 -->
|
||||
<if test="condition.name == 'title'">
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="b.title"/>
|
||||
</include>
|
||||
</if>
|
||||
<!-- 状态 -->
|
||||
<if test="condition.name == 'status'">
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
|
@ -274,7 +281,7 @@
|
|||
</include>
|
||||
</if>
|
||||
<!-- 用例数 -->
|
||||
<if test="condition.name == 'caseTotal'">
|
||||
<if test="condition.name == 'relationCaseCount'">
|
||||
<choose>
|
||||
<when test="condition.operator == 'NOT_EMPTY'">
|
||||
b.id in (
|
||||
|
@ -304,7 +311,7 @@
|
|||
<if test="(condition.operator == 'EQUALS' and condition.value > 0) or (condition.operator == 'LT' and condition.value > 1) or condition.operator == 'GT'">
|
||||
b.id in (
|
||||
select distinct b.id from bug b join bug_relation_case brc on b.id = brc.bug_id
|
||||
where deleted = ${deleted} and project_id = '${projectId}' group b.id having
|
||||
where b.deleted = ${deleted} and b.project_id = '${projectId}' group by b.id having
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="count(b.id)"/>
|
||||
|
@ -319,7 +326,7 @@
|
|||
</include>
|
||||
</foreach>
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.customFiledConditions">
|
||||
<property name="mainIdColumn" value="bug.id"/>
|
||||
<property name="mainIdColumn" value="b.id"/>
|
||||
<property name="associationTable" value="bug_custom_field"/>
|
||||
<property name="associationIdColumn" value="bug_id"/>
|
||||
<property name="combineSearch" value="${combineSearch}"/>
|
||||
|
@ -335,11 +342,16 @@
|
|||
</if>
|
||||
<if test="request.keyword != null and request.keyword != ''">
|
||||
and (
|
||||
b.title like concat('%', #{request.keyword},'%')
|
||||
or b.num like concat('%', #{request.keyword},'%')
|
||||
or b.tags like concat('%', #{request.keyword},'%')
|
||||
b.title like concat('%', #{request.keyword},'%')
|
||||
or b.num like concat('%', #{request.keyword},'%')
|
||||
or b.tags like concat('%', #{request.keyword},'%')
|
||||
)
|
||||
</if>
|
||||
<include refid="combine">
|
||||
<property name="combineSearch" value="request.combineSearch"/>
|
||||
<property name="projectId" value="${request.projectId}"/>
|
||||
<property name="deleted" value="${request.useTrash}"/>
|
||||
</include>
|
||||
</sql>
|
||||
</mapper>
|
||||
|
||||
|
|
|
@ -45,6 +45,8 @@ public enum UserViewType implements ValueEnum {
|
|||
*/
|
||||
PLAN_FUNCTIONAL_CASE_DRAWER("plan-functional-case-drawer",
|
||||
List.of(InternalUserView.ALL_DATA, InternalUserView.MY_CREATE)),
|
||||
PLAN_API_DEFINITION_DRAWER("plan-api-definition-drawer",
|
||||
List.of(InternalUserView.ALL_DATA, InternalUserView.MY_CREATE)),
|
||||
PLAN_API_CASE_DRAWER("plan-api-case-drawer",
|
||||
List.of(InternalUserView.ALL_DATA, InternalUserView.MY_CREATE)),
|
||||
PLAN_API_SCENARIO_DRAWER("plan-api-scenario-drawer",
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
<if test="condition.name == 'createUser'">
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="${tablePrefix}.create_User"/>
|
||||
<property name="column" value="${tablePrefix}.create_user"/>
|
||||
</include>
|
||||
</if>
|
||||
<if test="condition.name == 'updateUser'">
|
||||
|
|
|
@ -302,6 +302,7 @@
|
|||
|
||||
<include refid="combine">
|
||||
<property name="combineSearch" value="request.combineSearch"/>
|
||||
<property name="planId" value="${request.testPlanId}"/>
|
||||
</include>
|
||||
|
||||
<include refid="queryApiCaseVersionCondition">
|
||||
|
@ -402,6 +403,20 @@
|
|||
<property name="condition" value="condition"/>
|
||||
<property name="tablePrefix" value="atc"/>
|
||||
</include>
|
||||
<!-- 测试点 -->
|
||||
<if test="condition.name == 'testPlanCollectionId'">
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="test_plan_collection.id"/>
|
||||
</include>
|
||||
</if>
|
||||
<!-- 所属项目 -->
|
||||
<if test="condition.name == 'projectName'">
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="atc.project_id"/>
|
||||
</include>
|
||||
</if>
|
||||
<!-- 协议 -->
|
||||
<if test="condition.name == 'protocol'">
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
|
@ -435,16 +450,16 @@
|
|||
<choose>
|
||||
<when test="condition.operator == 'NOT_EMPTY'">
|
||||
atc.id in (
|
||||
select atcr.api_test_case_id as id
|
||||
from api_report ar left join api_test_case_record atcr on atcr.api_report_id = ar.id
|
||||
group by atcr.api_test_case_id
|
||||
select atcr.api_test_case_id as id
|
||||
from api_report ar left join api_test_case_record atcr on atcr.api_report_id = ar.id
|
||||
group by atcr.api_test_case_id
|
||||
)
|
||||
</when>
|
||||
<when test="condition.operator == 'EMPTY'">
|
||||
atc.id not in (
|
||||
select atcr.api_test_case_id as id
|
||||
from api_report ar left join api_test_case_record atcr on atcr.api_report_id = ar.id
|
||||
group by atcr.api_test_case_id
|
||||
select atcr.api_test_case_id as id
|
||||
from api_report ar left join api_test_case_record atcr on atcr.api_report_id = ar.id
|
||||
group by atcr.api_test_case_id
|
||||
)
|
||||
</when>
|
||||
<when test="(condition.operator == 'LT' and condition.value == 0) or (condition.operator == 'GT' and condition.value > 100 )">
|
||||
|
@ -452,19 +467,21 @@
|
|||
</when>
|
||||
<otherwise>
|
||||
atc.id in (
|
||||
select atcr.api_test_case_id as id, format(sum(if(ar.`status` = 'success', 1, 0)) / count(ar.id) * 100, 2) as passRate
|
||||
from api_report ar left join api_test_case_record atcr on atcr.api_report_id = ar.id
|
||||
group by atcr.api_test_case_id having
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="passRate"/>
|
||||
</include>
|
||||
select rate_tmp.id from (
|
||||
select atcr.api_test_case_id as id, format(sum(if(ar.`status` = 'success', 1, 0)) / count(ar.id) * 100, 2) as passRate
|
||||
from api_report ar left join api_test_case_record atcr on atcr.api_report_id = ar.id
|
||||
group by atcr.api_test_case_id having
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="passRate"/>
|
||||
</include>
|
||||
) rate_tmp
|
||||
)
|
||||
</otherwise>
|
||||
</choose>
|
||||
</if>
|
||||
<!-- 用例环境 -->
|
||||
<if test="condition.name == 'env'">
|
||||
<if test="condition.name == 'environmentName'">
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="atc.environment_id"/>
|
||||
|
@ -478,12 +495,53 @@
|
|||
</include>
|
||||
</if>
|
||||
<!-- 执行结果 -->
|
||||
<if test="condition.name == 'lastExecuteResult'">
|
||||
<if test="condition.name == 'lastExecResult'">
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="t.last_exec_result"/>
|
||||
</include>
|
||||
</if>
|
||||
<!-- 缺陷数 -->
|
||||
<if test="condition.name == 'bugCount'">
|
||||
<choose>
|
||||
<when test="condition.operator == 'NOT_EMPTY'">
|
||||
t.id in (
|
||||
select distinct brc.test_plan_case_id from bug_relation_case brc join bug b on brc.bug_id = b.id
|
||||
where b.deleted = false and brc.test_plan_id = '${planId}' and brc.case_type = 'API'
|
||||
)
|
||||
</when>
|
||||
<when test="condition.operator == 'EMPTY'">
|
||||
t.id not in (
|
||||
select distinct brc.test_plan_case_id from bug_relation_case brc join bug b on brc.bug_id = b.id
|
||||
where b.deleted = false and brc.test_plan_id = '${planId}' and brc.case_type = 'API'
|
||||
)
|
||||
</when>
|
||||
<when test="(condition.operator == 'LT' and condition.value < 1) or (condition.operator == 'EQUALS' and condition.value < 0)">
|
||||
1=2
|
||||
</when>
|
||||
<otherwise>
|
||||
<if test="condition.operator == 'LT' or (condition.operator == 'EQUALS' and condition.value == 0)">
|
||||
t.id not in (
|
||||
select distinct brc.test_plan_case_id from bug_relation_case brc join bug b on brc.bug_id = b.id
|
||||
where b.deleted = false and brc.test_plan_id = '${planId}' and brc.case_type = 'API'
|
||||
)
|
||||
<if test="condition.value > 1">
|
||||
OR
|
||||
</if>
|
||||
</if>
|
||||
<if test="(condition.operator == 'EQUALS' and condition.value > 0) or (condition.operator == 'LT' and condition.value > 1) or condition.operator == 'GT'">
|
||||
t.id in (
|
||||
select brc.test_plan_case_id from bug_relation_case brc join bug b on brc.bug_id = b.id
|
||||
where b.deleted = false and brc.test_plan_id = '${planId}' and brc.case_type = 'API' group by brc.test_plan_case_id having
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="count(brc.id)"/>
|
||||
</include>
|
||||
)
|
||||
</if>
|
||||
</otherwise>
|
||||
</choose>
|
||||
</if>
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.queryType">
|
||||
<property name="searchMode" value="${combineSearch}.searchMode"/>
|
||||
</include>
|
||||
|
|
|
@ -149,6 +149,7 @@
|
|||
|
||||
<include refid="combine">
|
||||
<property name="combineSearch" value="request.combineSearch"/>
|
||||
<property name="planId" value="${request.testPlanId}"/>
|
||||
</include>
|
||||
|
||||
<include refid="queryVersionCondition">
|
||||
|
@ -268,6 +269,20 @@
|
|||
<property name="condition" value="condition"/>
|
||||
<property name="tablePrefix" value="api_scenario"/>
|
||||
</include>
|
||||
<!-- 测试点 -->
|
||||
<if test="condition.name == 'testPlanCollectionId'">
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="test_plan_collection.id"/>
|
||||
</include>
|
||||
</if>
|
||||
<!-- 所属项目 -->
|
||||
<if test="condition.name == 'projectName'">
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="api_scenario.project_id"/>
|
||||
</include>
|
||||
</if>
|
||||
<!-- 场景等级 -->
|
||||
<if test="condition.name == 'priority'">
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
|
@ -290,7 +305,7 @@
|
|||
</include>
|
||||
</if>
|
||||
<!-- 执行结果 -->
|
||||
<if test="condition.name == 'lastExecuteResult'">
|
||||
<if test="condition.name == 'lastExecResult'">
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="test_plan_api_scenario.last_exec_result"/>
|
||||
|
@ -304,29 +319,73 @@
|
|||
</include>
|
||||
</if>
|
||||
<!-- 通过率 -->
|
||||
<if test="condition.name == 'passRate'">
|
||||
<if test="condition.name == 'requestPassRate'">
|
||||
<choose>
|
||||
<when test="condition.operator == 'NOT_EMPTY'">
|
||||
api_scenario.request_pass_rate is not null and api_scenario.request_pass_rate != '' and api_scenario.request_pass_rate != 'Calculating'
|
||||
</when>
|
||||
<when test="condition.operator == 'EMPTY'">
|
||||
api_scenario.request_pass_rate is null or api_scenario.request_pass_rate == '' or api_scenario.request_pass_rate == 'Calculating'
|
||||
api_scenario.request_pass_rate is null or api_scenario.request_pass_rate = '' or api_scenario.request_pass_rate = 'Calculating'
|
||||
</when>
|
||||
<when test="(condition.operator == 'LT' and condition.value == 0) or (condition.operator == 'GT' and condition.value > 100 )">
|
||||
1=2
|
||||
</when>
|
||||
<otherwise>
|
||||
api_scenario.request_pass_rate ${condition.operator} #{condition.value}
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="api_scenario.request_pass_rate"/>
|
||||
</include>
|
||||
</otherwise>
|
||||
</choose>
|
||||
</if>
|
||||
<!-- 环境 -->
|
||||
<if test="condition.name == 'env'">
|
||||
<if test="condition.name == 'environmentName'">
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="api_scenario.environment_id"/>
|
||||
</include>
|
||||
</if>
|
||||
<!-- 缺陷数 -->
|
||||
<if test="condition.name == 'bugCount'">
|
||||
<choose>
|
||||
<when test="condition.operator == 'NOT_EMPTY'">
|
||||
test_plan_api_scenario.id in (
|
||||
select distinct brc.test_plan_case_id from bug_relation_case brc join bug b on brc.bug_id = b.id
|
||||
where b.deleted = false and brc.test_plan_id = '${planId}' and brc.case_type = 'SCENARIO'
|
||||
)
|
||||
</when>
|
||||
<when test="condition.operator == 'EMPTY'">
|
||||
test_plan_api_scenario.id not in (
|
||||
select distinct brc.test_plan_case_id from bug_relation_case brc join bug b on brc.bug_id = b.id
|
||||
where b.deleted = false and brc.test_plan_id = '${planId}' and brc.case_type = 'SCENARIO'
|
||||
)
|
||||
</when>
|
||||
<when test="(condition.operator == 'LT' and condition.value < 1) or (condition.operator == 'EQUALS' and condition.value < 0)">
|
||||
1=2
|
||||
</when>
|
||||
<otherwise>
|
||||
<if test="condition.operator == 'LT' or (condition.operator == 'EQUALS' and condition.value == 0)">
|
||||
test_plan_api_scenario.id not in (
|
||||
select distinct brc.test_plan_case_id from bug_relation_case brc join bug b on brc.bug_id = b.id
|
||||
where b.deleted = false and brc.test_plan_id = '${planId}' and brc.case_type = 'SCENARIO'
|
||||
)
|
||||
<if test="condition.value > 1">
|
||||
OR
|
||||
</if>
|
||||
</if>
|
||||
<if test="(condition.operator == 'EQUALS' and condition.value > 0) or (condition.operator == 'LT' and condition.value > 1) or condition.operator == 'GT'">
|
||||
test_plan_api_scenario.id in (
|
||||
select brc.test_plan_case_id from bug_relation_case brc join bug b on brc.bug_id = b.id
|
||||
where b.deleted = false and brc.test_plan_id = '${planId}' and brc.case_type = 'SCENARIO' group by brc.test_plan_case_id having
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="count(brc.id)"/>
|
||||
</include>
|
||||
)
|
||||
</if>
|
||||
</otherwise>
|
||||
</choose>
|
||||
</if>
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.queryType">
|
||||
<property name="searchMode" value="${combineSearch}.searchMode"/>
|
||||
</include>
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
<include refid="combine">
|
||||
<property name="combineSearch" value="request.combineSearch"/>
|
||||
<property name="projectId" value="${request.projectId}"/>
|
||||
<property name="deleted" value="${request.useTrash}"/>
|
||||
</include>
|
||||
group by brc.bug_id
|
||||
</select>
|
||||
|
@ -130,6 +129,13 @@
|
|||
<property name="condition" value="condition"/>
|
||||
<property name="tablePrefix" value="b"/>
|
||||
</include>
|
||||
<!-- 标题 -->
|
||||
<if test="condition.name == 'title'">
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="b.title"/>
|
||||
</include>
|
||||
</if>
|
||||
<!-- 状态 -->
|
||||
<if test="condition.name == 'status'">
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
|
@ -152,18 +158,18 @@
|
|||
</include>
|
||||
</if>
|
||||
<!-- 用例数 -->
|
||||
<if test="condition.name == 'caseTotal'">
|
||||
<if test="condition.name == 'relationCaseCount'">
|
||||
<choose>
|
||||
<when test="condition.operator == 'NOT_EMPTY'">
|
||||
b.id in (
|
||||
select distinct b.id from bug b join bug_relation_case brc on b.id = brc.bug_id
|
||||
where deleted = ${deleted} and project_id = '${projectId}'
|
||||
select distinct b.id from bug b join bug_relation_case brc on b.id = brc.bug_id
|
||||
where deleted = false and project_id = '${projectId}'
|
||||
)
|
||||
</when>
|
||||
<when test="condition.operator == 'EMPTY'">
|
||||
b.id not in (
|
||||
select distinct b.id from bug b join bug_relation_case brc on b.id = brc.bug_id
|
||||
where deleted = ${deleted} and project_id = '${projectId}'
|
||||
select distinct b.id from bug b join bug_relation_case brc on b.id = brc.bug_id
|
||||
where deleted = false and project_id = '${projectId}'
|
||||
)
|
||||
</when>
|
||||
<when test="(condition.operator == 'LT' and condition.value < 1) or (condition.operator == 'EQUALS' and condition.value < 0)">
|
||||
|
@ -172,8 +178,8 @@
|
|||
<otherwise>
|
||||
<if test="condition.operator == 'LT' or (condition.operator == 'EQUALS' and condition.value == 0)">
|
||||
b.id not in (
|
||||
select distinct b.id from bug b join bug_relation_case brc on b.id = brc.bug_id
|
||||
where deleted = ${deleted} and project_id = '${projectId}'
|
||||
select distinct b.id from bug b join bug_relation_case brc on b.id = brc.bug_id
|
||||
where deleted = false and project_id = '${projectId}'
|
||||
)
|
||||
<if test="condition.value > 1">
|
||||
OR
|
||||
|
@ -181,12 +187,12 @@
|
|||
</if>
|
||||
<if test="(condition.operator == 'EQUALS' and condition.value > 0) or (condition.operator == 'LT' and condition.value > 1) or condition.operator == 'GT'">
|
||||
b.id in (
|
||||
select distinct b.id from bug b join bug_relation_case brc on b.id = brc.bug_id
|
||||
where deleted = ${deleted} and project_id = '${projectId}' group b.id having
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="count(b.id)"/>
|
||||
</include>
|
||||
select distinct b.id from bug b join bug_relation_case brc on b.id = brc.bug_id
|
||||
where deleted = false and project_id = '${projectId}' group by b.id having
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="count(b.id)"/>
|
||||
</include>
|
||||
)
|
||||
</if>
|
||||
</otherwise>
|
||||
|
@ -197,7 +203,7 @@
|
|||
</include>
|
||||
</foreach>
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.customFiledConditions">
|
||||
<property name="mainIdColumn" value="bug.id"/>
|
||||
<property name="mainIdColumn" value="b.id"/>
|
||||
<property name="associationTable" value="bug_custom_field"/>
|
||||
<property name="associationIdColumn" value="bug_id"/>
|
||||
<property name="combineSearch" value="${combineSearch}"/>
|
||||
|
|
|
@ -168,6 +168,7 @@
|
|||
</include>
|
||||
<include refid="combine">
|
||||
<property name="combineSearch" value="request.combineSearch"/>
|
||||
<property name="planId" value="${request.testPlanId}"/>
|
||||
</include>
|
||||
<include refid="queryVersionCondition">
|
||||
<property name="versionTable" value="functional_case"/>
|
||||
|
@ -313,6 +314,20 @@
|
|||
<property name="condition" value="condition"/>
|
||||
<property name="tablePrefix" value="functional_case"/>
|
||||
</include>
|
||||
<!-- 测试点 -->
|
||||
<if test="condition.name == 'testPlanCollectionId'">
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="test_plan_collection.id"/>
|
||||
</include>
|
||||
</if>
|
||||
<!-- 所属项目 -->
|
||||
<if test="condition.name == 'projectName'">
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="functional_case.project_id"/>
|
||||
</include>
|
||||
</if>
|
||||
<!-- 评审结果 -->
|
||||
<if test="condition.name == 'reviewStatus'">
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
|
@ -328,7 +343,7 @@
|
|||
</include>
|
||||
</if>
|
||||
<!-- 执行结果 -->
|
||||
<if test="condition.name == 'lastExecuteResult'">
|
||||
<if test="condition.name == 'lastExecResult'">
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="test_plan_functional_case.last_exec_result"/>
|
||||
|
@ -365,6 +380,47 @@
|
|||
<property name="condition" value="condition"/>
|
||||
</include>
|
||||
</if>
|
||||
<!-- 缺陷数 -->
|
||||
<if test="condition.name == 'bugCount'">
|
||||
<choose>
|
||||
<when test="condition.operator == 'NOT_EMPTY'">
|
||||
test_plan_functional_case.id in (
|
||||
select distinct brc.test_plan_case_id from bug_relation_case brc join bug b on brc.bug_id = b.id
|
||||
where b.deleted = false and brc.test_plan_id = '${planId}' and brc.case_type = 'FUNCTIONAL'
|
||||
)
|
||||
</when>
|
||||
<when test="condition.operator == 'EMPTY'">
|
||||
test_plan_functional_case.id not in (
|
||||
select distinct brc.test_plan_case_id from bug_relation_case brc join bug b on brc.bug_id = b.id
|
||||
where b.deleted = false and brc.test_plan_id = '${planId}' and brc.case_type = 'FUNCTIONAL'
|
||||
)
|
||||
</when>
|
||||
<when test="(condition.operator == 'LT' and condition.value < 1) or (condition.operator == 'EQUALS' and condition.value < 0)">
|
||||
1=2
|
||||
</when>
|
||||
<otherwise>
|
||||
<if test="condition.operator == 'LT' or (condition.operator == 'EQUALS' and condition.value == 0)">
|
||||
test_plan_functional_case.id not in (
|
||||
select distinct brc.test_plan_case_id from bug_relation_case brc join bug b on brc.bug_id = b.id
|
||||
where b.deleted = false and brc.test_plan_id = '${planId}' and brc.case_type = 'FUNCTIONAL'
|
||||
)
|
||||
<if test="condition.value > 1">
|
||||
OR
|
||||
</if>
|
||||
</if>
|
||||
<if test="(condition.operator == 'EQUALS' and condition.value > 0) or (condition.operator == 'LT' and condition.value > 1) or condition.operator == 'GT'">
|
||||
test_plan_functional_case.id in (
|
||||
select brc.test_plan_case_id from bug_relation_case brc join bug b on brc.bug_id = b.id
|
||||
where b.deleted = false and brc.test_plan_id = '${planId}' and brc.case_type = 'FUNCTIONAL' group by brc.test_plan_case_id having
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
<property name="condition" value="condition"/>
|
||||
<property name="column" value="count(brc.id)"/>
|
||||
</include>
|
||||
)
|
||||
</if>
|
||||
</otherwise>
|
||||
</choose>
|
||||
</if>
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.queryType">
|
||||
<property name="searchMode" value="${combineSearch}.searchMode"/>
|
||||
</include>
|
||||
|
|
Loading…
Reference in New Issue