From 0aea5e2d2fbef235ecb1c27d79caad6bf53b1fd2 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Fri, 15 Nov 2024 18:56:06 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=94=A8=E4=BE=8B=E8=AF=84=E5=AE=A1):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A7=BB=E5=8A=A8=E7=94=A8=E4=BE=8B=E6=97=B6?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E8=AF=84=E5=AE=A1=E7=9A=84=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=9C=AA=E5=8F=8A=E6=97=B6=E6=9B=B4=E6=96=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1048758 --user=郭雨琦 修复脑图排序失败问题 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001048758 --- .../controller/CaseReviewController.java | 2 + .../service/CaseReviewLogService.java | 93 ++++++++++++++++--- 2 files changed, 83 insertions(+), 12 deletions(-) diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/controller/CaseReviewController.java b/backend/services/case-management/src/main/java/io/metersphere/functional/controller/CaseReviewController.java index 88f3361fad..cb451e2bd4 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/controller/CaseReviewController.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/controller/CaseReviewController.java @@ -128,6 +128,7 @@ public class CaseReviewController { @Operation(summary = "用例管理-用例评审-拖拽排序") @RequiresPermissions(PermissionConstants.CASE_REVIEW_READ_UPDATE) @CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project") + @Log(type = OperationLogType.UPDATE, expression = "#msClass.updateCaseReviewLogByPos(#request)", msClass = CaseReviewLogService.class) public void editPos(@Validated @RequestBody PosRequest request) { caseReviewService.editPos(request); } @@ -144,6 +145,7 @@ public class CaseReviewController { @Operation(summary = "用例管理-用例评审-批量移动用例评审") @RequiresPermissions(PermissionConstants.CASE_REVIEW_READ_UPDATE) @CheckOwner(resourceId = "#request.getSelectIds()", resourceType = "case_review") + @Log(type = OperationLogType.UPDATE, expression = "#msClass.updateBatchCaseReviewLog(#request)", msClass = CaseReviewLogService.class) public void batchMoveCaseReview(@Validated @RequestBody CaseReviewBatchRequest request) { caseReviewService.batchMoveCaseReview(request, SessionUtils.getUserId()); } 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 762fac21fe..027dbbea57 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 @@ -1,29 +1,22 @@ package io.metersphere.functional.service; -import io.metersphere.functional.domain.CaseReview; -import io.metersphere.functional.domain.CaseReviewFunctionalCase; -import io.metersphere.functional.domain.FunctionalCase; -import io.metersphere.functional.domain.FunctionalCaseExample; +import io.metersphere.functional.domain.*; import io.metersphere.functional.dto.BaseFunctionalCaseBatchDTO; -import io.metersphere.functional.mapper.CaseReviewFunctionalCaseMapper; -import io.metersphere.functional.mapper.CaseReviewMapper; -import io.metersphere.functional.mapper.ExtFunctionalCaseMapper; -import io.metersphere.functional.mapper.FunctionalCaseMapper; -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.functional.mapper.*; +import io.metersphere.functional.request.*; 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.dto.sdk.request.PosRequest; 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.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -40,6 +33,9 @@ public class CaseReviewLogService { @Resource private CaseReviewMapper caseReviewMapper; + @Resource + private ExtCaseReviewMapper extCaseReviewMapper; + @Resource private FunctionalCaseMapper functionalCaseMapper; @@ -124,6 +120,32 @@ public class CaseReviewLogService { dto.setOriginalValue(JSON.toJSONBytes(caseReview)); return dto; } + /** + * 排序更新用例评审 日志 + * + * @param request 页面参数 + * @return LogDTO + */ + public LogDTO updateCaseReviewLogByPos(PosRequest request) { + CaseReview caseReview = caseReviewMapper.selectByPrimaryKey(request.getTargetId()); + if (caseReview == null) { + return null; + } + LogDTO dto = new LogDTO( + caseReview.getProjectId(), + null, + caseReview.getId(), + caseReview.getCreateUser(), + OperationLogType.UPDATE.name(), + OperationLogModule.CASE_MANAGEMENT_REVIEW_REVIEW, + caseReview.getName()); + + dto.setPath("/case/edit/pos"); + dto.setMethod(HttpMethodConstants.POST.name()); + dto.setOriginalValue(JSON.toJSONBytes(caseReview)); + return dto; + } + /** * 删除用例 日志 @@ -238,6 +260,39 @@ public class CaseReviewLogService { return dtoList; } + /** + * 移动更新用例评审 + * @param request + * @return + */ + public List updateBatchCaseReviewLog(CaseReviewBatchRequest request) { + if (StringUtils.isBlank(request.getMoveModuleId())) { + return new ArrayList<>(); + } + List ids = doSelectReviewIds(request); + List dtoList = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(ids)) { + CaseReviewExample caseReviewExample = new CaseReviewExample(); + caseReviewExample.createCriteria().andIdIn(ids); + List caseReviews = caseReviewMapper.selectByExample(caseReviewExample); + caseReviews.forEach(caseReview -> { + LogDTO dto = new LogDTO( + caseReview.getProjectId(), + null, + caseReview.getId(), + caseReview.getCreateUser(), + OperationLogType.UPDATE.name(), + OperationLogModule.CASE_MANAGEMENT_REVIEW_REVIEW, + caseReview.getName()); + + dto.setPath("/case/batch/move"); + dto.setMethod(HttpMethodConstants.POST.name()); + dtoList.add(dto); + }); + } + return dtoList; + } + public List doSelectIds(T dto, String projectId) { BaseFunctionalCaseBatchDTO request = (BaseFunctionalCaseBatchDTO) dto; if (request.isSelectAll()) { @@ -251,6 +306,20 @@ public class CaseReviewLogService { } } + public ListdoSelectReviewIds(CaseReviewBatchRequest request) { + List ids; + if (request.isSelectAll()) { + ids = extCaseReviewMapper.getIds(request, request.getProjectId()); + if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(request.getExcludeIds())) { + ids.removeAll(request.getExcludeIds()); + } + } else { + ids = request.getSelectIds(); + } + return ids; + } + + public void createCaseAndAssociateLog(CaseReview caseReview, FunctionalCase functionalCase, String userId) { Project project = projectMapper.selectByPrimaryKey(caseReview.getProjectId()); LogDTO dto = LogDTOBuilder.builder()