feat(用例管理): 增加用例评审脑图获取接口

This commit is contained in:
guoyuqi 2024-05-15 14:36:33 +08:00 committed by 刘瑞斌
parent 1be59b0f50
commit e0333a661d
7 changed files with 93 additions and 41 deletions

View File

@ -1,10 +1,12 @@
package io.metersphere.functional.controller;
import com.alibaba.excel.util.StringUtils;
import io.metersphere.functional.dto.FunctionalMinderTreeDTO;
import io.metersphere.functional.dto.MinderOptionDTO;
import io.metersphere.functional.request.FunctionalCaseMindRequest;
import io.metersphere.functional.request.FunctionalCaseMinderEditRequest;
import io.metersphere.functional.request.FunctionalCaseMinderRemoveRequest;
import io.metersphere.functional.request.FunctionalCaseReviewMindRequest;
import io.metersphere.functional.service.FunctionalCaseLogService;
import io.metersphere.functional.service.FunctionalCaseMinderService;
import io.metersphere.functional.service.FunctionalCaseNoticeService;
@ -39,7 +41,7 @@ public class FunctionalCaseMinderController {
@PostMapping("/list")
@Operation(summary = "用例管理-功能用例-脑图用例跟根据模块ID查询列表")
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ_MINDER)
@CheckOwner(resourceId = "#projectId()", resourceType = "project")
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
public List<FunctionalMinderTreeDTO> getFunctionalCaseMinderTree(@Validated @RequestBody FunctionalCaseMindRequest request) {
return functionalCaseMinderService.getMindFunctionalCase(request, false);
}
@ -83,4 +85,21 @@ public class FunctionalCaseMinderController {
functionalCaseMinderService.deleteFunctionalCaseBatch(projectId, resourceList, userId);
}
@PostMapping("/review/list")
@Operation(summary = "用例管理-功能用例-脑图用例跟根据模块ID查询列表")
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ_MINDER)
@CheckOwner(resourceId = "#request.getReviewId()", resourceType = "case_review")
public List<FunctionalMinderTreeDTO> getReviewMindFunctionalCase(@Validated @RequestBody FunctionalCaseReviewMindRequest request) {
String userId = StringUtils.EMPTY;
if (request.isViewFlag()) {
userId = SessionUtils.getUserId();
}
String viewStatusUserId = StringUtils.EMPTY;
if (request.isViewStatusFlag()) {
viewStatusUserId = SessionUtils.getUserId();
}
return functionalCaseMinderService.getReviewMindFunctionalCase(request, false, userId, viewStatusUserId);
}
}

View File

@ -1,12 +0,0 @@
package io.metersphere.functional.dto;
import io.swagger.v3.oas.annotations.media.Schema;
public class FunctionalCaseReviewMindDTO extends FunctionalCaseMindDTO{
@Schema(description = "用例评审ID--用例评审脑图")
private String reviewId;
@Schema(description = "功能用例ID--用例评审脑图")
private String caseId;
}

View File

@ -2,10 +2,7 @@ package io.metersphere.functional.mapper;
import io.metersphere.dto.TestCaseProviderDTO;
import io.metersphere.functional.domain.FunctionalCase;
import io.metersphere.functional.dto.BaseFunctionalCaseBatchDTO;
import io.metersphere.functional.dto.FunctionalCaseMindDTO;
import io.metersphere.functional.dto.FunctionalCasePageDTO;
import io.metersphere.functional.dto.FunctionalCaseVersionDTO;
import io.metersphere.functional.dto.*;
import io.metersphere.functional.request.FunctionalCaseBatchMoveRequest;
import io.metersphere.functional.request.FunctionalCaseMindRequest;
import io.metersphere.functional.request.FunctionalCasePageRequest;
@ -91,6 +88,6 @@ public interface ExtFunctionalCaseMapper {
/**
* 根据模块ID获取用例评审脑图展示数据
*/
List<FunctionalCaseMindDTO> getMinderCaseReviewList(@Param("request") FunctionalCaseReviewMindRequest request, @Param("deleted") boolean delete, @Param("userId") String userId, @Param("viewStatusUserId") boolean viewStatusUserId);
List<FunctionalCaseMindDTO> getMinderCaseReviewList(@Param("request") FunctionalCaseReviewMindRequest request, @Param("deleted") boolean delete, @Param("userId") String userId, @Param("viewStatusUserId") String viewStatusUserId);
}

