fix(用例管理): 用例详情模块名称,默认模块报错问题

This commit is contained in:
WangXu10 2024-02-04 18:26:34 +08:00 committed by 刘瑞斌
parent 4bc8e0995b
commit f7d32ef2f6
7 changed files with 36 additions and 23 deletions

View File

@ -62,6 +62,9 @@ public class FunctionalCaseDetailDTO implements Serializable {
@Schema(description = "创建人")
private String createUser;
@Schema(description = "创建人姓名")
private String createUserName;
@Schema(description = "创建时间")
private Long createTime;

View File

@ -29,7 +29,7 @@
cf.type type
FROM
functional_case_custom_field fccf
LEFT JOIN custom_field cf ON fccf.field_id = cf.id
INNER JOIN custom_field cf ON fccf.field_id = cf.id
where case_id in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}

View File

@ -218,15 +218,6 @@ public class CaseReviewModuleService extends ModuleTreeService {
example.clear();
}
private String getRootNodeId(CaseReviewModule caseReviewModule) {
if (StringUtils.equals(caseReviewModule.getParentId(), ModuleConstants.ROOT_NODE_PARENT_ID)) {
return caseReviewModule.getId();
} else {
CaseReviewModule parentModule = caseReviewModuleMapper.selectByPrimaryKey(caseReviewModule.getParentId());
return this.getRootNodeId(parentModule);
}
}
@Override
public void updatePos(String id, long pos) {
CaseReviewModule updateModule = new CaseReviewModule();

View File

@ -216,14 +216,6 @@ public class FunctionalCaseModuleService extends ModuleTreeService {
example.clear();
}
private String getRootNodeId(FunctionalCaseModule functionalCaseModule) {
if (StringUtils.equals(functionalCaseModule.getParentId(), ModuleConstants.ROOT_NODE_PARENT_ID)) {
return functionalCaseModule.getId();
} else {
FunctionalCaseModule parentModule = functionalCaseModuleMapper.selectByPrimaryKey(functionalCaseModule.getParentId());
return this.getRootNodeId(parentModule);
}
}
@Override
public void updatePos(String id, long pos) {
@ -406,7 +398,10 @@ public class FunctionalCaseModuleService extends ModuleTreeService {
}
public FunctionalCaseModule getModule(String id) {
return functionalCaseModuleMapper.selectByPrimaryKey(id);
public String getModuleName(String id) {
if (ModuleConstants.DEFAULT_NODE_ID.equals(id)) {
return Translator.get("default.module");
}
return functionalCaseModuleMapper.selectByPrimaryKey(id).getName();
}
}

View File

@ -31,6 +31,7 @@ import io.metersphere.sdk.util.BeanUtils;
import io.metersphere.sdk.util.JSON;
import io.metersphere.sdk.util.Translator;
import io.metersphere.system.domain.CustomFieldOption;
import io.metersphere.system.domain.User;
import io.metersphere.system.dto.OperationHistoryDTO;
import io.metersphere.system.dto.request.OperationHistoryRequest;
import io.metersphere.system.dto.sdk.*;
@ -39,6 +40,7 @@ import io.metersphere.system.log.constants.OperationLogModule;
import io.metersphere.system.log.constants.OperationLogType;
import io.metersphere.system.log.dto.LogDTO;
import io.metersphere.system.log.service.OperationLogService;
import io.metersphere.system.mapper.UserMapper;
import io.metersphere.system.notice.constants.NoticeConstants;
import io.metersphere.system.notice.sender.AfterReturningNoticeSendService;
import io.metersphere.system.service.BaseCustomFieldOptionService;
@ -153,6 +155,8 @@ public class FunctionalCaseService {
private AfterReturningNoticeSendService afterReturningNoticeSendService;
@Resource
private OperationHistoryService operationHistoryService;
@Resource
private UserMapper userMapper;
public FunctionalCase addFunctionalCase(FunctionalCaseAddRequest request, List<MultipartFile> files, String userId, String organizationId) {
@ -276,9 +280,10 @@ public class FunctionalCaseService {
functionalCaseDetailDTO.setVersionName(versions.get(0).getName());
}
//模块名称
FunctionalCaseModule module = functionalCaseModuleService.getModule(functionalCaseDetailDTO.getModuleId());
functionalCaseDetailDTO.setModuleName(module.getName());
handDTO(functionalCaseDetailDTO);
//处理已关联需求数量/缺陷数量/用例数量
handleCount(functionalCaseDetailDTO);
@ -287,6 +292,19 @@ public class FunctionalCaseService {
}
/**
* 处理返回对象的相关属性
*
* @param functionalCaseDetailDTO functionalCaseDetailDTO
*/
private void handDTO(FunctionalCaseDetailDTO functionalCaseDetailDTO) {
String name = functionalCaseModuleService.getModuleName(functionalCaseDetailDTO.getModuleId());
functionalCaseDetailDTO.setModuleName(name);
User user = userMapper.selectByPrimaryKey(functionalCaseDetailDTO.getCreateUser());
functionalCaseDetailDTO.setCreateUserName(user.getName());
}
private void handleCount(FunctionalCaseDetailDTO functionalCaseDetailDTO) {
//获取已关联需求数量
FunctionalCaseDemandExample functionalCaseDemandExample = new FunctionalCaseDemandExample();

View File

@ -244,6 +244,7 @@ public class FunctionalCaseControllerTests extends BaseTest {
}
});
this.requestGetWithOkAndReturn(FUNCTIONAL_CASE_DETAIL_URL + "TEST_FUNCTIONAL_CASE_ID_3");
this.requestGetWithOkAndReturn(FUNCTIONAL_CASE_DETAIL_URL + "wx_test_root");
}

View File

@ -78,3 +78,8 @@ INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, r
VALUES ('TEST_IMPORT', 10, 'TEST_MODULE_ID_GYQ', '100001100001', '100001', '1223', 'UN_REVIEWED', NULL, 'STEP', 0, 'v3.0.0', 'wx_ref_id', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL);
INSERT INTO functional_case_blob(id, steps, text_description, expected_result, prerequisite, description) VALUES ('TEST_IMPORT', 'STEP', '1111', '', '', 'TEST');
INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, review_status, tags, case_edit_type, pos, version_id, ref_id, last_execute_result, deleted, public_case, latest, create_user, update_user, delete_user, create_time, update_time, delete_time)
VALUES ('wx_test_root', 13, 'root', '100001100001', '100001', '测试默认模块', 'UN_REVIEWED', NULL, 'STEP', 0, 'v3.0.0', 'wx_ref_id', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL);
INSERT INTO functional_case_blob(id, steps, text_description, expected_result, prerequisite, description) VALUES ('wx_test_root', 'STEP', '1111', '', '', 'TEST');