refactor(用例管理): 优化用例详情查询代码
This commit is contained in:
parent
6476aa3a16
commit
6619efe9a3
|
@ -173,6 +173,9 @@ ALTER TABLE test_plan DROP INDEX uq_name_project;
|
||||||
CREATE INDEX idx_report_id ON api_scenario_report_step(report_id);
|
CREATE INDEX idx_report_id ON api_scenario_report_step(report_id);
|
||||||
|
|
||||||
|
|
||||||
|
CREATE INDEX idx_source_id ON operation_history(`source_id`);
|
||||||
|
|
||||||
|
|
||||||
-- set innodb lock wait timeout to default
|
-- set innodb lock wait timeout to default
|
||||||
SET SESSION innodb_lock_wait_timeout = DEFAULT;
|
SET SESSION innodb_lock_wait_timeout = DEFAULT;
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ public class FunctionalCaseController {
|
||||||
@CheckOwner(resourceId = "#id", resourceType = "functional_case")
|
@CheckOwner(resourceId = "#id", resourceType = "functional_case")
|
||||||
public FunctionalCaseDetailDTO getFunctionalCaseDetail(@PathVariable String id) {
|
public FunctionalCaseDetailDTO getFunctionalCaseDetail(@PathVariable String id) {
|
||||||
String userId = SessionUtils.getUserId();
|
String userId = SessionUtils.getUserId();
|
||||||
return functionalCaseService.getFunctionalCaseDetail(id, userId);
|
return functionalCaseService.getFunctionalCaseDetail(id, userId, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -339,7 +339,7 @@ public class FunctionalCaseService {
|
||||||
* @param functionalCaseId functionalCaseId
|
* @param functionalCaseId functionalCaseId
|
||||||
* @return FunctionalCaseDetailDTO
|
* @return FunctionalCaseDetailDTO
|
||||||
*/
|
*/
|
||||||
public FunctionalCaseDetailDTO getFunctionalCaseDetail(String functionalCaseId, String userId) {
|
public FunctionalCaseDetailDTO getFunctionalCaseDetail(String functionalCaseId, String userId, boolean checkDetailCount) {
|
||||||
FunctionalCase functionalCase = checkFunctionalCase(functionalCaseId);
|
FunctionalCase functionalCase = checkFunctionalCase(functionalCaseId);
|
||||||
FunctionalCaseDetailDTO functionalCaseDetailDTO = new FunctionalCaseDetailDTO();
|
FunctionalCaseDetailDTO functionalCaseDetailDTO = new FunctionalCaseDetailDTO();
|
||||||
BeanUtils.copyBean(functionalCaseDetailDTO, functionalCase);
|
BeanUtils.copyBean(functionalCaseDetailDTO, functionalCase);
|
||||||
|
@ -369,9 +369,10 @@ public class FunctionalCaseService {
|
||||||
//模块名称
|
//模块名称
|
||||||
handDTO(functionalCaseDetailDTO);
|
handDTO(functionalCaseDetailDTO);
|
||||||
|
|
||||||
|
if (checkDetailCount) {
|
||||||
//处理已关联需求数量/缺陷数量/用例数量
|
//处理已关联需求数量/缺陷数量/用例数量
|
||||||
handleCount(functionalCaseDetailDTO);
|
handleCount(functionalCaseDetailDTO);
|
||||||
|
}
|
||||||
|
|
||||||
return functionalCaseDetailDTO;
|
return functionalCaseDetailDTO;
|
||||||
|
|
||||||
|
@ -442,8 +443,7 @@ public class FunctionalCaseService {
|
||||||
//获取变更历史数量数量
|
//获取变更历史数量数量
|
||||||
OperationHistoryExample operationHistoryExample = new OperationHistoryExample();
|
OperationHistoryExample operationHistoryExample = new OperationHistoryExample();
|
||||||
List<String> types = List.of(OperationLogType.ADD.name(), OperationLogType.IMPORT.name(), OperationLogType.UPDATE.name());
|
List<String> types = List.of(OperationLogType.ADD.name(), OperationLogType.IMPORT.name(), OperationLogType.UPDATE.name());
|
||||||
List<String> modules = List.of(OperationLogModule.FUNCTIONAL_CASE);
|
operationHistoryExample.createCriteria().andSourceIdEqualTo(functionalCaseDetailDTO.getId()).andModuleEqualTo(OperationLogModule.FUNCTIONAL_CASE).andTypeIn(types);
|
||||||
operationHistoryExample.createCriteria().andSourceIdEqualTo(functionalCaseDetailDTO.getId()).andTypeIn(types).andModuleIn(modules);
|
|
||||||
functionalCaseDetailDTO.setHistoryCount((int) operationHistoryMapper.countByExample(operationHistoryExample));
|
functionalCaseDetailDTO.setHistoryCount((int) operationHistoryMapper.countByExample(operationHistoryExample));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -482,12 +482,17 @@ public class FunctionalCaseService {
|
||||||
TemplateDTO templateDTO = projectTemplateService.getTemplateDTOById(functionalCase.getTemplateId(), functionalCase.getProjectId(), TemplateScene.FUNCTIONAL.name());
|
TemplateDTO templateDTO = projectTemplateService.getTemplateDTOById(functionalCase.getTemplateId(), functionalCase.getProjectId(), TemplateScene.FUNCTIONAL.name());
|
||||||
if (CollectionUtils.isNotEmpty(templateDTO.getCustomFields())) {
|
if (CollectionUtils.isNotEmpty(templateDTO.getCustomFields())) {
|
||||||
List<TemplateCustomFieldDTO> customFields = templateDTO.getCustomFields();
|
List<TemplateCustomFieldDTO> customFields = templateDTO.getCustomFields();
|
||||||
|
List<String> fieldIds = customFields.stream().map(TemplateCustomFieldDTO::getFieldId).distinct().toList();
|
||||||
|
FunctionalCaseCustomFieldExample example = new FunctionalCaseCustomFieldExample();
|
||||||
|
example.createCriteria().andCaseIdEqualTo(functionalCase.getId()).andFieldIdIn(fieldIds);
|
||||||
|
List<FunctionalCaseCustomField> functionalCaseCustomFields = functionalCaseCustomFieldMapper.selectByExample(example);
|
||||||
|
Map<String, FunctionalCaseCustomField> customFieldMap = functionalCaseCustomFields.stream().collect(Collectors.toMap(FunctionalCaseCustomField::getFieldId, t -> t));
|
||||||
List<CustomFieldOption> memberCustomOption = getMemberOptions(functionalCase.getProjectId());
|
List<CustomFieldOption> memberCustomOption = getMemberOptions(functionalCase.getProjectId());
|
||||||
customFields.forEach(item -> {
|
customFields.forEach(item -> {
|
||||||
if (StringUtils.equalsAnyIgnoreCase(item.getType(), CustomFieldType.MEMBER.name(), CustomFieldType.MULTIPLE_MEMBER.name())) {
|
if (StringUtils.equalsAnyIgnoreCase(item.getType(), CustomFieldType.MEMBER.name(), CustomFieldType.MULTIPLE_MEMBER.name())) {
|
||||||
item.setOptions(memberCustomOption);
|
item.setOptions(memberCustomOption);
|
||||||
}
|
}
|
||||||
FunctionalCaseCustomField caseCustomField = functionalCaseCustomFieldService.getCustomField(item.getFieldId(), functionalCase.getId());
|
FunctionalCaseCustomField caseCustomField = customFieldMap.get(item.getFieldId());
|
||||||
Optional.ofNullable(caseCustomField).ifPresentOrElse(customField -> {
|
Optional.ofNullable(caseCustomField).ifPresentOrElse(customField -> {
|
||||||
item.setDefaultValue(customField.getValue());
|
item.setDefaultValue(customField.getValue());
|
||||||
if (Translator.get("custom_field.functional_priority").equals(item.getFieldName())) {
|
if (Translator.get("custom_field.functional_priority").equals(item.getFieldName())) {
|
||||||
|
|
|
@ -91,8 +91,6 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
|
||||||
@Resource
|
@Resource
|
||||||
private BugRelationCaseMapper bugRelationCaseMapper;
|
private BugRelationCaseMapper bugRelationCaseMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private TestPlanModuleService testPlanModuleService;
|
|
||||||
@Resource
|
|
||||||
private ExtTestPlanModuleMapper extTestPlanModuleMapper;
|
private ExtTestPlanModuleMapper extTestPlanModuleMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private FunctionalCaseModuleService functionalCaseModuleService;
|
private FunctionalCaseModuleService functionalCaseModuleService;
|
||||||
|
@ -553,7 +551,7 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
|
||||||
public TestPlanCaseDetailResponse getFunctionalCaseDetail(String id, String userId) {
|
public TestPlanCaseDetailResponse getFunctionalCaseDetail(String id, String userId) {
|
||||||
TestPlanFunctionalCase planFunctionalCase = testPlanFunctionalCaseMapper.selectByPrimaryKey(id);
|
TestPlanFunctionalCase planFunctionalCase = testPlanFunctionalCaseMapper.selectByPrimaryKey(id);
|
||||||
String caseId = planFunctionalCase.getFunctionalCaseId();
|
String caseId = planFunctionalCase.getFunctionalCaseId();
|
||||||
FunctionalCaseDetailDTO functionalCaseDetail = functionalCaseService.getFunctionalCaseDetail(caseId, userId);
|
FunctionalCaseDetailDTO functionalCaseDetail = functionalCaseService.getFunctionalCaseDetail(caseId, userId, false);
|
||||||
String caseDetailSteps = functionalCaseDetail.getSteps();
|
String caseDetailSteps = functionalCaseDetail.getSteps();
|
||||||
List<TestPlanCaseExecuteHistory> testPlanCaseExecuteHistories = extTestPlanCaseExecuteHistoryMapper.selectSteps(id, caseId);
|
List<TestPlanCaseExecuteHistory> testPlanCaseExecuteHistories = extTestPlanCaseExecuteHistoryMapper.selectSteps(id, caseId);
|
||||||
Integer runListCount = 0;
|
Integer runListCount = 0;
|
||||||
|
|
Loading…
Reference in New Issue