View File

@ -806,11 +806,9 @@
AND cf.internal= true
</select>
<select id="getMinderCaseReviewList" resultType="io.metersphere.functional.dto.FunctionalCaseReviewMindDTO">
<select id="getMinderCaseReviewList" resultType="io.metersphere.functional.dto.FunctionalCaseMindDTO">
SELECT
crfc.id as id,
crfc.review_id as reviewId,
crfc.case_id as caseId,
crfc.case_id as id,
history.`status` as status,
fc.module_id as moduleId,
fc.name as name,
@ -827,7 +825,7 @@
</if>
order by crh.create_time desc limit 1 ) as history ON history.case_id = crfc.case_id
WHERE
review_id = #{request.reviewId}
crfc.review_id = #{request.reviewId}
AND fc.deleted = #{deleted}
<if test="userId != null and userId != ''">
AND crfc.case_id in (select crfcu.case_id from case_review_functional_case_user crfcu where crfcu.review_id = #{request.reviewId} and crfcu.user_id = #{userId})

View File

@ -4,10 +4,7 @@ import io.metersphere.functional.constants.FunctionalCaseTypeConstants;
import io.metersphere.functional.domain.*;
import io.metersphere.functional.dto.*;
import io.metersphere.functional.mapper.*;
import io.metersphere.functional.request.FunctionalCaseBatchMoveRequest;
import io.metersphere.functional.request.FunctionalCaseMindRequest;
import io.metersphere.functional.request.FunctionalCaseMinderEditRequest;
import io.metersphere.functional.request.FunctionalCaseMinderRemoveRequest;
import io.metersphere.functional.request.*;
import io.metersphere.sdk.exception.MSException;
import io.metersphere.sdk.util.JSON;
import io.metersphere.sdk.util.Translator;
@ -102,20 +99,7 @@ public class FunctionalCaseMinderService {
//查出当前模块下的所有用例
List<FunctionalCaseMindDTO> functionalCaseMindDTOList = extFunctionalCaseMapper.getMinderCaseList(request, deleted);
//构造父子级数据
for (FunctionalCaseMindDTO functionalCaseMindDTO : functionalCaseMindDTOList) {
FunctionalMinderTreeDTO root = new FunctionalMinderTreeDTO();
FunctionalMinderTreeNodeDTO rootData = new FunctionalMinderTreeNodeDTO();
rootData.setId(functionalCaseMindDTO.getId());
rootData.setPos(functionalCaseMindDTO.getPos());
rootData.setText(functionalCaseMindDTO.getName());
rootData.setPriority(functionalCaseMindDTO.getPriority());
rootData.setStatus(functionalCaseMindDTO.getReviewStatus());
rootData.setResource(List.of(Translator.get("minder_extra_node.case")));
List<FunctionalMinderTreeDTO> children = buildChildren(functionalCaseMindDTO);
root.setChildren(children);
root.setData(rootData);
list.add(root);
}
buildList(functionalCaseMindDTOList, list);
return list;
}
@ -479,4 +463,34 @@ public class FunctionalCaseMinderService {
}
}
public List<FunctionalMinderTreeDTO> getReviewMindFunctionalCase(FunctionalCaseReviewMindRequest request, boolean deleted, String userId, String viewStatusUserId) {
List<FunctionalMinderTreeDTO> list = new ArrayList<>();
//查出当前模块下的所有用例
List<FunctionalCaseMindDTO> functionalCaseMindDTOList = extFunctionalCaseMapper.getMinderCaseReviewList(request, deleted, userId, viewStatusUserId);
//构造父子级数据
buildList(functionalCaseMindDTOList, list);
return list;
}
private void buildList(List<FunctionalCaseMindDTO> functionalCaseMindDTOList, List<FunctionalMinderTreeDTO> list) {
//构造父子级数据
for (FunctionalCaseMindDTO functionalCaseMindDTO : functionalCaseMindDTOList) {
FunctionalMinderTreeDTO root = new FunctionalMinderTreeDTO();
FunctionalMinderTreeNodeDTO rootData = new FunctionalMinderTreeNodeDTO();
rootData.setId(functionalCaseMindDTO.getId());
rootData.setPos(functionalCaseMindDTO.getPos());
rootData.setText(functionalCaseMindDTO.getName());
rootData.setPriority(functionalCaseMindDTO.getPriority());
rootData.setStatus(functionalCaseMindDTO.getReviewStatus());
rootData.setResource(List.of(Translator.get("minder_extra_node.case")));
List<FunctionalMinderTreeDTO> children = buildChildren(functionalCaseMindDTO);
root.setChildren(children);
root.setData(rootData);
list.add(root);
}
}
}

