refactor(接口测试): 增加新增的变更历史

This commit is contained in:
wxg0103 2024-04-10 11:36:48 +08:00 committed by 刘瑞斌
parent 68bcf10ca1
commit d3bf4cc11c
6 changed files with 16 additions and 11 deletions

View File

@ -33,6 +33,7 @@ import io.metersphere.sdk.constants.ModuleConstants;
import io.metersphere.sdk.exception.MSException;
import io.metersphere.sdk.util.BeanUtils;
import io.metersphere.sdk.util.JSON;
import io.metersphere.sdk.util.SubListUtils;
import io.metersphere.sdk.util.Translator;
import io.metersphere.system.domain.User;
import io.metersphere.system.dto.sdk.ApiDefinitionCaseDTO;
@ -178,6 +179,11 @@ public class ApiDefinitionImportUtilService {
ApiDetailWithDataUpdate apiDetailWithDataUpdate = new ApiDetailWithDataUpdate();
getNeedUpdateData(request, apiDealWithData, apiDetailWithDataUpdate);
//不用的数据清空保证内存回收
apiLists = new ArrayList<>();
apiModules = new ArrayList<>();
importData = new ArrayList<>();
//数据入库
insertData(modulePathMap, idModuleMap, apiDetailWithDataUpdate, request);
@ -388,7 +394,7 @@ public class ApiDefinitionImportUtilService {
sqlSession.flushStatements();
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
operationLogService.batchAdd(operationLogs);
SubListUtils.dealForSubList(operationLogs, 500, operationLogService::batchAdd);
//发送通知
List<Map> createResources = new ArrayList<>(JSON.parseArray(JSON.toJSONString(createLists), Map.class));
User user = userMapper.selectByPrimaryKey(request.getUserId());

View File

@ -55,7 +55,7 @@ public class ApiDefinitionLogService {
OperationLogModule.API_TEST_MANAGEMENT_DEFINITION,
request.getName());
dto.setHistory(false);
dto.setHistory(true);
dto.setMethod(HttpMethodConstants.POST.name());
dto.setOriginalValue(JSON.toJSONBytes(request));
return dto;
@ -161,7 +161,7 @@ public class ApiDefinitionLogService {
}
public void batchMoveLog(List<String> ids, String userId, String projectId) {
saveBatchLog(projectId, ids, userId, OperationLogType.UPDATE.name(), false, null);
saveBatchLog(projectId, ids, userId, OperationLogType.UPDATE.name(), true, null);
}
public LogDTO followLog(String id) {

View File

@ -62,6 +62,7 @@ public class ApiTestCaseLogService {
request.getName());
dto.setMethod(HttpMethodConstants.POST.name());
dto.setOriginalValue(JSON.toJSONBytes(request));
dto.setHistory(true);
return dto;
}

View File

@ -206,7 +206,7 @@ public class ApiScenarioLogService {
return dto;
}
public void saveBatchOperationLog(ApiScenarioBatchOperationResponse response, String projectId, String operationType, LogInsertModule logInsertModule, String logModule) {
public void saveBatchOperationLog(ApiScenarioBatchOperationResponse response, String projectId, String operationType, LogInsertModule logInsertModule, String logModule, boolean isHistory) {
if (StringUtils.isBlank(logModule)) {
logModule = OperationLogModule.API_SCENARIO_MANAGEMENT_SCENARIO;
@ -227,7 +227,7 @@ public class ApiScenarioLogService {
.content(item.getName())
.createUser(logInsertModule.getOperator())
.build().getLogDTO();
dto.setHistory(false);
dto.setHistory(isHistory);
logs.add(dto);
}
);

View File

@ -12,7 +12,6 @@ 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.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
@ -67,7 +66,6 @@ public class ApiScenarioReportLogService {
return dto;
}
@Async
public void batchDeleteLog(List<String> ids, String userId, String projectId) {
Project project = projectMapper.selectByPrimaryKey(projectId);
List<ApiScenarioReport> apiReports = extApiScenarioReportMapper.selectApiReportByIds(ids);

View File

@ -2278,7 +2278,7 @@ public class ApiScenarioService extends MoveNodeService {
long moveTime = System.currentTimeMillis();
ApiScenarioBatchOperationResponse response =
ApiScenarioBatchOperationUtils.executeWithBatchOperationResponse(scenarioIds, sublist -> move(sublist, request, moveTime, logInsertModule.getOperator()));
apiScenarioLogService.saveBatchOperationLog(response, request.getProjectId(), OperationLogType.UPDATE.name(), logInsertModule, null);
apiScenarioLogService.saveBatchOperationLog(response, request.getProjectId(), OperationLogType.UPDATE.name(), logInsertModule, null, true);
return response;
}
@ -2292,7 +2292,7 @@ public class ApiScenarioService extends MoveNodeService {
request.setSelectIds(scenarioIds);
ApiScenarioBatchOperationResponse response =
ApiScenarioBatchOperationUtils.executeWithBatchOperationResponse(scenarioIds, sublist -> copyAndInsert(sublist, request, logInsertModule.getOperator()));
apiScenarioLogService.saveBatchOperationLog(response, request.getProjectId(), OperationLogType.ADD.name(), logInsertModule, null);
apiScenarioLogService.saveBatchOperationLog(response, request.getProjectId(), OperationLogType.ADD.name(), logInsertModule, null, true);
return response;
}
@ -2505,7 +2505,7 @@ public class ApiScenarioService extends MoveNodeService {
scenarioIds,
sublist -> operationGC(sublist, isDeleteOperation, deleteTime, logInsertModule.getOperator()));
apiScenarioLogService.saveBatchOperationLog(response, request.getProjectId(),
isDeleteOperation ? OperationLogType.DELETE.name() : OperationLogType.RECOVER.name(), logInsertModule, OperationLogModule.API_TEST_SCENARIO_RECYCLE);
isDeleteOperation ? OperationLogType.DELETE.name() : OperationLogType.RECOVER.name(), logInsertModule, OperationLogModule.API_TEST_SCENARIO_RECYCLE, false);
return response;
}
@ -2540,7 +2540,7 @@ public class ApiScenarioService extends MoveNodeService {
ApiScenarioBatchOperationResponse response = ApiScenarioBatchOperationUtils.executeWithBatchOperationResponse(
scenarioIds,
sublist -> delete(sublist, request.getProjectId(), logInsertModule.getOperator()));
apiScenarioLogService.saveBatchOperationLog(response, request.getProjectId(), OperationLogType.DELETE.name(), logInsertModule, OperationLogModule.API_TEST_SCENARIO_RECYCLE);
apiScenarioLogService.saveBatchOperationLog(response, request.getProjectId(), OperationLogType.DELETE.name(), logInsertModule, OperationLogModule.API_TEST_SCENARIO_RECYCLE, false);
return response;
}