feat(测试计划): 关联计划弹窗功能用例列表

This commit is contained in:
WangXu10 2024-05-13 10:28:53 +08:00 committed by Craftsman
parent 177d5afda1
commit 2c0c4c07fa
11 changed files with 134 additions and 8 deletions

View File

@ -144,7 +144,7 @@ public class FunctionalCaseController {
public Pager<List<FunctionalCasePageDTO>> getFunctionalCasePage(@Validated @RequestBody FunctionalCasePageRequest request) {
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "pos desc");
return PageUtils.setPageInfo(page, functionalCaseService.getFunctionalCasePage(request, false));
return PageUtils.setPageInfo(page, functionalCaseService.getFunctionalCasePage(request, false, false));
}
@PostMapping("/module/count")

View File

@ -57,7 +57,7 @@ public class FunctionalCaseRelationshipController {
public Pager<List<FunctionalCasePageDTO>> getFunctionalCasePage(@Validated @RequestBody RelationshipPageRequest request) {
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "pos desc");
return PageUtils.setPageInfo(page, functionalCaseService.getFunctionalCasePage(request, false));
return PageUtils.setPageInfo(page, functionalCaseService.getFunctionalCasePage(request, false, false));
}
@PostMapping("/add")

View File

@ -43,7 +43,7 @@ public class FunctionalCaseTrashController {
public Pager<List<FunctionalCasePageDTO>> getFunctionalCasePage(@Validated @RequestBody FunctionalCasePageRequest request) {
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "delete_time desc, id asc");
return PageUtils.setPageInfo(page, functionalCaseService.getFunctionalCasePage(request, true));
return PageUtils.setPageInfo(page, functionalCaseService.getFunctionalCasePage(request, true, false));
}
@PostMapping("/module/count")

View File

@ -34,7 +34,7 @@ public interface ExtFunctionalCaseMapper {
List<FunctionalCase> checkCaseByModuleIds(@Param("moduleIds") List<String> deleteIds);
List<FunctionalCasePageDTO> list(@Param("request") FunctionalCasePageRequest request, @Param("deleted") boolean deleted);
List<FunctionalCasePageDTO> list(@Param("request") FunctionalCasePageRequest request, @Param("deleted") boolean deleted, @Param("isRepeat") boolean isRepeat);
void recoverCase(@Param("ids") List<String> ids, @Param("userId") String userId, @Param("time") long time);
@ -84,12 +84,12 @@ public interface ExtFunctionalCaseMapper {
List<String> getSelectIdsByAssociateParam(@Param("request") AssociateOtherCaseRequest request, @Param("deleted") boolean deleted);
/**
* 根据模块ID获取脑图展示数据
* 根据模块ID获取脑图展示数据
*/
List<FunctionalCaseMindDTO> getMinderCaseList(@Param("request") FunctionalCaseMindRequest request, @Param("deleted") boolean deleted);
/**
* 根据模块ID获取用例评审脑图展示数据
* 根据模块ID获取用例评审脑图展示数据
*/
List<FunctionalCaseMindDTO> getMinderCaseReviewList(@Param("request") FunctionalCaseReviewMindRequest request, @Param("deleted") boolean delete, @Param("userId") String userId, @Param("viewStatusUserId") boolean viewStatusUserId);

View File

@ -127,6 +127,11 @@
select case_review_functional_case.case_id from case_review_functional_case where case_review_functional_case.review_id = #{request.reviewId}
)
</if>
<if test="!isRepeat">
AND functional_case.id not in (
select test_plan_functional_case.functional_case_id from test_plan_functional_case where test_plan_functional_case.test_plan_id = #{request.testPlanId}
)
</if>
<if test="request.excludeIds != null and request.excludeIds.size() > 0">
AND functional_case.id not in
<foreach collection="request.excludeIds" item="excludeId" separator="," open="(" close=")">

View File

@ -47,4 +47,6 @@ public class FunctionalCasePageRequest extends BasePageRequest implements Serial
@Schema(description = "排除ids")
private List<String> excludeIds;
@Schema(description = "测试计划id")
private String testPlanId;
}

View File

