fix(测试用例): 用例评审快捷创建用例并关联评审,缺失关联日志

--bug=1048759 --user=王旭 【测试用例】评审-评审详情-快捷创建并关联用例-查看日志-未生成关联用例的日志 https://www.tapd.cn/55049933/s/1609975
This commit is contained in:
WangXu10 2024-11-14 17:06:22 +08:00 committed by Craftsman
parent 857a420281
commit 315b9bc083
3 changed files with 32 additions and 4 deletions

View File

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

View File

@ -178,6 +178,8 @@ public class FunctionalCaseService {
private ProjectService projectService;
@Resource
private FunctionalCaseNoticeService functionalCaseNoticeService;
@Resource
private CaseReviewLogService caseReviewLogService;;
public FunctionalCase addFunctionalCase(FunctionalCaseAddRequest request, List<MultipartFile> 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);
}
}

View File

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