feat(用例管理): 用例评审脑图以及测试计划脑图增加用例字段的排序

This commit is contained in:
guoyuqi 2024-11-04 14:51:40 +08:00 committed by Craftsman
parent ddce1de3fd
commit bf765e6c51
5 changed files with 101 additions and 8 deletions

View File

@ -100,9 +100,9 @@ public interface ExtFunctionalCaseMapper {
/**
* 根据模块ID获取用例评审脑图展示数据
*/
List<FunctionalCaseMindDTO> getMinderCaseReviewList(@Param("request") FunctionalCaseReviewMindRequest request, @Param("deleted") boolean delete, @Param("userId") String userId, @Param("viewStatusUserId") String viewStatusUserId);
List<FunctionalCaseMindDTO> getMinderCaseReviewList(@Param("request") FunctionalCaseReviewMindRequest request, @Param("deleted") boolean delete, @Param("userId") String userId, @Param("viewStatusUserId") String viewStatusUserId, @Param("sort") String sort);
List<FunctionalCaseMindDTO> getMinderTestPlanList(@Param("request") FunctionalCasePlanMindRequest request, @Param("deleted") boolean delete);
List<FunctionalCaseMindDTO> getMinderTestPlanList(@Param("request") FunctionalCasePlanMindRequest request, @Param("deleted") boolean delete, @Param("sort") String sort);
List<FunctionalCaseMindDTO> getMinderCollectionList(@Param("request") FunctionalCaseCollectionMindRequest request, @Param("deleted") boolean delete);

View File

@ -760,6 +760,13 @@
fc.project_Id = #{request.projectId}
AND
fc.module_id = #{request.moduleId}
order by
<if test="sort != null and sort != ''">
fc.${sort}
</if>
<if test="sort == null or sort == ''">
fc.pos desc
</if>
</select>
<select id="getMinderTestPlanList" resultType="io.metersphere.functional.dto.FunctionalCaseMindDTO">
@ -788,6 +795,13 @@
fc.project_Id = #{request.projectId}
AND
fc.module_id = #{request.moduleId}
order by
<if test="sort != null and sort != ''">
fc.${sort}
</if>
<if test="sort == null or sort == ''">
fc.pos desc
</if>
</select>
<select id="getMinderCollectionList" resultType="io.metersphere.functional.dto.FunctionalCaseMindDTO">

View File

@ -1,9 +1,15 @@
package io.metersphere.functional.request;
import com.google.common.base.CaseFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import java.util.Map;
@Data
public class FunctionalCaseMindRequest {
@ -17,4 +23,65 @@ public class FunctionalCaseMindRequest {
@Min(value = 1, message = "当前页码必须大于0")
@Schema(description = "当前页码")
private int current;
@Schema(description = "排序字段model中的字段 : asc/desc")
private Map<@Valid @Pattern(regexp = "^[A-Za-z]+$") String, @Valid @NotBlank String> sort;
public String getSortString() {
if (sort == null || sort.isEmpty()) {
return null;
}
StringBuilder sb = new StringBuilder();
for (Map.Entry<String, String> entry : sort.entrySet()) {
String column = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, entry.getKey());
sb.append(column)
.append(StringUtils.SPACE)
.append(StringUtils.equalsIgnoreCase(entry.getValue(), "DESC") ? "DESC" : "ASC")
.append(",");
}
return sb.substring(0, sb.length() - 1);
}
public String getSortString(String defaultColumn, String tableAliseName) {
if (sort == null || sort.isEmpty()) {
return null;
}
StringBuilder sb = new StringBuilder();
for (Map.Entry<String, String> entry : sort.entrySet()) {
String column = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, entry.getKey());
sb.append(tableAliseName)
.append(".")
.append(column)
.append(StringUtils.SPACE)
.append(StringUtils.equalsIgnoreCase(entry.getValue(), "DESC") ? "DESC" : "ASC")
.append(",")
.append(tableAliseName)
.append(".")
.append(defaultColumn)
.append(StringUtils.SPACE)
.append(StringUtils.equalsIgnoreCase(entry.getValue(), "DESC") ? "DESC" : "ASC");
return sb.toString();
}
return null;
}
public String getSortString(String defaultColumn) {
if (sort == null || sort.isEmpty()) {
return null;
}
StringBuilder sb = new StringBuilder();
for (Map.Entry<String, String> entry : sort.entrySet()) {
String column = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, entry.getKey());
sb.append(column)
.append(StringUtils.SPACE)
.append(StringUtils.equalsIgnoreCase(entry.getValue(), "DESC") ? "DESC" : "ASC")
.append(",")
.append(defaultColumn)
.append(StringUtils.SPACE)
.append(StringUtils.equalsIgnoreCase(entry.getValue(), "DESC") ? "DESC" : "ASC");
return sb.toString();
}
return null;
}
}

