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);