fix(项目管理): 测试计划脑图创建缺陷日志

--bug=1046641 --user=王旭 【项目管理】日志-测试计划脑图执行时,通过模块创建缺陷,项目中没有生成缺陷创建日志 https://www.tapd.cn/55049933/s/1581057
This commit is contained in:
WangXu10 2024-09-19 14:41:42 +08:00 committed by Craftsman
parent 4995736e30
commit dece1a8751
2 changed files with 18 additions and 0 deletions

View File

@ -15,6 +15,7 @@ import io.metersphere.sdk.util.JSON;
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.lang3.StringUtils;
import org.springframework.stereotype.Service;
@ -35,6 +36,8 @@ public class BugLogService {
private BugService bugService;
@Resource
private BugContentMapper bugContentMapper;
@Resource
private OperationLogService operationLogService;
/**
@ -168,4 +171,15 @@ public class BugLogService {
BugCustomFieldDTO titleField = find.orElseGet(BugCustomFieldDTO::new);
return StringUtils.isNotBlank(request.getTitle()) ? request.getTitle() : titleField.getValue();
}
@SuppressWarnings("unused")
public void minderAddLog(BugEditRequest request, List<MultipartFile> files, String orgId, String bugId, String userId) {
LogDTO dto = new LogDTO(request.getProjectId(), orgId, bugId, userId, OperationLogType.ADD.name(), OperationLogModule.BUG_MANAGEMENT_INDEX, getPlatformTitle(request));
dto.setHistory(true);
dto.setPath("/test-plan/functional/case/minder/batch/add-bug");
dto.setMethod(HttpMethodConstants.POST.name());
dto.setModifiedValue(JSON.toJSONBytes(request));
operationLogService.add(dto);
}
}

View File

@ -2,6 +2,7 @@ package io.metersphere.plan.controller;
import io.metersphere.bug.domain.Bug;
import io.metersphere.bug.dto.request.BugEditRequest;
import io.metersphere.bug.service.BugLogService;
import io.metersphere.bug.service.BugService;
import io.metersphere.plan.dto.request.TestPlanCaseBatchAddBugRequest;
import io.metersphere.plan.dto.request.TestPlanCaseBatchAssociateBugRequest;
@ -29,6 +30,8 @@ public class TestPlanFunctionalCaseMinderController {
private BugService bugService;
@Resource
private TestPlanFunctionalCaseMinderService testPlanFunctionalCaseMinderService;
@Resource
private BugLogService bugLogService;
@PostMapping("/batch/add-bug")
@Operation(summary = "测试计划-功能用例-脑图-批量添加缺陷")
@ -39,6 +42,7 @@ public class TestPlanFunctionalCaseMinderController {
BugEditRequest bugEditRequest = new BugEditRequest();
BeanUtils.copyBean(bugEditRequest, request);
Bug bug = bugService.addOrUpdate(bugEditRequest, files, SessionUtils.getUserId(), SessionUtils.getCurrentOrganizationId(), false);
bugLogService.minderAddLog(bugEditRequest, files, SessionUtils.getCurrentOrganizationId(), bug.getId(), SessionUtils.getUserId());
testPlanFunctionalCaseMinderService.minderBatchAssociateBug(request, bug.getId(), SessionUtils.getUserId());
}