feat(测试计划): 测试计划关联的用例增加关联缺陷接口

This commit is contained in:
wxg0103 2024-05-14 15:25:43 +08:00 committed by 刘瑞斌
parent 0c3ed10966
commit 05d11c04ec
8 changed files with 75 additions and 12 deletions

View File

@ -57,4 +57,6 @@ public interface BaseAssociateBugProvider {
* @return
*/
List<BugProviderDTO> hasAssociateBugPage(AssociateBugPageRequest request);
List<BugProviderDTO> hasTestPlanAssociateBugPage(AssociateBugPageRequest request);
}

View File

@ -23,7 +23,7 @@ public class AssociateBugPageRequest extends BaseProviderCondition {
@Schema(description = "用例id", requiredMode = Schema.RequiredMode.REQUIRED)
private String caseId;
@Schema(description = "关联测试计划用例ID", requiredMode = Schema.RequiredMode.REQUIRED)
@Schema(description = "关联测试计划用例ID 如果是测试计划关联用例的缺陷,这个参数必填", requiredMode = Schema.RequiredMode.REQUIRED)
private String testPlanCaseId;
@Schema(description = "项目ID", requiredMode = Schema.RequiredMode.REQUIRED)

View File

@ -81,4 +81,6 @@ public interface ExtBugRelateCaseMapper {
long countByCaseId(String caseId);
List<CaseRelateBugDTO> getBugCountByIds(@Param("ids") List<String> ids);
List<BugProviderDTO> getTestPlanAssociateBugs(@Param("request") AssociateBugPageRequest request, @Param("sort") String sort);
}

View File

@ -275,4 +275,38 @@
ORDER BY
bug.pos DESC
</select>
<select id="getTestPlanAssociateBugs" resultType="io.metersphere.dto.BugProviderDTO">
SELECT
brc.id as id,
brc.bug_id bugId,
b.num as num,
b.title as name,
b.handle_user handleUser,
b.`status`,
bc.description as content,
brc.test_plan_id testPlanId,
tp.name testPlanName
FROM
bug_relation_case brc
INNER JOIN bug b ON brc.bug_id = b.id
INNER JOIN bug_content bc ON brc.bug_id = bc.bug_id
left join test_plan tp on brc.test_plan_id = tp.id
<where>
<if test="request.testPlanCaseId != null and request.testPlanCaseId != ''">
and brc.test_plan_case_id = #{request.testPlanCaseId}
</if>
<if test="request.keyword != null and request.keyword != ''">
and b.title like concat('%', #{request.keyword},'%')
</if>
<include refid="filter"/>
order by
<if test="sort != null and sort != ''">
brc.${sort}
</if>
<if test="sort == null or sort == ''">
brc.create_time desc
</if>
</where>
</select>
</mapper>

View File

@ -96,13 +96,20 @@ public class AssociateBugProvider implements BaseAssociateBugProvider {
return buildAssociateBugs(associateBugs, request.getProjectId());
}
@Override
public List<BugProviderDTO> hasTestPlanAssociateBugPage(AssociateBugPageRequest request) {
List<BugProviderDTO> associateBugs = extBugRelateCaseMapper.getTestPlanAssociateBugs(request, request.getSortString());
return buildAssociateBugs(associateBugs, request.getProjectId());
}
/**
* 关联缺陷列表数据处理
*
* @param associateBugs 关联缺陷
* @param projectId 项目ID
* @return 关联缺陷列表
*/
private List<BugProviderDTO> buildAssociateBugs(List<BugProviderDTO> associateBugs, String projectId) {
public List<BugProviderDTO> buildAssociateBugs(List<BugProviderDTO> associateBugs, String projectId) {
List<SelectOption> headerHandlerOption = bugCommonService.getHeaderHandlerOption(projectId);
List<SelectOption> statusOption = bugStatusService.getHeaderStatusOption(projectId);
associateBugs.forEach(item -> {

View File

@ -10,6 +10,7 @@ import io.metersphere.plan.dto.response.TestPlanCasePageResponse;
import io.metersphere.plan.dto.response.TestPlanResourceSortResponse;
import io.metersphere.plan.service.TestPlanFunctionalCaseService;
import io.metersphere.plan.service.TestPlanManagementService;
import io.metersphere.request.AssociateBugPageRequest;
import io.metersphere.request.BugPageProviderRequest;
import io.metersphere.sdk.constants.HttpMethodConstants;
import io.metersphere.sdk.constants.PermissionConstants;
@ -131,4 +132,12 @@ public class TestPlanFunctionalCaseController {
testPlanFunctionalCaseService.run(request, new LogInsertModule(SessionUtils.getUserId(), "/test-plan/functional/case/run", HttpMethodConstants.POST.name()));
}
@PostMapping("/has/associate/bug/page")
@Operation(summary = "测试计划-计划详情-功能用例-获取已关联的缺陷列表")
@CheckOwner(resourceId = "#request.getTestPlanCaseId()", resourceType = "test_plan_functional_case")
public Pager<List<BugProviderDTO>> getAssociateBugList(@Validated @RequestBody AssociateBugPageRequest request) {
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize());
return PageUtils.setPageInfo(page, testPlanFunctionalCaseService.hasAssociateBugPage(request));
}
}

View File

@ -32,6 +32,7 @@ import io.metersphere.plan.mapper.*;
import io.metersphere.project.domain.Project;
import io.metersphere.project.dto.ModuleCountDTO;
import io.metersphere.provider.BaseAssociateBugProvider;
import io.metersphere.request.AssociateBugPageRequest;
import io.metersphere.request.BugPageProviderRequest;
import io.metersphere.sdk.constants.CaseType;
import io.metersphere.sdk.constants.FunctionalCaseExecuteResult;
@ -411,4 +412,8 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
executeHistory.setCreateTime(System.currentTimeMillis());
return executeHistory;
}
public List<BugProviderDTO> hasAssociateBugPage(AssociateBugPageRequest request) {
return baseAssociateBugProvider.hasTestPlanAssociateBugPage(request);
}
}

View File

@ -6,13 +6,10 @@ import io.metersphere.bug.mapper.BugRelationCaseMapper;
import io.metersphere.dto.BugProviderDTO;
import io.metersphere.plan.domain.TestPlanFunctionalCase;
import io.metersphere.plan.domain.TestPlanFunctionalCaseExample;
import io.metersphere.plan.dto.request.BasePlanCaseBatchRequest;
import io.metersphere.plan.dto.request.TestPlanCaseAssociateBugRequest;
import io.metersphere.plan.dto.request.TestPlanCaseRequest;
import io.metersphere.plan.dto.request.TestPlanCaseRunRequest;
import io.metersphere.plan.dto.request.TestPlanDisassociationRequest;
import io.metersphere.plan.dto.request.*;
import io.metersphere.plan.mapper.TestPlanFunctionalCaseMapper;
import io.metersphere.provider.BaseAssociateBugProvider;
import io.metersphere.request.AssociateBugPageRequest;
import io.metersphere.request.BugPageProviderRequest;
import io.metersphere.sdk.util.JSON;
import io.metersphere.system.base.BaseTest;
@ -156,6 +153,14 @@ public class TestPlanCaseControllerTests extends BaseTest {
ids.add("bug_1");
Mockito.when(baseAssociateBugProvider.getSelectBugs(request, false)).thenReturn(ids);
this.requestPostWithOkAndReturn("/test-plan/functional/case/associate/bug", request);
AssociateBugPageRequest associateBugPageRequest = new AssociateBugPageRequest();
associateBugPageRequest.setProjectId(DEFAULT_PROJECT_ID);
associateBugPageRequest.setCurrent(1);
associateBugPageRequest.setPageSize(10);
associateBugPageRequest.setTestPlanCaseId("relate_case_1");
this.requestPostWithOkAndReturn("/test-plan/functional/case/has/associate/bug/page", associateBugPageRequest);
}
@Test
@ -168,7 +173,6 @@ public class TestPlanCaseControllerTests extends BaseTest {
}
@Test
@Order(11)
public void testFunctionalCaseRun() throws Exception {