From 315b9bc083cbbceec2536a208b6be83e0b7854cd Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Thu, 14 Nov 2024 17:06:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B):=20?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E8=AF=84=E5=AE=A1=E5=BF=AB=E6=8D=B7=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E7=94=A8=E4=BE=8B=E5=B9=B6=E5=85=B3=E8=81=94=E8=AF=84?= =?UTF-8?q?=E5=AE=A1=EF=BC=8C=E7=BC=BA=E5=A4=B1=E5=85=B3=E8=81=94=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1048759 --user=王旭 【测试用例】评审-评审详情-快捷创建并关联用例-查看日志-未生成关联用例的日志 https://www.tapd.cn/55049933/s/1609975 --- .../service/CaseReviewLogService.java | 23 +++++++++++++++++++ .../service/FunctionalCaseService.java | 11 +++++---- .../dml/init_review_functional_case_test.sql | 2 ++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewLogService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewLogService.java index 136c0b5686..762fac21fe 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewLogService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewLogService.java @@ -13,11 +13,15 @@ import io.metersphere.functional.request.BaseAssociateCaseRequest; import io.metersphere.functional.request.BaseReviewCaseBatchRequest; import io.metersphere.functional.request.CaseReviewAssociateRequest; import io.metersphere.functional.request.CaseReviewRequest; +import io.metersphere.project.domain.Project; +import io.metersphere.project.mapper.ProjectMapper; import io.metersphere.sdk.constants.HttpMethodConstants; import io.metersphere.sdk.util.JSON; +import io.metersphere.system.dto.builder.LogDTOBuilder; 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 jakarta.annotation.Resource; import org.apache.commons.collections.CollectionUtils; import org.springframework.stereotype.Service; @@ -46,6 +50,10 @@ public class CaseReviewLogService { private CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper; @Resource private ExtFunctionalCaseMapper extFunctionalCaseMapper; + @Resource + private ProjectMapper projectMapper; + @Resource + private OperationLogService operationLogService; /** * 新增用例评审 日志 @@ -243,4 +251,19 @@ public class CaseReviewLogService { } } + public void createCaseAndAssociateLog(CaseReview caseReview, FunctionalCase functionalCase, String userId) { + Project project = projectMapper.selectByPrimaryKey(caseReview.getProjectId()); + LogDTO dto = LogDTOBuilder.builder() + .projectId(caseReview.getProjectId()) + .organizationId(project.getOrganizationId()) + .type(OperationLogType.ASSOCIATE.name()) + .module(OperationLogModule.CASE_REVIEW_DETAIL) + .method(HttpMethodConstants.POST.name()) + .path("/functional/case/add") + .sourceId(caseReview.getId()) + .content(functionalCase.getName()) + .createUser(userId) + .build().getLogDTO(); + operationLogService.add(dto); + } } 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 78c10fb8f6..fb8f67b518 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 @@ -178,6 +178,8 @@ public class FunctionalCaseService { private ProjectService projectService; @Resource private FunctionalCaseNoticeService functionalCaseNoticeService; + @Resource + private CaseReviewLogService caseReviewLogService;; public FunctionalCase addFunctionalCase(FunctionalCaseAddRequest request, List files, String userId, String organizationId) { String caseId = IDGenerator.nextStr(); @@ -201,7 +203,7 @@ public class FunctionalCaseService { copyAttachment(request, userId, uploadFileIds, caseId); } LogUtils.info("保存用例的文件操作完成"); - addCaseReviewCase(request.getReviewId(), caseId, userId); + addCaseReviewCase(request.getReviewId(), functionalCase, userId); //记录日志 FunctionalCaseHistoryLogDTO historyLogDTO = getAddLogModule(functionalCase); @@ -276,10 +278,11 @@ public class FunctionalCaseService { * * @param reviewId reviewId */ - private void addCaseReviewCase(String reviewId, String caseId, String userId) { + private void addCaseReviewCase(String reviewId, FunctionalCase functionalCase, String userId) { if (StringUtils.isNotBlank(reviewId)) { - caseReviewService.checkCaseReview(reviewId); - caseReviewFunctionalCaseService.addCaseReviewFunctionalCase(caseId, userId, reviewId); + CaseReview caseReview = caseReviewService.checkCaseReview(reviewId); + caseReviewFunctionalCaseService.addCaseReviewFunctionalCase(functionalCase.getId(), userId, reviewId); + caseReviewLogService.createCaseAndAssociateLog(caseReview, functionalCase, userId); } } diff --git a/backend/services/case-management/src/test/resources/dml/init_review_functional_case_test.sql b/backend/services/case-management/src/test/resources/dml/init_review_functional_case_test.sql index 984604712a..649595bf13 100644 --- a/backend/services/case-management/src/test/resources/dml/init_review_functional_case_test.sql +++ b/backend/services/case-management/src/test/resources/dml/init_review_functional_case_test.sql @@ -120,6 +120,8 @@ INSERT INTO project (id, num, organization_id, name, description, create_user, u VALUES ('wx_test_project_review_one', null, 'organization-associate-case-test', '评审跨项目关联用例', '系统默认创建的项目', 'admin', 'admin', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000), ('wx_test_project_review_two', null, 'organization-associate-case-test', '评审跨项目关联用例2', '系统默认创建的项目', + 'admin', 'admin', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000), + ('wx_test_project', null, 'organization-associate-case-test', '评审跨项目关联用例3', '系统默认创建的项目', 'admin', 'admin', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000);