refactor(测试计划): 优化规划视图下列表返回模块名称
This commit is contained in:
parent
a020a8e595
commit
3872d84dea
|
@ -1,5 +1,6 @@
|
|||
package io.metersphere.functional.mapper;
|
||||
|
||||
import io.metersphere.functional.domain.FunctionalCaseModule;
|
||||
import io.metersphere.functional.dto.FunctionalCaseModuleDTO;
|
||||
import io.metersphere.functional.dto.ProjectOptionDTO;
|
||||
import io.metersphere.project.dto.NodeSortQueryParam;
|
||||
|
@ -38,4 +39,6 @@ public interface ExtFunctionalCaseModuleMapper {
|
|||
List<String> selectIdByProjectIdAndReviewId(@Param("projectId")String projectId, @Param("reviewId")String reviewId);
|
||||
|
||||
void batchUpdateStringColumn(@Param("column") String column, @Param("ids") List<String> ids, @Param("value") String value);
|
||||
|
||||
List<FunctionalCaseModule> getNameInfoByIds(@Param("ids") List<String> ids);
|
||||
}
|
||||
|
|
|
@ -136,4 +136,13 @@
|
|||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<select id="getNameInfoByIds" resultType="io.metersphere.functional.domain.FunctionalCaseModule">
|
||||
SELECT id, name
|
||||
FROM functional_case_module
|
||||
WHERE id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
|
@ -39,6 +39,9 @@ public class TestPlanApiCasePageResponse implements Serializable {
|
|||
@Schema(description = "模块ID")
|
||||
private String moduleId;
|
||||
|
||||
@Schema(description = "模块名称")
|
||||
private String moduleName;
|
||||
|
||||
@Schema(description = "环境fk")
|
||||
private String environmentId;
|
||||
|
||||
|
|
|
@ -35,6 +35,9 @@ public class TestPlanApiScenarioPageResponse implements Serializable {
|
|||
@Schema(description = "模块ID")
|
||||
private String moduleId;
|
||||
|
||||
@Schema(description = "模块名称")
|
||||
private String moduleName;
|
||||
|
||||
@Schema(description = "环境fk")
|
||||
private String environmentId;
|
||||
|
||||
|
|
|
@ -26,6 +26,9 @@ public class TestPlanCasePageResponse implements Serializable {
|
|||
@Schema(description = "模块ID")
|
||||
private String moduleId;
|
||||
|
||||
@Schema(description = "模块名称")
|
||||
private String moduleName;
|
||||
|
||||
@Schema(description = "项目ID")
|
||||
private String projectId;
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import io.metersphere.api.dto.definition.ApiDefinitionDTO;
|
|||
import io.metersphere.api.dto.definition.ApiTestCaseDTO;
|
||||
import io.metersphere.api.mapper.ApiReportMapper;
|
||||
import io.metersphere.api.mapper.ApiTestCaseMapper;
|
||||
import io.metersphere.api.mapper.ExtApiDefinitionModuleMapper;
|
||||
import io.metersphere.api.service.ApiBatchRunBaseService;
|
||||
import io.metersphere.api.service.ApiExecuteService;
|
||||
import io.metersphere.api.service.definition.ApiDefinitionModuleService;
|
||||
|
@ -19,7 +20,6 @@ import io.metersphere.plan.domain.*;
|
|||
import io.metersphere.plan.dto.*;
|
||||
import io.metersphere.plan.dto.request.*;
|
||||
import io.metersphere.plan.dto.response.TestPlanApiCasePageResponse;
|
||||
import io.metersphere.plan.dto.response.TestPlanApiScenarioPageResponse;
|
||||
import io.metersphere.plan.dto.response.TestPlanAssociationResponse;
|
||||
import io.metersphere.plan.dto.response.TestPlanOperationResponse;
|
||||
import io.metersphere.plan.mapper.*;
|
||||
|
@ -116,6 +116,8 @@ public class TestPlanApiCaseService extends TestPlanResourceService {
|
|||
private ApiReportMapper apiReportMapper;
|
||||
@Resource
|
||||
private OperationLogService operationLogService;
|
||||
@Resource
|
||||
private ExtApiDefinitionModuleMapper extApiDefinitionModuleMapper;
|
||||
|
||||
@Override
|
||||
public void deleteBatchByTestPlanId(List<String> testPlanIdList) {
|
||||
|
@ -233,11 +235,20 @@ public class TestPlanApiCaseService extends TestPlanResourceService {
|
|||
if (CollectionUtils.isNotEmpty(apiCaseList)) {
|
||||
Map<String, String> projectMap = getProject(apiCaseList);
|
||||
Map<String, String> userMap = getUserMap(apiCaseList);
|
||||
handleCaseAndEnv(apiCaseList, projectMap, userMap, testPlanId);
|
||||
Map<String, String> moduleNameMap = getModuleName(apiCaseList);
|
||||
handleCaseAndEnv(apiCaseList, projectMap, userMap, testPlanId, moduleNameMap);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleCaseAndEnv(List<TestPlanApiCasePageResponse> apiCaseList, Map<String, String> projectMap, Map<String, String> userMap, String testPlanId) {
|
||||
private Map<String, String> getModuleName(List<TestPlanApiCasePageResponse> apiCaseList) {
|
||||
List<String> moduleIds = apiCaseList.stream().map(TestPlanApiCasePageResponse::getModuleId).toList();
|
||||
List<ApiDefinitionModule> modules = extApiDefinitionModuleMapper.getNameInfoByIds(moduleIds);
|
||||
Map<String, String> moduleNameMap = modules.stream()
|
||||
.collect(Collectors.toMap(ApiDefinitionModule::getId, ApiDefinitionModule::getName));
|
||||
return moduleNameMap;
|
||||
}
|
||||
|
||||
private void handleCaseAndEnv(List<TestPlanApiCasePageResponse> apiCaseList, Map<String, String> projectMap, Map<String, String> userMap, String testPlanId, Map<String, String> moduleNameMap) {
|
||||
//获取二级节点环境
|
||||
List<TestPlanCollectionEnvDTO> secondEnv = extTestPlanCollectionMapper.selectSecondCollectionEnv(CaseType.API_CASE.getKey(), ModuleConstants.ROOT_NODE_PARENT_ID, testPlanId);
|
||||
Map<String, TestPlanCollectionEnvDTO> secondEnvMap = secondEnv.stream().collect(Collectors.toMap(TestPlanCollectionEnvDTO::getId, item -> item));
|
||||
|
@ -253,6 +264,7 @@ public class TestPlanApiCaseService extends TestPlanResourceService {
|
|||
item.setProjectName(projectMap.get(item.getProjectId()));
|
||||
item.setCreateUserName(userMap.get(item.getCreateUser()));
|
||||
item.setExecuteUserName(userMap.get(item.getExecuteUser()));
|
||||
item.setModuleName(moduleNameMap.get(item.getModuleId()));
|
||||
if (secondEnvMap.containsKey(item.getTestPlanCollectionId())) {
|
||||
TestPlanCollectionEnvDTO collectEnv = secondEnvMap.get(item.getTestPlanCollectionId());
|
||||
if (collectEnv.getExtended()) {
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
package io.metersphere.plan.service;
|
||||
|
||||
import io.metersphere.api.domain.ApiScenario;
|
||||
import io.metersphere.api.domain.ApiScenarioExample;
|
||||
import io.metersphere.api.domain.ApiScenarioReport;
|
||||
import io.metersphere.api.domain.ApiScenarioReportExample;
|
||||
import io.metersphere.api.domain.*;
|
||||
import io.metersphere.api.dto.scenario.ApiScenarioDTO;
|
||||
import io.metersphere.api.dto.scenario.ApiScenarioDetail;
|
||||
import io.metersphere.api.mapper.ApiScenarioMapper;
|
||||
import io.metersphere.api.mapper.ApiScenarioModuleMapper;
|
||||
import io.metersphere.api.mapper.ApiScenarioReportMapper;
|
||||
import io.metersphere.api.service.ApiBatchRunBaseService;
|
||||
import io.metersphere.api.service.ApiExecuteService;
|
||||
|
@ -109,6 +107,8 @@ public class TestPlanApiScenarioService extends TestPlanResourceService {
|
|||
private ApiScenarioReportMapper apiScenarioReportMapper;
|
||||
@Resource
|
||||
private ApiScenarioMapper apiScenarioMapper;
|
||||
@Resource
|
||||
private ApiScenarioModuleMapper apiScenarioModuleMapper;
|
||||
|
||||
@Override
|
||||
public void deleteBatchByTestPlanId(List<String> testPlanIdList) {
|
||||
|
@ -367,11 +367,21 @@ public class TestPlanApiScenarioService extends TestPlanResourceService {
|
|||
if (CollectionUtils.isNotEmpty(apiScenarioList)) {
|
||||
Map<String, String> projectMap = getProject(apiScenarioList);
|
||||
Map<String, String> userMap = getUserMap(apiScenarioList);
|
||||
handleScenarioAndEnv(apiScenarioList, projectMap, userMap, testPlanId);
|
||||
Map<String, String> moduleNameMap = getModuleName(apiScenarioList);
|
||||
handleScenarioAndEnv(apiScenarioList, projectMap, userMap, testPlanId, moduleNameMap);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleScenarioAndEnv(List<TestPlanApiScenarioPageResponse> apiScenarioList, Map<String, String> projectMap, Map<String, String> userMap, String testPlanId) {
|
||||
private Map<String, String> getModuleName(List<TestPlanApiScenarioPageResponse> apiScenarioList) {
|
||||
List<String> moduleIds = apiScenarioList.stream().map(TestPlanApiScenarioPageResponse::getModuleId).distinct().toList();
|
||||
ApiScenarioModuleExample moduleExample = new ApiScenarioModuleExample();
|
||||
moduleExample.createCriteria().andIdIn(moduleIds);
|
||||
List<ApiScenarioModule> modules = apiScenarioModuleMapper.selectByExample(moduleExample);
|
||||
Map<String, String> moduleNameMap = modules.stream().collect(Collectors.toMap(ApiScenarioModule::getId, ApiScenarioModule::getName));
|
||||
return moduleNameMap;
|
||||
}
|
||||
|
||||
private void handleScenarioAndEnv(List<TestPlanApiScenarioPageResponse> apiScenarioList, Map<String, String> projectMap, Map<String, String> userMap, String testPlanId, Map<String, String> moduleNameMap) {
|
||||
//获取二级节点环境
|
||||
List<TestPlanCollectionEnvDTO> secondEnv = extTestPlanCollectionMapper.selectSecondCollectionEnv(CaseType.SCENARIO_CASE.getKey(), ModuleConstants.ROOT_NODE_PARENT_ID, testPlanId);
|
||||
Map<String, TestPlanCollectionEnvDTO> secondEnvMap = secondEnv.stream().collect(Collectors.toMap(TestPlanCollectionEnvDTO::getId, item -> item));
|
||||
|
@ -387,6 +397,7 @@ public class TestPlanApiScenarioService extends TestPlanResourceService {
|
|||
item.setProjectName(projectMap.get(item.getProjectId()));
|
||||
item.setCreateUserName(userMap.get(item.getCreateUser()));
|
||||
item.setExecuteUserName(userMap.get(item.getExecuteUser()));
|
||||
item.setModuleName(StringUtils.isNotBlank(moduleNameMap.get(item.getModuleId())) ? moduleNameMap.get(item.getModuleId()) : Translator.get("api_unplanned_scenario"));
|
||||
if (secondEnvMap.containsKey(item.getTestPlanCollectionId())) {
|
||||
TestPlanCollectionEnvDTO collectEnv = secondEnvMap.get(item.getTestPlanCollectionId());
|
||||
if (collectEnv.getExtended()) {
|
||||
|
|
|
@ -14,6 +14,7 @@ import io.metersphere.functional.domain.FunctionalCase;
|
|||
import io.metersphere.functional.domain.FunctionalCaseExample;
|
||||
import io.metersphere.functional.domain.FunctionalCaseModule;
|
||||
import io.metersphere.functional.dto.*;
|
||||
import io.metersphere.functional.mapper.ExtFunctionalCaseModuleMapper;
|
||||
import io.metersphere.functional.mapper.FunctionalCaseMapper;
|
||||
import io.metersphere.functional.service.FunctionalCaseAttachmentService;
|
||||
import io.metersphere.functional.service.FunctionalCaseModuleService;
|
||||
|
@ -121,6 +122,8 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
|
|||
private FunctionalCaseMapper functionalCaseMapper;
|
||||
@Resource
|
||||
private OperationLogService operationLogService;
|
||||
@Resource
|
||||
private ExtFunctionalCaseModuleMapper extFunctionalCaseModuleMapper;
|
||||
|
||||
@Override
|
||||
public long copyResource(String originalTestPlanId, String newTestPlanId, String operator, long operatorTime) {
|
||||
|
@ -242,10 +245,14 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
|
|||
List<SelectOption> statusOption = bugStatusService.getHeaderStatusOption(projectId);
|
||||
Map<String, String> statusMap = statusOption.stream().collect(Collectors.toMap(SelectOption::getValue, SelectOption::getText));
|
||||
Map<String, String> userMap = userLoginService.getUserNameMap(new ArrayList<>(userIds));
|
||||
List<String> moduleIds = functionalCaseLists.stream().map(TestPlanCasePageResponse::getModuleId).toList();
|
||||
List<FunctionalCaseModule> modules = extFunctionalCaseModuleMapper.getNameInfoByIds(moduleIds);
|
||||
Map<String, String> moduleNameMap = modules.stream().collect(Collectors.toMap(FunctionalCaseModule::getId, FunctionalCaseModule::getName));
|
||||
functionalCaseLists.forEach(testPlanCasePageResponse -> {
|
||||
testPlanCasePageResponse.setCustomFields(collect.get(testPlanCasePageResponse.getCaseId()));
|
||||
testPlanCasePageResponse.setCreateUserName(userMap.get(testPlanCasePageResponse.getCreateUser()));
|
||||
testPlanCasePageResponse.setExecuteUserName(userMap.get(testPlanCasePageResponse.getExecuteUser()));
|
||||
testPlanCasePageResponse.setModuleName(moduleNameMap.get(testPlanCasePageResponse.getModuleId()));
|
||||
if (bugListMap.containsKey(testPlanCasePageResponse.getCaseId())) {
|
||||
List<CaseRelateBugDTO> bugDTOList = bugListMap.get(testPlanCasePageResponse.getCaseId());
|
||||
testPlanCasePageResponse.setBugList(handleStatus(bugDTOList, statusMap));
|
||||
|
|
Loading…
Reference in New Issue