From 60da55b95e8d39497338a7be7178c148a9297339 Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Thu, 14 Nov 2024 14:50:51 +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=E6=A8=A1=E5=9D=97=E6=93=8D=E4=BD=9C&?= =?UTF-8?q?=E8=84=91=E5=9B=BE=E6=93=8D=E4=BD=9C=E6=A8=A1=E5=9D=97=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=1048748 --user=王旭 【测试用例】用例-模块树-模块下无用例时-删除模块,未生成日志 https://www.tapd.cn/55049933/s/1609868 --bug=1048745 --user=王旭 【测试用例】用例-脑图模块-脑图模式下创建/更新/删除模块-未生成日志 https://www.tapd.cn/55049933/s/1609869 --- .../service/FunctionalCaseMinderService.java | 8 +++++ .../FunctionalCaseModuleLogService.java | 30 +++++++++++++++++-- .../service/FunctionalCaseModuleService.java | 4 +++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseMinderService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseMinderService.java index 7589de00c3..2ecd1d9fd6 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseMinderService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseMinderService.java @@ -878,6 +878,7 @@ public class FunctionalCaseMinderService { checkModules(module, parentIdInDBMap, OperationLogType.ADD.toString()); moduleMapper.insert(module); } + functionalCaseModuleLogService.handleModuleLog(modules, request.getProjectId(), userId, "/functional/mind/case/edit", OperationLogType.ADD.name()); } //处理更新(更新的情况是可能换数据本身,可能换父节点,可能换顺序) List updateList = resourceMap.get(OperationLogType.UPDATE.toString()); @@ -900,6 +901,7 @@ public class FunctionalCaseMinderService { checkModules(module, parentIdInDBMap, OperationLogType.UPDATE.toString()); moduleMapper.updateByPrimaryKeySelective(module); } + functionalCaseModuleLogService.handleModuleLog(modules, request.getProjectId(), userId, "/functional/mind/case/edit", OperationLogType.UPDATE.name()); } } setDTOTargetMap(functionalMinderUpdateDTO, sourceIdAndTargetIdsMap); @@ -1236,6 +1238,12 @@ public class FunctionalCaseMinderService { if (moduleIds.contains("root")) { throw new MSException(Translator.get("functional_case.module.default.name.cut_error")); } + //模块日志 + FunctionalCaseModuleExample moduleExample = new FunctionalCaseModuleExample(); + moduleExample.createCriteria().andIdIn(moduleIds); + List modules = functionalCaseModuleMapper.selectByExample(moduleExample); + functionalCaseModuleLogService.handleModuleLog(modules, request.getProjectId(), user.getId(), "/functional/mind/case/edit", OperationLogType.DELETE.name()); + List functionalCases = functionalCaseModuleService.deleteModuleByIds(moduleIds, new ArrayList<>(), user.getId()); functionalCaseModuleLogService.batchDelLog(functionalCases, request.getProjectId(), user.getId(), "/functional/mind/case/edit"); List finalCaseIds = caseIds; diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseModuleLogService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseModuleLogService.java index aa71877700..6fbcf5009f 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseModuleLogService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseModuleLogService.java @@ -78,7 +78,7 @@ public class FunctionalCaseModuleLogService { /** - * 功能用例模块删除日志 + * 功能用例用例删除日志 * * @param functionalCases * @param projectId @@ -93,7 +93,7 @@ public class FunctionalCaseModuleLogService { item.getId(), userId, OperationLogType.DELETE.name(), - OperationLogModule.CASE_MANAGEMENT_CASE_MODULE, + OperationLogModule.CASE_MANAGEMENT_CASE_CASE, item.getName()); dto.setPath(path); dto.setMethod(HttpMethodConstants.GET.name()); @@ -104,4 +104,30 @@ public class FunctionalCaseModuleLogService { } + /** + * 功能用例模块删除日志 + * @param deleteModule + * @param projectId + * @param userId + * @param path + */ + public void handleModuleLog(List deleteModule, String projectId, String userId, String path, String type) { + Project project = projectMapper.selectByPrimaryKey(projectId); + List dtoList = new ArrayList<>(); + deleteModule.forEach(item -> { + LogDTO dto = new LogDTO( + projectId, + project.getOrganizationId(), + item.getId(), + userId, + type, + OperationLogModule.CASE_MANAGEMENT_CASE_MODULE, + item.getName()); + dto.setPath(path); + dto.setMethod(HttpMethodConstants.GET.name()); + dto.setOriginalValue(JSON.toJSONBytes(item)); + dtoList.add(dto); + }); + operationLogService.batchAdd(dtoList); + } } 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 7d412b4028..b5e3be173d 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 @@ -26,6 +26,7 @@ import io.metersphere.sdk.util.Translator; import io.metersphere.system.domain.User; import io.metersphere.system.dto.sdk.BaseTreeNode; import io.metersphere.system.dto.sdk.request.NodeMoveRequest; +import io.metersphere.system.log.constants.OperationLogType; import io.metersphere.system.mapper.UserMapper; import io.metersphere.system.notice.constants.NoticeConstants; import io.metersphere.system.uid.IDGenerator; @@ -128,7 +129,10 @@ public class FunctionalCaseModuleService extends ModuleTreeService { FunctionalCaseModule deleteModule = functionalCaseModuleMapper.selectByPrimaryKey(moduleId); if (deleteModule != null) { List functionalCases = this.deleteModuleByIds(Collections.singletonList(moduleId), new ArrayList<>(), userId); + //用例日志 functionalCaseModuleLogService.batchDelLog(functionalCases, deleteModule.getProjectId(), userId, "/functional/case/module/delete/" + moduleId); + //模块日志 + functionalCaseModuleLogService.handleModuleLog(List.of(deleteModule), deleteModule.getProjectId(), userId, "/functional/case/module/delete/" + moduleId, OperationLogType.DELETE.name()); List ids = functionalCases.stream().map(FunctionalCase::getId).toList(); User user = userMapper.selectByPrimaryKey(userId); functionalCaseNoticeService.batchSendNotice(deleteModule.getProjectId(), ids, user, NoticeConstants.Event.DELETE);