refactor(测试用例): 优化模块操作日志

This commit is contained in:
WangXu10 2024-11-18 11:20:34 +08:00 committed by Craftsman
parent 173b6c9bfe
commit 290a8d6429
4 changed files with 11 additions and 8 deletions

View File

@ -6,6 +6,7 @@ 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.sdk.util.Translator;
import io.metersphere.system.dto.builder.LogDTOBuilder;
import io.metersphere.system.log.constants.OperationLogModule;
import io.metersphere.system.log.constants.OperationLogType;
@ -79,15 +80,15 @@ public class CaseReviewModuleLogService {
/**
* 评审删除模块日志
*
* @param caseReviews
* @param deleteModule
* @param projectId
* @param userId
* @param path
*/
public void batchDelLog(List<CaseReview> caseReviews, String projectId, String userId, String path) {
public void batchDelLog(List<CaseReviewModule> deleteModule, String projectId, String userId, String path) {
Project project = projectMapper.selectByPrimaryKey(projectId);
List<LogDTO> dtoList = new ArrayList<>();
caseReviews.forEach(item -> {
deleteModule.forEach(item -> {
LogDTO dto = new LogDTO(
projectId,
project.getOrganizationId(),
@ -95,7 +96,7 @@ public class CaseReviewModuleLogService {
userId,
OperationLogType.DELETE.name(),
OperationLogModule.CASE_MANAGEMENT_REVIEW_REVIEW_MODULE,
item.getName());
item.getName() + " " + Translator.get("log.delete_module"));
dto.setPath(path);
dto.setMethod(HttpMethodConstants.GET.name());
dto.setOriginalValue(JSON.toJSONBytes(item));

View File

@ -119,8 +119,8 @@ public class CaseReviewModuleService extends ModuleTreeService {
public void deleteModule(String moduleId, String userId) {
CaseReviewModule deleteModule = caseReviewModuleMapper.selectByPrimaryKey(moduleId);
if (deleteModule != null) {
List<CaseReview> caseReviews = this.deleteModuleByIds(Collections.singletonList(moduleId), new ArrayList<>(), deleteModule.getProjectId());
caseReviewModuleLogService.batchDelLog(caseReviews, deleteModule.getProjectId(), userId, "/case/review/module/delete/" + moduleId);
this.deleteModuleByIds(Collections.singletonList(moduleId), new ArrayList<>(), deleteModule.getProjectId());
caseReviewModuleLogService.batchDelLog(List.of(deleteModule), deleteModule.getProjectId(), userId, "/case/review/module/delete/" + moduleId);
}
}

View File

@ -6,6 +6,7 @@ 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.sdk.util.Translator;
import io.metersphere.system.dto.builder.LogDTOBuilder;
import io.metersphere.system.log.constants.OperationLogModule;
import io.metersphere.system.log.constants.OperationLogType;
@ -106,6 +107,7 @@ public class FunctionalCaseModuleLogService {
/**
* 功能用例模块删除日志
*
* @param deleteModule
* @param projectId
* @param userId
@ -122,7 +124,7 @@ public class FunctionalCaseModuleLogService {
userId,
type,
OperationLogModule.CASE_MANAGEMENT_CASE_MODULE,
item.getName());
item.getName() + " " + Translator.get("log.delete_module"));
dto.setPath(path);
dto.setMethod(HttpMethodConstants.GET.name());
dto.setOriginalValue(JSON.toJSONBytes(item));

View File

@ -73,7 +73,7 @@ public class TestPlanModuleLogService {
.method(requestMethod)
.path(requestUrl)
.sourceId(deleteModule.getId())
.content(deleteModule.getName())
.content(deleteModule.getName() + " " + Translator.get("log.delete_module"))
.originalValue(JSON.toJSONBytes(deleteModule))
.createUser(operator)
.build().getLogDTO();