refactor(功能用例): 移动高级筛的匹配模式选到基础类里

This commit is contained in:
guoyuqi 2023-11-29 16:44:57 +08:00 committed by Craftsman
parent cd585bf7a3
commit f6472080a7
5 changed files with 37 additions and 20 deletions

View File

@ -16,9 +16,6 @@ public class BaseFunctionalCaseBatchDTO extends TableBatchProcessDTO implements
@Schema(description = "模块id")
private List<String> moduleIds;
@Schema(description = "匹配模式 所有/任一", allowableValues = {"AND", "OR"})
private String searchMode = "AND";
@Schema(description = "版本id")
private String versionId;

View File

@ -266,6 +266,28 @@
</if>
</sql>
<sql id="queryVersionConditionByBaseQueryRequest">
<if test="request.versionId != null">
${versionTable}.version_id = #{request.versionId}
<include refid="queryType">
<property name="searchMode" value="request.condition.searchMode"/>
</include>
</if>
<if test="request.refId != null">
${versionTable}.ref_id = #{request.refId}
<include refid="queryType">
<property name="searchMode" value="request.condition.searchMode"/>
</include>
</if>
<if test="request.versionId == null and request.refId == null">
${versionTable}.latest = 1
<include refid="queryType">
<property name="searchMode" value="request.condition.searchMode"/>
</include>
</if>
1 = 1
</sql>
<sql id="queryVersionCondition">
<if test="request.versionId != null">
${versionTable}.version_id = #{request.versionId}
@ -382,10 +404,10 @@
functional_case.project_id = #{projectId}
and functional_case.deleted = #{deleted}
<choose>
<when test='request.searchMode == "AND"'>
<when test='request.condition.searchMode == "AND"'>
AND <include refid="queryWhereConditionByBaseQueryRequest"/>
</when>
<when test='request.searchMode == "OR"'>
<when test='request.condition.searchMode == "OR"'>
and (
<include refid="queryWhereConditionByBaseQueryRequest"/>
)
@ -400,7 +422,7 @@
#{moduleId}
</foreach>
<include refid="queryType">
<property name="searchMode" value="request.searchMode"/>
<property name="searchMode" value="request.condition.searchMode"/>
</include>
</if>
<if test="request.condition.keyword != null">
@ -410,7 +432,7 @@
or JSON_CONTAINS(tags, concat('["',#{request.keyword},'"]'))
)
<include refid="queryType">
<property name="searchMode" value="request.searchMode"/>
<property name="searchMode" value="request.condition.searchMode"/>
</include>
</if>
<include refid="filters">
@ -421,7 +443,7 @@
<property name="condition" value="request.condition.combine"/>
</include>
</if>
<include refid="queryVersionCondition">
<include refid="queryVersionConditionByBaseQueryRequest">
<property name="versionTable" value="functional_case"/>
</include>
</sql>

View File

@ -32,10 +32,6 @@ public class FunctionalCasePageRequest extends BasePageRequest implements Serial
@Schema(description = "模块id")
private List<String> moduleIds;
@Schema(description = "匹配模式 所有/任一", allowableValues = {"AND", "OR"})
private String searchMode = "AND";
@Schema(description = "关联用例")
private AssociationDTO associationCase;

View File

@ -227,7 +227,7 @@ public class FunctionalCaseService {
*
* @param functionalCase functionalCase
*/
private FunctionalCaseDetailDTO checkTemplateCustomField(FunctionalCaseDetailDTO functionalCaseDetailDTO, FunctionalCase functionalCase) {
private void checkTemplateCustomField(FunctionalCaseDetailDTO functionalCaseDetailDTO, FunctionalCase functionalCase) {
TemplateDTO templateDTO = projectTemplateService.getTemplateDTOById(functionalCase.getTemplateId(), functionalCase.getProjectId(), TemplateScene.FUNCTIONAL.name());
if (CollectionUtils.isNotEmpty(templateDTO.getCustomFields())) {
List<TemplateCustomFieldDTO> customFields = templateDTO.getCustomFields();
@ -240,7 +240,6 @@ public class FunctionalCaseService {
});
functionalCaseDetailDTO.setCustomFields(customFields);
}
return functionalCaseDetailDTO;
}
@ -477,13 +476,13 @@ public class FunctionalCaseService {
Long nextOrder = getNextOrder(request.getProjectId());
for (int i = 0; i < ids.size(); i++) {
for (String s : ids) {
String id = IDGenerator.nextStr();
FunctionalCase functionalCase = functionalCaseMap.get(ids.get(i));
FunctionalCaseBlob functionalCaseBlob = functionalCaseBlobMap.get(ids.get(i));
List<FunctionalCaseAttachment> caseAttachments = attachmentMap.get(ids.get(i));
List<FileAssociation> fileAssociationList = fileAssociationMap.get(ids.get(i));
List<FunctionalCaseCustomField> customFields = customFieldMap.get(ids.get(i));
FunctionalCase functionalCase = functionalCaseMap.get(s);
FunctionalCaseBlob functionalCaseBlob = functionalCaseBlobMap.get(s);
List<FunctionalCaseAttachment> caseAttachments = attachmentMap.get(s);
List<FileAssociation> fileAssociationList = fileAssociationMap.get(s);
List<FunctionalCaseCustomField> customFields = customFieldMap.get(s);
Optional.ofNullable(functionalCase).ifPresent(functional -> {
functional.setId(id);

View File

@ -11,6 +11,9 @@ public class BaseCondition {
@Schema(description = "关键字")
private String keyword;
@Schema(description = "匹配模式 所有/任一", allowableValues = {"AND", "OR"})
private String searchMode = "AND";
@Schema(description = "过滤字段")
private Map<String, List<String>> filter;