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 = "创建人") @Schema(description = "创建人")
private String createUser; private String createUser;
@Schema(description = "创建人姓名")
private String createUserName;
@Schema(description = "创建时间") @Schema(description = "创建时间")
private Long createTime; private Long createTime;

View File

@ -29,7 +29,7 @@
cf.type type cf.type type
FROM FROM
functional_case_custom_field fccf 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 where case_id in
<foreach collection="ids" item="id" separator="," open="(" close=")"> <foreach collection="ids" item="id" separator="," open="(" close=")">
#{id} #{id}

View File

@ -218,15 +218,6 @@ public class CaseReviewModuleService extends ModuleTreeService {
example.clear(); 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 @Override
public void updatePos(String id, long pos) { public void updatePos(String id, long pos) {
CaseReviewModule updateModule = new CaseReviewModule(); CaseReviewModule updateModule = new CaseReviewModule();

View File

@ -216,14 +216,6 @@ public class FunctionalCaseModuleService extends ModuleTreeService {
example.clear(); 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 @Override
public void updatePos(String id, long pos) { public void updatePos(String id, long pos) {
@ -406,7 +398,10 @@ public class FunctionalCaseModuleService extends ModuleTreeService {
} }
public FunctionalCaseModule getModule(String id) { public String getModuleName(String id) {
return functionalCaseModuleMapper.selectByPrimaryKey(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.JSON;
import io.metersphere.sdk.util.Translator; import io.metersphere.sdk.util.Translator;
import io.metersphere.system.domain.CustomFieldOption; import io.metersphere.system.domain.CustomFieldOption;
import io.metersphere.system.domain.User;
import io.metersphere.system.dto.OperationHistoryDTO; import io.metersphere.system.dto.OperationHistoryDTO;
import io.metersphere.system.dto.request.OperationHistoryRequest; import io.metersphere.system.dto.request.OperationHistoryRequest;
import io.metersphere.system.dto.sdk.*; 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.constants.OperationLogType;
import io.metersphere.system.log.dto.LogDTO; import io.metersphere.system.log.dto.LogDTO;
import io.metersphere.system.log.service.OperationLogService; 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.constants.NoticeConstants;
import io.metersphere.system.notice.sender.AfterReturningNoticeSendService; import io.metersphere.system.notice.sender.AfterReturningNoticeSendService;
import io.metersphere.system.service.BaseCustomFieldOptionService; import io.metersphere.system.service.BaseCustomFieldOptionService;
@ -153,6 +155,8 @@ public class FunctionalCaseService {
private AfterReturningNoticeSendService afterReturningNoticeSendService; private AfterReturningNoticeSendService afterReturningNoticeSendService;
@Resource @Resource
private OperationHistoryService operationHistoryService; private OperationHistoryService operationHistoryService;
@Resource
private UserMapper userMapper;
public FunctionalCase addFunctionalCase(FunctionalCaseAddRequest request, List<MultipartFile> files, String userId, String organizationId) { 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()); functionalCaseDetailDTO.setVersionName(versions.get(0).getName());
} }
//模块名称 //模块名称
FunctionalCaseModule module = functionalCaseModuleService.getModule(functionalCaseDetailDTO.getModuleId()); handDTO(functionalCaseDetailDTO);
functionalCaseDetailDTO.setModuleName(module.getName());
//处理已关联需求数量/缺陷数量/用例数量 //处理已关联需求数量/缺陷数量/用例数量
handleCount(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) { private void handleCount(FunctionalCaseDetailDTO functionalCaseDetailDTO) {
//获取已关联需求数量 //获取已关联需求数量
FunctionalCaseDemandExample functionalCaseDemandExample = new FunctionalCaseDemandExample(); 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 + "TEST_FUNCTIONAL_CASE_ID_3");
this.requestGetWithOkAndReturn(FUNCTIONAL_CASE_DETAIL_URL + "wx_test_root");
} }

View File

@ -77,4 +77,9 @@ VALUES ('v2.0.1', 'wx_relationship', 'v1.0', NULL, 'open', b'1', 1698810592000,
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) 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 ('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); 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_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');