feat(功能用例): 脑图分页

This commit is contained in:
guoyuqi 2024-06-21 10:54:20 +08:00 committed by Craftsman
parent b7b38276e7
commit 9b0c48a5bf
4 changed files with 44 additions and 31 deletions

View File

@ -1,6 +1,8 @@
package io.metersphere.functional.controller; package io.metersphere.functional.controller;
import com.alibaba.excel.util.StringUtils; import com.alibaba.excel.util.StringUtils;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.functional.dto.FunctionalMinderTreeDTO; import io.metersphere.functional.dto.FunctionalMinderTreeDTO;
import io.metersphere.functional.request.FunctionalCaseMindRequest; import io.metersphere.functional.request.FunctionalCaseMindRequest;
import io.metersphere.functional.request.FunctionalCaseMinderEditRequest; import io.metersphere.functional.request.FunctionalCaseMinderEditRequest;
@ -10,6 +12,8 @@ import io.metersphere.functional.service.FunctionalCaseMinderService;
import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.sdk.constants.PermissionConstants;
import io.metersphere.system.dto.sdk.BaseTreeNode; import io.metersphere.system.dto.sdk.BaseTreeNode;
import io.metersphere.system.security.CheckOwner; import io.metersphere.system.security.CheckOwner;
import io.metersphere.system.utils.PageUtils;
import io.metersphere.system.utils.Pager;
import io.metersphere.system.utils.SessionUtils; import io.metersphere.system.utils.SessionUtils;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
@ -46,8 +50,10 @@ public class FunctionalCaseMinderController {
@Operation(summary = "用例管理-功能用例-脑图用例跟根据模块ID查询列表") @Operation(summary = "用例管理-功能用例-脑图用例跟根据模块ID查询列表")
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ) @RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ)
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project") @CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
public List<FunctionalMinderTreeDTO> getFunctionalCaseMinderTree(@Validated @RequestBody FunctionalCaseMindRequest request) { public Pager<List<FunctionalMinderTreeDTO>> getFunctionalCaseMinderTree(@Validated @RequestBody FunctionalCaseMindRequest request) {
return functionalCaseMinderService.getMindFunctionalCase(request, false); Page<Object> page = PageHelper.startPage(request.getCurrent(), 100 );
return PageUtils.setPageInfo(page, functionalCaseMinderService.getMindFunctionalCase(request, false));
} }
@PostMapping("/edit") @PostMapping("/edit")

View File

@ -1,6 +1,7 @@
package io.metersphere.functional.request; package io.metersphere.functional.request;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
import lombok.Data; import lombok.Data;
@ -12,4 +13,8 @@ public class FunctionalCaseMindRequest {
@Schema(description = "模块ID", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "模块ID", requiredMode = Schema.RequiredMode.REQUIRED)
private String moduleId; private String moduleId;
@Min(value = 1, message = "当前页码必须大于0")
@Schema(description = "当前页码")
private int current;
} }

View File

