refactor(接口测试): 增加新增的变更历史
This commit is contained in:
parent
68bcf10ca1
commit
d3bf4cc11c
|
@ -33,6 +33,7 @@ import io.metersphere.sdk.constants.ModuleConstants;
|
||||||
import io.metersphere.sdk.exception.MSException;
|
import io.metersphere.sdk.exception.MSException;
|
||||||
import io.metersphere.sdk.util.BeanUtils;
|
import io.metersphere.sdk.util.BeanUtils;
|
||||||
import io.metersphere.sdk.util.JSON;
|
import io.metersphere.sdk.util.JSON;
|
||||||
|
import io.metersphere.sdk.util.SubListUtils;
|
||||||
import io.metersphere.sdk.util.Translator;
|
import io.metersphere.sdk.util.Translator;
|
||||||
import io.metersphere.system.domain.User;
|
import io.metersphere.system.domain.User;
|
||||||
import io.metersphere.system.dto.sdk.ApiDefinitionCaseDTO;
|
import io.metersphere.system.dto.sdk.ApiDefinitionCaseDTO;
|
||||||
|
@ -178,6 +179,11 @@ public class ApiDefinitionImportUtilService {
|
||||||
ApiDetailWithDataUpdate apiDetailWithDataUpdate = new ApiDetailWithDataUpdate();
|
ApiDetailWithDataUpdate apiDetailWithDataUpdate = new ApiDetailWithDataUpdate();
|
||||||
getNeedUpdateData(request, apiDealWithData, apiDetailWithDataUpdate);
|
getNeedUpdateData(request, apiDealWithData, apiDetailWithDataUpdate);
|
||||||
|
|
||||||
|
//不用的数据清空,保证内存回收
|
||||||
|
apiLists = new ArrayList<>();
|
||||||
|
apiModules = new ArrayList<>();
|
||||||
|
importData = new ArrayList<>();
|
||||||
|
|
||||||
//数据入库
|
//数据入库
|
||||||
insertData(modulePathMap, idModuleMap, apiDetailWithDataUpdate, request);
|
insertData(modulePathMap, idModuleMap, apiDetailWithDataUpdate, request);
|
||||||
|
|
||||||
|
@ -388,7 +394,7 @@ public class ApiDefinitionImportUtilService {
|
||||||
|
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
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));
|
List<Map> createResources = new ArrayList<>(JSON.parseArray(JSON.toJSONString(createLists), Map.class));
|
||||||
User user = userMapper.selectByPrimaryKey(request.getUserId());
|
User user = userMapper.selectByPrimaryKey(request.getUserId());
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class ApiDefinitionLogService {
|
||||||
OperationLogModule.API_TEST_MANAGEMENT_DEFINITION,
|
OperationLogModule.API_TEST_MANAGEMENT_DEFINITION,
|
||||||
request.getName());
|
request.getName());
|
||||||
|
|
||||||
dto.setHistory(false);
|
dto.setHistory(true);
|
||||||
dto.setMethod(HttpMethodConstants.POST.name());
|
dto.setMethod(HttpMethodConstants.POST.name());
|
||||||
dto.setOriginalValue(JSON.toJSONBytes(request));
|
dto.setOriginalValue(JSON.toJSONBytes(request));
|
||||||
return dto;
|
return dto;
|
||||||
|
@ -161,7 +161,7 @@ public class ApiDefinitionLogService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void batchMoveLog(List<String> ids, String userId, String projectId) {
|
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) {
|
public LogDTO followLog(String id) {
|
||||||
|
|
|
@ -62,6 +62,7 @@ public class ApiTestCaseLogService {
|
||||||
request.getName());
|
request.getName());
|
||||||
dto.setMethod(HttpMethodConstants.POST.name());
|
dto.setMethod(HttpMethodConstants.POST.name());
|
||||||
dto.setOriginalValue(JSON.toJSONBytes(request));
|
dto.setOriginalValue(JSON.toJSONBytes(request));
|
||||||
|
dto.setHistory(true);
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -206,7 +206,7 @@ public class ApiScenarioLogService {
|
||||||
return dto;
|
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)) {
|
if (StringUtils.isBlank(logModule)) {
|
||||||
logModule = OperationLogModule.API_SCENARIO_MANAGEMENT_SCENARIO;
|
logModule = OperationLogModule.API_SCENARIO_MANAGEMENT_SCENARIO;
|
||||||
|
@ -227,7 +227,7 @@ public class ApiScenarioLogService {
|
||||||
.content(item.getName())
|
.content(item.getName())
|
||||||
.createUser(logInsertModule.getOperator())
|
.createUser(logInsertModule.getOperator())
|
||||||
.build().getLogDTO();
|
.build().getLogDTO();
|
||||||
dto.setHistory(false);
|
dto.setHistory(isHistory);
|
||||||
logs.add(dto);
|
logs.add(dto);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -12,7 +12,6 @@ import io.metersphere.system.log.constants.OperationLogType;
|
||||||
import io.metersphere.system.log.dto.LogDTO;
|
import io.metersphere.system.log.dto.LogDTO;
|
||||||
import io.metersphere.system.log.service.OperationLogService;
|
import io.metersphere.system.log.service.OperationLogService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -67,7 +66,6 @@ public class ApiScenarioReportLogService {
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Async
|
|
||||||
public void batchDeleteLog(List<String> ids, String userId, String projectId) {
|
public void batchDeleteLog(List<String> ids, String userId, String projectId) {
|
||||||
Project project = projectMapper.selectByPrimaryKey(projectId);
|
Project project = projectMapper.selectByPrimaryKey(projectId);
|
||||||
List<ApiScenarioReport> apiReports = extApiScenarioReportMapper.selectApiReportByIds(ids);
|
List<ApiScenarioReport> apiReports = extApiScenarioReportMapper.selectApiReportByIds(ids);
|
||||||
|
|
|
@ -2278,7 +2278,7 @@ public class ApiScenarioService extends MoveNodeService {
|
||||||
long moveTime = System.currentTimeMillis();
|
long moveTime = System.currentTimeMillis();
|
||||||
ApiScenarioBatchOperationResponse response =
|
ApiScenarioBatchOperationResponse response =
|
||||||
ApiScenarioBatchOperationUtils.executeWithBatchOperationResponse(scenarioIds, sublist -> move(sublist, request, moveTime, logInsertModule.getOperator()));
|
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;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2292,7 +2292,7 @@ public class ApiScenarioService extends MoveNodeService {
|
||||||
request.setSelectIds(scenarioIds);
|
request.setSelectIds(scenarioIds);
|
||||||
ApiScenarioBatchOperationResponse response =
|
ApiScenarioBatchOperationResponse response =
|
||||||
ApiScenarioBatchOperationUtils.executeWithBatchOperationResponse(scenarioIds, sublist -> copyAndInsert(sublist, request, logInsertModule.getOperator()));
|
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;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2505,7 +2505,7 @@ public class ApiScenarioService extends MoveNodeService {
|
||||||
scenarioIds,
|
scenarioIds,
|
||||||
sublist -> operationGC(sublist, isDeleteOperation, deleteTime, logInsertModule.getOperator()));
|
sublist -> operationGC(sublist, isDeleteOperation, deleteTime, logInsertModule.getOperator()));
|
||||||
apiScenarioLogService.saveBatchOperationLog(response, request.getProjectId(),
|
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;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2540,7 +2540,7 @@ public class ApiScenarioService extends MoveNodeService {
|
||||||
ApiScenarioBatchOperationResponse response = ApiScenarioBatchOperationUtils.executeWithBatchOperationResponse(
|
ApiScenarioBatchOperationResponse response = ApiScenarioBatchOperationUtils.executeWithBatchOperationResponse(
|
||||||
scenarioIds,
|
scenarioIds,
|
||||||
sublist -> delete(sublist, request.getProjectId(), logInsertModule.getOperator()));
|
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;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue