fix(测试计划): 测试计划关键字查询支持针对测试计划组内子计划的查询
This commit is contained in:
parent
45cd225c66
commit
fff5f6e574
|
@ -13,7 +13,6 @@ public class TestPlanConstants {
|
|||
|
||||
//测试计划状态-未开始
|
||||
public static final String TEST_PLAN_STATUS_PREPARED = "PREPARED";
|
||||
|
||||
//测试计划状态-进行中
|
||||
public static final String TEST_PLAN_STATUS_UNDERWAY = "UNDERWAY";
|
||||
//测试计划状态-已完成
|
||||
|
|
|
@ -23,6 +23,8 @@ public class TestPlanTableRequest extends BasePageRequest {
|
|||
@NotBlank(message = "{test_plan.type.not_blank}")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "通过Keyword过滤出的测试子计划的测试计划组id")
|
||||
private List<String> keywordFilterIds;
|
||||
|
||||
public String getSortString() {
|
||||
if (StringUtils.isEmpty(super.getSortString())) {
|
||||
|
|
|
@ -62,4 +62,6 @@ public interface ExtTestPlanMapper {
|
|||
List<String> selectRightfulIdsForExecute(@Param("ids") List<String> ids);
|
||||
|
||||
List<TestPlanExecuteHisDTO> listHis(@Param("request")TestPlanExecuteHisPageRequest request);
|
||||
|
||||
List<String> selectGroupIdByKeyword(@Param("projectId") String projectId, @Param("keyword") String keyword);
|
||||
}
|
||||
|
|
|
@ -90,27 +90,19 @@
|
|||
|
||||
<sql id="queryByTableRequest">
|
||||
<include refid="baseConditionQuery"/>
|
||||
|
||||
<if test="request.keyword != null and request.keyword != ''">
|
||||
and (
|
||||
t.name like concat('%', #{request.keyword},'%')
|
||||
or t.num like concat('%', #{request.keyword},'%')
|
||||
or t.tags like concat('%', #{request.keyword}, '%')
|
||||
)
|
||||
<if test="request.keywordFilterIds != null and request.keywordFilterIds.size() > 0">
|
||||
or t.id in
|
||||
<foreach collection="request.keywordFilterIds" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="request.type != null and request.type != ''">
|
||||
<choose>
|
||||
<when test="request.type == 'ALL'">
|
||||
and t.group_id = 'NONE'
|
||||
</when>
|
||||
<when test="request.type == 'TEST_PLAN'">
|
||||
and t.group_id = 'NONE'
|
||||
and t.type = 'TEST_PLAN'
|
||||
</when>
|
||||
<when test="request.type == 'GROUP'">
|
||||
and t.group_id = 'NONE'
|
||||
and t.type = 'GROUP'
|
||||
</when>
|
||||
</choose>
|
||||
)
|
||||
</if>
|
||||
<choose>
|
||||
<when test='request.searchMode == "AND"'>
|
||||
|
@ -472,6 +464,16 @@
|
|||
where tpr.test_plan_id = #{request.testPlanId}
|
||||
<include refid="filter"/>
|
||||
</select>
|
||||
<select id="selectGroupIdByKeyword" resultType="java.lang.String">
|
||||
SELECT t.group_id
|
||||
FROM test_plan t
|
||||
WHERE t.project_id = #{projectId}
|
||||
AND (
|
||||
t.name like concat('%', #{keyword}, '%')
|
||||
or t.num like concat('%', #{keyword}, '%')
|
||||
or t.tags like concat('%', #{keyword}, '%')
|
||||
)
|
||||
</select>
|
||||
|
||||
<update id="batchUpdate">
|
||||
update test_plan
|
||||
|
|
|
@ -185,6 +185,9 @@ public class TestPlanLogService {
|
|||
* @param typeKey 类型Key
|
||||
*/
|
||||
public void saveBatchLog(List<TestPlan> plans, String operator, String requestUrl, String requestMethod, String requestType, String typeKey) {
|
||||
if (CollectionUtils.isEmpty(plans)) {
|
||||
return;
|
||||
}
|
||||
Project project = projectMapper.selectByPrimaryKey(plans.get(0).getProjectId());
|
||||
List<LogDTO> list = new ArrayList<>();
|
||||
for (TestPlan plan : plans) {
|
||||
|
|
|
@ -26,9 +26,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
|
@ -48,6 +46,7 @@ public class TestPlanManagementService {
|
|||
private TestPlanMapper testPlanMapper;
|
||||
|
||||
public Map<String, Long> moduleCount(TestPlanTableRequest request) {
|
||||
this.initDefaultFilter(request);
|
||||
//查出每个模块节点下的资源数量。 不需要按照模块进行筛选
|
||||
request.setModuleIds(null);
|
||||
List<ModuleCountDTO> moduleCountDTOList = extTestPlanMapper.countModuleIdByConditions(request);
|
||||
|
@ -64,11 +63,36 @@ public class TestPlanManagementService {
|
|||
* 测试计划列表查询
|
||||
*/
|
||||
public Pager<List<TestPlanResponse>> page(TestPlanTableRequest request) {
|
||||
this.initDefaultFilter(request);
|
||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
|
||||
MapUtils.isEmpty(request.getSort()) ? "t.num desc" : request.getSortString());
|
||||
return PageUtils.setPageInfo(page, this.list(request));
|
||||
}
|
||||
|
||||
private void initDefaultFilter(TestPlanTableRequest request) {
|
||||
if (request.getFilter() == null || !request.getFilter().containsKey("status")) {
|
||||
List<String> defaultStatusList = new ArrayList<>();
|
||||
defaultStatusList.add(TestPlanConstants.TEST_PLAN_STATUS_PREPARED);
|
||||
defaultStatusList.add(TestPlanConstants.TEST_PLAN_STATUS_UNDERWAY);
|
||||
defaultStatusList.add(TestPlanConstants.TEST_PLAN_STATUS_COMPLETED);
|
||||
if (request.getFilter() == null) {
|
||||
request.setFilter(new HashMap<>() {{
|
||||
this.put("status", defaultStatusList);
|
||||
}});
|
||||
} else {
|
||||
request.getFilter().put("status", defaultStatusList);
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(request.getKeyword())) {
|
||||
List<String> groupIdList = extTestPlanMapper.selectGroupIdByKeyword(request.getProjectId(), request.getKeyword());
|
||||
if (CollectionUtils.isNotEmpty(groupIdList)) {
|
||||
request.setKeywordFilterIds(groupIdList);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public List<TestPlanResponse> list(TestPlanTableRequest request) {
|
||||
List<TestPlanResponse> testPlanResponses = extTestPlanMapper.selectByConditions(request);
|
||||
handChildren(testPlanResponses,request.getProjectId());
|
||||
|
|
|
@ -433,7 +433,7 @@ public class TestPlanService extends TestPlanBaseUtilsService {
|
|||
).collect(Collectors.toList());
|
||||
archivedPlanList.forEach(item -> this.archived(item.getId(), currentUser));
|
||||
//日志
|
||||
testPlanLogService.saveBatchLog(archivedPlanList, currentUser, "/test-plan/batch-archived", HttpMethodConstants.POST.name(), OperationLogType.UPDATE.name(), "archive");
|
||||
testPlanLogService.saveBatchLog(archivedPlanList, currentUser, "/test-plan/batch-archived", HttpMethodConstants.POST.name(), OperationLogType.ARCHIVED.name(), "archive");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -601,7 +601,7 @@ public class TestPlanService extends TestPlanBaseUtilsService {
|
|||
//日志
|
||||
if (CollectionUtils.isNotEmpty(copyTestPlanList)) {
|
||||
copyCount = testPlanBatchOperationService.batchCopy(copyTestPlanList, request.getTargetId(), request.getMoveType(), userId);
|
||||
testPlanLogService.saveBatchLog(copyTestPlanList, userId, url, method, OperationLogType.COPY.name(), "copy");
|
||||
testPlanLogService.saveBatchLog(copyTestPlanList, userId, url, method, OperationLogType.ADD.name(), "copy");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -814,7 +814,7 @@ public class TestPlanService extends TestPlanBaseUtilsService {
|
|||
}
|
||||
}
|
||||
TestPlanExample testPlanExample = new TestPlanExample();
|
||||
testPlanExample.createCriteria().andIdEqualTo(testPlanGroupId).andStatusNotEqualTo(TestPlanConstants.TEST_PLAN_STATUS_ARCHIVED);
|
||||
testPlanExample.createCriteria().andIdEqualTo(testPlanGroupId);
|
||||
TestPlan updateGroupPlan = new TestPlan();
|
||||
updateGroupPlan.setStatus(groupStatus);
|
||||
testPlanMapper.updateByExampleSelective(updateGroupPlan, testPlanExample);
|
||||
|
|
|
@ -951,7 +951,6 @@ public class TestPlanTests extends BaseTest {
|
|||
groupRequest.setType(TestPlanConstants.TEST_PLAN_TYPE_GROUP);
|
||||
onlyPlanRequest.setType(TestPlanConstants.TEST_PLAN_TYPE_PLAN);
|
||||
|
||||
|
||||
BaseTreeNode a1Node = TestPlanTestUtils.getNodeByName(preliminaryTreeNodes, "a1");
|
||||
BaseTreeNode a2Node = TestPlanTestUtils.getNodeByName(preliminaryTreeNodes, "a2");
|
||||
BaseTreeNode a3Node = TestPlanTestUtils.getNodeByName(preliminaryTreeNodes, "a3");
|
||||
|
@ -959,17 +958,27 @@ public class TestPlanTests extends BaseTest {
|
|||
BaseTreeNode a1b1Node = TestPlanTestUtils.getNodeByName(preliminaryTreeNodes, "a1-b1");
|
||||
assert a1Node != null & a2Node != null & a3Node != null & a1a1Node != null & a1b1Node != null;
|
||||
|
||||
//此时有一个归档的
|
||||
testPlanTestService.checkTestPlanPage(this.requestPostWithOkAndReturn(
|
||||
URL_POST_TEST_PLAN_PAGE, dataRequest).getResponse().getContentAsString(StandardCharsets.UTF_8),
|
||||
dataRequest.getCurrent(),
|
||||
dataRequest.getPageSize(),
|
||||
1010);
|
||||
1010 - 1);
|
||||
//查询归档的
|
||||
dataRequest.setFilter(new HashMap<>() {{
|
||||
this.put("status", Collections.singletonList(TestPlanConstants.TEST_PLAN_STATUS_ARCHIVED));
|
||||
}});
|
||||
testPlanTestService.checkTestPlanPage(this.requestPostWithOkAndReturn(
|
||||
URL_POST_TEST_PLAN_PAGE, dataRequest).getResponse().getContentAsString(StandardCharsets.UTF_8),
|
||||
dataRequest.getCurrent(),
|
||||
dataRequest.getPageSize(),
|
||||
1);
|
||||
//只查询组
|
||||
testPlanTestService.checkTestPlanPage(this.requestPostWithOkAndReturn(
|
||||
URL_POST_TEST_PLAN_PAGE, groupRequest).getResponse().getContentAsString(StandardCharsets.UTF_8),
|
||||
dataRequest.getCurrent(),
|
||||
dataRequest.getPageSize(),
|
||||
3);
|
||||
3 - 1);
|
||||
//只查询计划
|
||||
testPlanTestService.checkTestPlanPage(this.requestPostWithOkAndReturn(
|
||||
URL_POST_TEST_PLAN_PAGE, onlyPlanRequest).getResponse().getContentAsString(StandardCharsets.UTF_8),
|
||||
|
@ -981,11 +990,12 @@ public class TestPlanTests extends BaseTest {
|
|||
dataRequest.setSort(new HashMap<>() {{
|
||||
this.put("name", "desc");
|
||||
}});
|
||||
dataRequest.setFilter(null);
|
||||
testPlanTestService.checkTestPlanPage(this.requestPostWithOkAndReturn(
|
||||
URL_POST_TEST_PLAN_PAGE, dataRequest).getResponse().getContentAsString(StandardCharsets.UTF_8),
|
||||
dataRequest.getCurrent(),
|
||||
dataRequest.getPageSize(),
|
||||
1010);
|
||||
1010 - 1);
|
||||
|
||||
|
||||
//指定模块ID查询 (查询count时,不会因为选择了模块而更改了总量
|
||||
|
@ -998,7 +1008,7 @@ public class TestPlanTests extends BaseTest {
|
|||
URL_POST_TEST_PLAN_PAGE, dataRequest).getResponse().getContentAsString(StandardCharsets.UTF_8),
|
||||
dataRequest.getCurrent(),
|
||||
dataRequest.getPageSize(),
|
||||
910);
|
||||
910 - 1);
|
||||
|
||||
//测试根据名称模糊查询: Plan_2 预期结果: a1Node下有11条(testPlan_2,testPlan_20~testPlan_29), a1b1Node下有100条(testPlan_200~testPlan_299)
|
||||
dataRequest.setModuleIds(null);
|
||||
|
|
Loading…
Reference in New Issue