diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/dto/FunctionalCaseDetailDTO.java b/backend/services/case-management/src/main/java/io/metersphere/functional/dto/FunctionalCaseDetailDTO.java index 5f743504e5..acf1ea40bb 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/dto/FunctionalCaseDetailDTO.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/dto/FunctionalCaseDetailDTO.java @@ -62,6 +62,9 @@ public class FunctionalCaseDetailDTO implements Serializable { @Schema(description = "创建人") private String createUser; + @Schema(description = "创建人姓名") + private String createUserName; + @Schema(description = "创建时间") private Long createTime; diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseCustomFieldMapper.xml b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseCustomFieldMapper.xml index 7dfbea7f7a..10f96f2ba1 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseCustomFieldMapper.xml +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseCustomFieldMapper.xml @@ -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 #{id} diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewModuleService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewModuleService.java index 9dafc546ba..00877baf46 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewModuleService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewModuleService.java @@ -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(); diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseModuleService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseModuleService.java index 96a8001238..6b6af786ea 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseModuleService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseModuleService.java @@ -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(); } } \ No newline at end of file diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java index a38a0e6409..3ba318c719 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java @@ -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 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(); diff --git a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseControllerTests.java b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseControllerTests.java index abd2b0db8c..27eff310c7 100644 --- a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseControllerTests.java +++ b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseControllerTests.java @@ -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"); } diff --git a/backend/services/case-management/src/test/resources/dml/init_file_metadata_test.sql b/backend/services/case-management/src/test/resources/dml/init_file_metadata_test.sql index a30e08e6c6..40d81b9071 100644 --- a/backend/services/case-management/src/test/resources/dml/init_file_metadata_test.sql +++ b/backend/services/case-management/src/test/resources/dml/init_file_metadata_test.sql @@ -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) 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'); \ No newline at end of file +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'); \ No newline at end of file