View File

@ -1262,7 +1262,7 @@ 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);
List<FunctionalCaseMindDTO> functionalCaseMindDTOList = extFunctionalCaseMapper.getMinderCaseReviewList(request, deleted, userId, viewStatusUserId, request.getSortString());
List<String> fieldIds = getFieldIds(request.getProjectId());
List<FunctionalCaseCustomField> caseCustomFieldList = extFunctionalCaseMapper.getCaseCustomFieldList(request, deleted, fieldIds);
Map<String, String> priorityMap = caseCustomFieldList.stream().collect(Collectors.toMap(FunctionalCaseCustomField::getCaseId, FunctionalCaseCustomField::getValue));
@ -1279,7 +1279,7 @@ public class FunctionalCaseMinderService {
String substring = request.getModuleId().substring(i + 1);
request.setModuleId(substring);
}
List<FunctionalCaseMindDTO> functionalCaseMindDTOList = extFunctionalCaseMapper.getMinderTestPlanList(request, deleted);
List<FunctionalCaseMindDTO> functionalCaseMindDTOList = extFunctionalCaseMapper.getMinderTestPlanList(request, deleted, request.getSortString());
List<String> fieldIds = getFieldIds(request.getProjectId());
List<FunctionalCaseCustomField> caseCustomFieldList = extFunctionalCaseMapper.getCaseCustomFieldList(request, deleted, fieldIds);
Map<String, String> priorityMap = caseCustomFieldList.stream().collect(Collectors.toMap(FunctionalCaseCustomField::getCaseId, FunctionalCaseCustomField::getValue));

View File

@ -1,7 +1,10 @@
package io.metersphere.functional.controller;
import io.metersphere.functional.domain.*;
import io.metersphere.functional.dto.*;
import io.metersphere.functional.dto.CaseCustomFieldDTO;
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.request.*;
import io.metersphere.plan.domain.TestPlanCaseExecuteHistory;
@ -28,9 +31,7 @@ import org.springframework.test.context.jdbc.SqlConfig;
import org.springframework.test.web.servlet.MvcResult;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@ -82,7 +83,12 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
FunctionalCaseMindRequest request = new FunctionalCaseMindRequest();
request.setProjectId("project-case-minder-test");
request.setCurrent(1);
Map<String,String>sort = new HashMap<>();
sort.put("name","desc");
request.setSort(sort);
MvcResult mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_LIST_URL, request);
request.getSortString("name", "desc");
request.getSortString("name");
Pager<List<FunctionalMinderTreeDTO>> tableData = JSON.parseObject(JSON.toJSONString(
JSON.parseObject(mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class).getData()),
Pager.class);
@ -397,6 +403,9 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
request.setModuleId("TEST_MINDER_MODULE_ID_GYQ4");
request.setReviewId("TEST_MINDER_REVIEW_ID_GYQ");
request.setCurrent(1);
Map<String,String> map = new HashMap<>();
map.put("name", "desc");
request.setSort(map);
MvcResult mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_REVIEW_LIST_URL, request);
Pager<List<FunctionalMinderTreeDTO>> tableData = JSON.parseObject(JSON.toJSONString(
JSON.parseObject(mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class).getData()),
@ -428,6 +437,9 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
request.setModuleId("TEST_MINDER_MODULE_ID_GYQ4");
request.setPlanId("TEST_MINDER_PLAN_ID_1");
request.setCurrent(1);
Map<String,String> map = new HashMap<>();
map.put("name", "desc");
request.setSort(map);
TestPlanCaseExecuteHistory executeHistory = new TestPlanCaseExecuteHistory();
String nextStr = IDGenerator.nextStr();
executeHistory.setId(nextStr);