feat(功能用例): 用例页面创建缺陷并关联

This commit is contained in:
WangXu10 2024-01-25 14:39:44 +08:00 committed by Craftsman
parent 3118d9d764
commit 7c127bd7cf
5 changed files with 27 additions and 4 deletions

View File

@ -54,4 +54,7 @@ public class BugEditRequest {
@Schema(description = "关联附件集合, 文件ID") @Schema(description = "关联附件集合, 文件ID")
private List<String> linkFileIds; private List<String> linkFileIds;
@Schema(description = "用例ID")
private String caseId;
} }

View File

@ -378,18 +378,20 @@
</sql> </sql>
<sql id="queryWhereConditionByProvider"> <sql id="queryWhereConditionByProvider">
<if test="request.projectId != null"> <if test="request.projectId != null and request.projectId != ''">
and b.project_id = #{request.projectId} and b.project_id = #{request.projectId}
</if> </if>
<if test="request.keyword != null"> <if test="request.keyword != null and request.keyword != ''">
and ( and (
b.title like concat('%', #{request.keyword},'%') b.title like concat('%', #{request.keyword},'%')
or b.num like concat('%', #{request.keyword},'%') or b.num like concat('%', #{request.keyword},'%')
or b.tags like concat('%', #{request.keyword},'%')
) )
</if> </if>
<include refid="filter"/> <include refid="filter"/>
<include refid="combine"> <include refid="combine">
<property name="condition" value="request.combine"/> <property name="condition" value="request.combine"/>
<property name="searchMode" value="request.searchMode"/>
</include> </include>
</sql> </sql>
</mapper> </mapper>

View File

@ -91,10 +91,10 @@
</select> </select>
<sql id="queryWhereConditionByProvider"> <sql id="queryWhereConditionByProvider">
<if test="request.caseId != null"> <if test="request.caseId != null and request.caseId != ''">
and brc.case_id = #{request.caseId} and brc.case_id = #{request.caseId}
</if> </if>
<if test="request.keyword != null"> <if test="request.keyword != null and request.keyword != ''">
and b.title like concat('%', #{request.keyword},'%') and b.title like concat('%', #{request.keyword},'%')
</if> </if>
</sql> </sql>

View File

@ -224,6 +224,20 @@ public class BugService {
handleAndSaveCustomFields(request, isUpdate); handleAndSaveCustomFields(request, isUpdate);
// 处理附件 // 处理附件
handleAndSaveAttachments(request, files, currentUser, platformName, platformBug); handleAndSaveAttachments(request, files, currentUser, platformName, platformBug);
if (!isUpdate && StringUtils.isNotBlank(request.getCaseId())) {
//用例创建缺陷并关联
BugRelationCase bugRelationCase = new BugRelationCase();
bugRelationCase.setId(IDGenerator.nextStr());
bugRelationCase.setCaseId(request.getCaseId());
bugRelationCase.setBugId(bug.getId());
bugRelationCase.setCaseType(CaseType.FUNCTIONAL_CASE.getKey());
bugRelationCase.setCreateUser(currentUser);
bugRelationCase.setCreateTime(System.currentTimeMillis());
bugRelationCase.setUpdateTime(System.currentTimeMillis());
bugRelationCaseMapper.insertSelective(bugRelationCase);
}
return bug; return bug;
} }

View File

@ -239,6 +239,10 @@ public class BugControllerTests extends BaseTest {
MultiValueMap<String, Object> paramMap = getDefaultMultiPartParam(request, file); MultiValueMap<String, Object> paramMap = getDefaultMultiPartParam(request, file);
this.requestMultipartWithOkAndReturn(BUG_ADD, paramMap); this.requestMultipartWithOkAndReturn(BUG_ADD, paramMap);
request.setCaseId("test");
paramMap = new LinkedMultiValueMap<>();
paramMap.add("request", JSON.toJSONString(request));
this.requestMultipartWithOkAndReturn(BUG_ADD, paramMap);
} }
@Test @Test