View File

@ -12,6 +12,7 @@ import io.metersphere.functional.mapper.FunctionalCaseModuleMapper;
import io.metersphere.functional.request.FunctionalCaseMindRequest;
import io.metersphere.functional.request.FunctionalCaseMinderEditRequest;
import io.metersphere.functional.request.FunctionalCaseMinderRemoveRequest;
import io.metersphere.functional.request.FunctionalCaseReviewMindRequest;
import io.metersphere.sdk.util.JSON;
import io.metersphere.sdk.util.Translator;
import io.metersphere.system.base.BaseTest;
@ -46,6 +47,10 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
public static final String FUNCTIONAL_CASE_BATCH_MOVE = "/functional/mind/case/batch/remove";
//评审
public static final String FUNCTIONAL_CASE_REVIEW_LIST_URL = "/functional/mind/case/review/list";
@Resource
@ -302,7 +307,37 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
resourceList.add(optionDTOModule);
functionalCaseMinderRemoveRequest.setResourceList(resourceList);
this.requestPost(FUNCTIONAL_CASE_BATCH_MOVE, functionalCaseMinderRemoveRequest).andExpect(status().is5xxServerError());
}
@Test
@Order(5)
public void testGetCaseReviewList() throws Exception {
FunctionalCaseReviewMindRequest request = new FunctionalCaseReviewMindRequest();
request.setProjectId("project-case-minder-test");
request.setModuleId("TEST_MINDER_MODULE_ID_GYQ4");
request.setReviewId("TEST_MINDER_REVIEW_ID_GYQ");
MvcResult mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_REVIEW_LIST_URL, request);
String contentAsString = mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8);
ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
List<FunctionalMinderTreeDTO> baseTreeNodes = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), FunctionalMinderTreeDTO.class);
Assertions.assertNotNull(baseTreeNodes);
String jsonString = JSON.toJSONString(baseTreeNodes);
System.out.println(jsonString);
Assertions.assertEquals(1, baseTreeNodes.size());
request = new FunctionalCaseReviewMindRequest();
request.setProjectId("project-case-minder-test");
request.setModuleId("TEST_MINDER_MODULE_ID_GYQ4");
request.setReviewId("TEST_MINDER_REVIEW_ID_GYQ2");
request.setViewFlag(true);
request.setViewStatusFlag(true);
mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_REVIEW_LIST_URL, request);
contentAsString = mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8);
resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
baseTreeNodes = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), FunctionalMinderTreeDTO.class);
Assertions.assertNotNull(baseTreeNodes);
jsonString = JSON.toJSONString(baseTreeNodes);
System.out.println(jsonString);
Assertions.assertEquals(1, baseTreeNodes.size());
}

View File

@ -27,6 +27,7 @@ INSERT INTO functional_case_blob(id, steps, text_description, expected_result, p
INSERT INTO functional_case_custom_field(case_id, field_id, value) VALUES ('TEST_FUNCTIONAL_MINDER_CASE_ID_1', 'custom_field_minder_gyq_id_3', 'P0');
INSERT INTO functional_case_custom_field(case_id, field_id, value) VALUES ('TEST_FUNCTIONAL_MINDER_CASE_ID_2', 'custom_field_minder_gyq_id_3', 'P3');
INSERT INTO functional_case_custom_field(case_id, field_id, value) VALUES ('TEST_FUNCTIONAL_MINDER_CASE_ID_5', 'custom_field_minder_gyq_id_3', 'P3');
INSERT INTO functional_case_custom_field(case_id, field_id, value) VALUES ('TEST_FUNCTIONAL_MINDER_CASE_ID_6', 'custom_field_minder_gyq_id_3', 'P2');