@ -32,7 +32,6 @@ import io.metersphere.system.log.constants.OperationLogType;
import io.metersphere.system.log.dto.LogDTO; import io.metersphere.system.log.dto.LogDTO;
import io.metersphere.system.log.service.OperationLogService; import io.metersphere.system.log.service.OperationLogService;
import io.metersphere.system.mapper.CustomFieldMapper; import io.metersphere.system.mapper.CustomFieldMapper;
import io.metersphere.system.mapper.ExtCheckOwnerMapper;
import io.metersphere.system.mapper.UserMapper; import io.metersphere.system.mapper.UserMapper;
import io.metersphere.system.notice.constants.NoticeConstants; import io.metersphere.system.notice.constants.NoticeConstants;
import io.metersphere.system.service.CommonNoticeSendService; import io.metersphere.system.service.CommonNoticeSendService;
@ -84,9 +83,6 @@ public class FunctionalCaseMinderService {
@Resource @Resource
private FunctionalCaseCustomFieldMapper functionalCaseCustomFieldMapper; private FunctionalCaseCustomFieldMapper functionalCaseCustomFieldMapper;
@Resource
private ExtCheckOwnerMapper extCheckOwnerMapper;
@Resource @Resource
private FunctionalCaseService functionalCaseService; private FunctionalCaseService functionalCaseService;
@ -127,10 +123,6 @@ public class FunctionalCaseMinderService {
private ProjectTemplateService projectTemplateService; private ProjectTemplateService projectTemplateService;
private static final String FUNCTIONAL_CASE = "functional_case";
private static final String FUNCTIONAL_CASE_MODULE = "functional_case_module";
private static final String CHECK_OWNER_CASE = "check_owner_case";
/** /**
* 功能用例-脑图用例列表查询 * 功能用例-脑图用例列表查询
* *

View File

@ -1,10 +1,7 @@
package io.metersphere.functional.controller; package io.metersphere.functional.controller;
import io.metersphere.functional.domain.*; import io.metersphere.functional.domain.*;
import io.metersphere.functional.dto.CaseCustomFieldDTO; import io.metersphere.functional.dto.*;
import io.metersphere.functional.dto.FunctionalCaseStepDTO;
import io.metersphere.functional.dto.FunctionalMinderTreeDTO;
import io.metersphere.functional.dto.MinderOptionDTO;
import io.metersphere.functional.mapper.*; import io.metersphere.functional.mapper.*;
import io.metersphere.functional.request.*; import io.metersphere.functional.request.*;
import io.metersphere.sdk.util.JSON; import io.metersphere.sdk.util.JSON;
@ -12,6 +9,7 @@ import io.metersphere.sdk.util.Translator;
import io.metersphere.system.base.BaseTest; import io.metersphere.system.base.BaseTest;
import io.metersphere.system.controller.handler.ResultHolder; import io.metersphere.system.controller.handler.ResultHolder;
import io.metersphere.system.dto.sdk.BaseTreeNode; import io.metersphere.system.dto.sdk.BaseTreeNode;
import io.metersphere.system.utils.Pager;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -64,17 +62,21 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
public void testGetPageList() throws Exception { public void testGetPageList() throws Exception {
FunctionalCaseMindRequest request = new FunctionalCaseMindRequest(); FunctionalCaseMindRequest request = new FunctionalCaseMindRequest();
request.setProjectId("project-case-minder-test"); request.setProjectId("project-case-minder-test");
request.setCurrent(1);
MvcResult mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_LIST_URL, request); MvcResult mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_LIST_URL, request);
String contentAsString = mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8); Pager<List<FunctionalMinderTreeDTO>> tableData = JSON.parseObject(JSON.toJSONString(
ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class); JSON.parseObject(mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class).getData()),
Assertions.assertNotNull(resultHolder); Pager.class);
Assertions.assertNotNull(tableData);
request = new FunctionalCaseMindRequest(); request = new FunctionalCaseMindRequest();
request.setProjectId("project-case-minder-test"); request.setProjectId("project-case-minder-test");
request.setModuleId("TEST_MINDER_MODULE_ID_GYQ"); request.setModuleId("TEST_MINDER_MODULE_ID_GYQ");
request.setCurrent(1);
mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_LIST_URL, request); mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_LIST_URL, request);
contentAsString = mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8); tableData = JSON.parseObject(JSON.toJSONString(
resultHolder = JSON.parseObject(contentAsString, ResultHolder.class); JSON.parseObject(mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class).getData()),
Assertions.assertNotNull(resultHolder); Pager.class);
Assertions.assertNotNull(tableData);
FunctionalCaseBlob functionalCaseBlob = new FunctionalCaseBlob(); FunctionalCaseBlob functionalCaseBlob = new FunctionalCaseBlob();
functionalCaseBlob.setId("TEST_FUNCTIONAL_MINDER_CASE_ID_2"); functionalCaseBlob.setId("TEST_FUNCTIONAL_MINDER_CASE_ID_2");
functionalCaseBlob.setSteps(JSON.toJSONString(new ArrayList<>()).getBytes(StandardCharsets.UTF_8)); functionalCaseBlob.setSteps(JSON.toJSONString(new ArrayList<>()).getBytes(StandardCharsets.UTF_8));
@ -92,9 +94,10 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
functionalCaseBlob6.setDescription(StringUtils.EMPTY.getBytes(StandardCharsets.UTF_8)); functionalCaseBlob6.setDescription(StringUtils.EMPTY.getBytes(StandardCharsets.UTF_8));
functionalCaseBlobMapper.updateByPrimaryKeyWithBLOBs(functionalCaseBlob6); functionalCaseBlobMapper.updateByPrimaryKeyWithBLOBs(functionalCaseBlob6);
mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_LIST_URL, request); mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_LIST_URL, request);
contentAsString = mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8); tableData = JSON.parseObject(JSON.toJSONString(
resultHolder = JSON.parseObject(contentAsString, ResultHolder.class); JSON.parseObject(mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class).getData()),
Assertions.assertNotNull(resultHolder); Pager.class);
Assertions.assertNotNull(tableData);
List<FunctionalCaseStepDTO> list = new ArrayList<>(); List<FunctionalCaseStepDTO> list = new ArrayList<>();
FunctionalCaseStepDTO functionalCaseStepDTO = new FunctionalCaseStepDTO(); FunctionalCaseStepDTO functionalCaseStepDTO = new FunctionalCaseStepDTO();
functionalCaseStepDTO.setId("12455"); functionalCaseStepDTO.setId("12455");
@ -130,9 +133,11 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
functionalCaseBlob6.setDescription(description.getBytes(StandardCharsets.UTF_8)); functionalCaseBlob6.setDescription(description.getBytes(StandardCharsets.UTF_8));
functionalCaseBlobMapper.updateByPrimaryKeyWithBLOBs(functionalCaseBlob6); functionalCaseBlobMapper.updateByPrimaryKeyWithBLOBs(functionalCaseBlob6);
mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_LIST_URL, request); mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_LIST_URL, request);
contentAsString = mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8);
resultHolder = JSON.parseObject(contentAsString, ResultHolder.class); tableData = JSON.parseObject(JSON.toJSONString(
Assertions.assertNotNull(resultHolder); JSON.parseObject(mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class).getData()),
Pager.class);
Assertions.assertNotNull(tableData);
expectedResult = "文本描述的结果"; expectedResult = "文本描述的结果";
functionalCaseBlob = new FunctionalCaseBlob(); functionalCaseBlob = new FunctionalCaseBlob();
functionalCaseBlob.setId("TEST_FUNCTIONAL_MINDER_CASE_ID_2"); functionalCaseBlob.setId("TEST_FUNCTIONAL_MINDER_CASE_ID_2");
@ -145,11 +150,12 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_LIST_URL, request); mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_LIST_URL, request);
contentAsString = mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8); tableData = JSON.parseObject(JSON.toJSONString(
resultHolder = JSON.parseObject(contentAsString, ResultHolder.class); JSON.parseObject(mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class).getData()),
List<FunctionalMinderTreeDTO> baseTreeNodes = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), FunctionalMinderTreeDTO.class); Pager.class);
Assertions.assertNotNull(baseTreeNodes); Assertions.assertNotNull(tableData);
Assertions.assertEquals(2, baseTreeNodes.size()); Assertions.assertNotNull(tableData.getList());
Assertions.assertEquals(2, tableData.getList().size());
} }
@Test @Test
@ -330,6 +336,7 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
public void testGetCaseModuleNodeList() throws Exception { public void testGetCaseModuleNodeList() throws Exception {
FunctionalCaseMindRequest request = new FunctionalCaseMindRequest(); FunctionalCaseMindRequest request = new FunctionalCaseMindRequest();
request.setProjectId("project-case-minder-test"); request.setProjectId("project-case-minder-test");
request.setCurrent(1);
MvcResult mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_NODE_MODULE_URL, request); MvcResult mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_NODE_MODULE_URL, request);
String contentAsString = mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8); String contentAsString = mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8);
ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class); ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
@ -350,6 +357,7 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
request.setProjectId("project-case-minder-test"); request.setProjectId("project-case-minder-test");
request.setModuleId("TEST_MINDER_MODULE_ID_GYQ4"); request.setModuleId("TEST_MINDER_MODULE_ID_GYQ4");
request.setReviewId("TEST_MINDER_REVIEW_ID_GYQ"); request.setReviewId("TEST_MINDER_REVIEW_ID_GYQ");
request.setCurrent(1);
MvcResult mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_REVIEW_LIST_URL, request); MvcResult mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_REVIEW_LIST_URL, request);
String contentAsString = mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8); String contentAsString = mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8);
ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class); ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
@ -362,6 +370,7 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
request.setReviewId("TEST_MINDER_REVIEW_ID_GYQ2"); request.setReviewId("TEST_MINDER_REVIEW_ID_GYQ2");
request.setViewFlag(true); request.setViewFlag(true);
request.setViewStatusFlag(true); request.setViewStatusFlag(true);
request.setCurrent(1);
mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_REVIEW_LIST_URL, request); mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_REVIEW_LIST_URL, request);
contentAsString = mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8); contentAsString = mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8);
resultHolder = JSON.parseObject(contentAsString, ResultHolder.class); resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
@ -377,6 +386,7 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
request.setProjectId("project-case-minder-test"); request.setProjectId("project-case-minder-test");
request.setModuleId("TEST_MINDER_MODULE_ID_GYQ4"); request.setModuleId("TEST_MINDER_MODULE_ID_GYQ4");
request.setPlanId("TEST_MINDER_PLAN_ID_1"); request.setPlanId("TEST_MINDER_PLAN_ID_1");
request.setCurrent(1);
MvcResult mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_PLAN_LIST_URL, request); MvcResult mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_PLAN_LIST_URL, request);
String contentAsString = mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8); String contentAsString = mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8);
ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class); ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);