@ -676,8 +676,8 @@ public class FunctionalCaseService {
* @param request request
* @return List<FunctionalCasePageDTO>
*/
public List<FunctionalCasePageDTO> getFunctionalCasePage(FunctionalCasePageRequest request, Boolean deleted) {
List<FunctionalCasePageDTO> functionalCaseLists = extFunctionalCaseMapper.list(request, deleted);
public List<FunctionalCasePageDTO> getFunctionalCasePage(FunctionalCasePageRequest request, Boolean deleted, Boolean isRepeat) {
List<FunctionalCasePageDTO> functionalCaseLists = extFunctionalCaseMapper.list(request, deleted, isRepeat);
if (CollectionUtils.isEmpty(functionalCaseLists)) {
return new ArrayList<>();
}

View File

@ -0,0 +1,50 @@
package io.metersphere.plan.controller;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.functional.dto.FunctionalCasePageDTO;
import io.metersphere.functional.request.FunctionalCasePageRequest;
import io.metersphere.functional.service.FunctionalCaseService;
import io.metersphere.plan.service.TestPlanConfigService;
import io.metersphere.sdk.constants.PermissionConstants;
import io.metersphere.system.security.CheckOwner;
import io.metersphere.system.utils.PageUtils;
import io.metersphere.system.utils.Pager;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@Tag(name = "测试计划关联用例弹窗接口相关")
@RequestMapping("/test-plan/association")
public class TestPlanAssociateController {
@Resource
private TestPlanConfigService testPlanConfigService;
@Resource
private FunctionalCaseService functionalCaseService;
@PostMapping("/page")
@Operation(summary = "测试计划-关联用例弹窗-功能用例列表查询(项目)")
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ)
@CheckOwner(resourceId = "#request.getTestPlanId()", resourceType = "test_plan")
public Pager<List<FunctionalCasePageDTO>> getFunctionalCasePage(@Validated @RequestBody FunctionalCasePageRequest request) {
Boolean isRepeat = false;
if (StringUtils.isNotBlank(request.getTestPlanId())) {
isRepeat = testPlanConfigService.getConfigById(request.getTestPlanId());
}
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "pos desc");
return PageUtils.setPageInfo(page, functionalCaseService.getFunctionalCasePage(request, false, isRepeat));
}
}

View File

@ -1,5 +1,6 @@
package io.metersphere.plan.service;
import io.metersphere.plan.domain.TestPlanConfig;
import io.metersphere.plan.domain.TestPlanConfigExample;
import io.metersphere.plan.mapper.TestPlanConfigMapper;
import jakarta.annotation.Resource;
@ -25,4 +26,9 @@ public class TestPlanConfigService {
example.createCriteria().andTestPlanIdIn(testPlanIdList);
testPlanConfigMapper.deleteByExample(example);
}
public boolean getConfigById(String testPlanId) {
TestPlanConfig testPlanConfig = testPlanConfigMapper.selectByPrimaryKey(testPlanId);
return testPlanConfig.getRepeatCase();
}
}

View File

@ -0,0 +1,42 @@
package io.metersphere.plan.controller;
import io.metersphere.functional.request.FunctionalCasePageRequest;
import io.metersphere.sdk.util.JSON;
import io.metersphere.system.base.BaseTest;
import io.metersphere.system.controller.handler.ResultHolder;
import org.junit.jupiter.api.*;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.SqlConfig;
import org.springframework.test.web.servlet.MvcResult;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@AutoConfigureMockMvc
public class TestPlanAssociateControllerTests extends BaseTest {
public static final String FUNCTIONAL_CASE_ASSOCIATION_URL = "/test-plan/association/page";
@Test
@Order(1)
@Sql(scripts = {"/dml/init_test_plan_association.sql"}, config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED))
public void testGetPageList() throws Exception {
FunctionalCasePageRequest request = new FunctionalCasePageRequest();
request.setProjectId("123");
request.setCurrent(1);
request.setPageSize(10);
this.requestPost(FUNCTIONAL_CASE_ASSOCIATION_URL, request);
request.setSort(new HashMap<>() {{
put("createTime", "desc");
}});
request.setTestPlanId("wxx_1");
MvcResult mvcResult = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_ASSOCIATION_URL, request);
String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
Assertions.assertNotNull(resultHolder);
}
}

View File

@ -0,0 +1,21 @@
INSERT INTO `test_plan`(`id`, `num`, `project_id`, `group_id`, `module_id`, `name`, `status`, `type`, `tags`, `create_time`, `create_user`, `update_time`, `update_user`, `planned_start_time`, `planned_end_time`, `actual_start_time`, `actual_end_time`, `description`)
VALUES
('wxx_1', 5000, '123', 'NONE', '1', 'qwe', 'PREPARED', 'TEST_PLAN', NULL, 1714980158000, 'WX', 1714980158000, 'WX', 1714980158000, 1714980158000, 1714980158000, 1714980158000, '11'),
('wxx_2', 10000, '123', 'NONE', '1', 'eeew', 'PREPARED', 'TEST_PLAN', NULL, 1714980158000, 'WX', 1714980158000, 'WX', 1714980158000, 1714980158000, 1714980158000, 1714980158000, '11');
INSERT INTO `test_plan_config`(`test_plan_id`, `automatic_status_update`, `repeat_case`, `pass_threshold`, `test_planning`)
VALUES
('wxx_1', b'0', b'0', 100, b'0'),
('wxx_2', b'0', b'0', 100, b'0');
INSERT INTO `test_plan_functional_case`(`id`, `test_plan_id`, `functional_case_id`, `create_time`, `create_user`, `execute_user`, `last_exec_time`, `last_exec_result`, `pos`)
VALUES ('wxx_tpfc_1', 'wxx_1', 'wxx_test_1', 1714980158000, 'admin', NULL, NULL, NULL, 1);
INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, review_status, tags, case_edit_type, pos, version_id, ref_id, last_execute_result, deleted, public_case, latest, create_user, update_user, delete_user, create_time, update_time, delete_time)
VALUES
('wxx_test_1', 1, '1', '123', '100001', '1111', 'UN_REVIEWED', NULL, 'TEXT', 55000, 'v3.0.0', 'TEST_FUNCTIONAL_MINDER_CASE_ID_7', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL),
('wxx_test_2', 2, '1', '123', '100001', '2222', 'UN_REVIEWED', NULL, 'TEXT', 55000, 'v3.0.0', 'TEST_FUNCTIONAL_MINDER_CASE_ID_7', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL),
('wxx_test_3', 3, 'root', '123', '100001', '3333', 'UN_REVIEWED', NULL, 'TEXT', 55000, 'v3.0.0', 'TEST_FUNCTIONAL_MINDER_CASE_ID_7', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL);