refactor(接口定义): 接口、场景批量移动增加重复校验 (#15729)

--bug=1014783 --user=王孝刚 【接口测试】接口、场景批量移动,没有校验接口是否重复
https://www.tapd.cn/55049933/s/1200080

Co-authored-by: wxg0103 <727495428@qq.com>
This commit is contained in:
MeterSphere Bot 2022-07-13 18:47:12 +08:00 committed by GitHub
parent 80896ceea1
commit ab79efcdf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 3 deletions

View File

@ -1137,6 +1137,23 @@ public class ApiAutomationService {
ApiScenarioWithBLOBs apiScenarioWithBLOBs = new ApiScenarioWithBLOBs();
BeanUtils.copyBean(apiScenarioWithBLOBs, request);
apiScenarioWithBLOBs.setUpdateTime(System.currentTimeMillis());
if (request != null && (request.getIds() != null || !request.getIds().isEmpty())) {
request.getIds().forEach(apiId -> {
ApiScenarioWithBLOBs scenario = apiScenarioMapper.selectByPrimaryKey(apiId);
if (scenario == null) {
return;
}
//检查是否同名
SaveApiScenarioRequest scenarioRequest = new SaveApiScenarioRequest();
scenarioRequest.setProjectId(scenario.getProjectId());
scenarioRequest.setName(scenario.getName());
scenarioRequest.setId(scenario.getId());
scenarioRequest.setApiScenarioModuleId(request.getApiScenarioModuleId());
scenarioRequest.setModulePath(request.getModulePath());
scenarioRequest.setVersionId(scenario.getVersionId());
checkNameExist(scenarioRequest, false);
});
}
apiScenarioMapper.updateByExampleSelective(
apiScenarioWithBLOBs,
apiScenarioExample);

View File

@ -1651,6 +1651,28 @@ public class ApiDefinitionService {
ApiDefinitionWithBLOBs definitionWithBLOBs = new ApiDefinitionWithBLOBs();
BeanUtils.copyBean(definitionWithBLOBs, request);
definitionWithBLOBs.setUpdateTime(System.currentTimeMillis());
ServiceUtils.getSelectAllIds(request, request.getCondition(),
(query) -> extApiDefinitionMapper.selectIds(query));
if (request != null && (request.getIds() != null || !request.getIds().isEmpty())) {
request.getIds().forEach(apiId -> {
ApiDefinitionWithBLOBs api = apiDefinitionMapper.selectByPrimaryKey(apiId);
if (api == null) {
return;
}
//检查是否同名
SaveApiDefinitionRequest apiDefinitionRequest = new SaveApiDefinitionRequest();
apiDefinitionRequest.setProjectId(api.getProjectId());
apiDefinitionRequest.setMethod(api.getMethod());
apiDefinitionRequest.setProtocol(api.getProtocol());
apiDefinitionRequest.setPath(api.getPath());
apiDefinitionRequest.setName(api.getName());
apiDefinitionRequest.setId(api.getId());
apiDefinitionRequest.setModuleId(request.getModuleId());
apiDefinitionRequest.setModulePath(request.getModulePath());
apiDefinitionRequest.setVersionId(api.getVersionId());
checkNameExist(apiDefinitionRequest, false);
});
}
apiDefinitionMapper.updateByExampleSelective(definitionWithBLOBs, getBatchExample(request));
}

View File

@ -227,7 +227,7 @@ upload_content_is_null=Imported content is empty
test_plan_notification=Test plan notification
task_defect_notification=Task defect notification
task_notification_=Timing task result notification
api_definition_url_not_repeating=The interface request address already exists under the same module
api_definition_url_not_repeating=The interface request address already exists
api_definition_name_not_repeating=The same name-url combination already exists under the same module
api_definition_name_already_exists=Interface names under the same module cannot be repeated
api_definition_module=The module path is

View File

@ -227,7 +227,7 @@ upload_content_is_null=导入内容为空
test_plan_notification=测试计划通知
task_defect_notification=缺陷任务通知
task_notification_=定时任务结果通知
api_definition_url_not_repeating=同一模块下接口请求地址已经存在
api_definition_url_not_repeating=接口请求地址已经存在
api_definition_name_not_repeating=同一模块下相同的名称-url组合已存在
api_definition_name_already_exists=同一模块下接口名称不能重复
api_definition_module=模块路径为

View File

@ -226,7 +226,7 @@ upload_content_is_null=導入內容為空
test_plan_notification=測試計劃通知
task_defect_notification=缺陷任務通知
task_notification_=定時任務結果通知
api_definition_url_not_repeating=同一模塊下介面請求地址已經存在
api_definition_url_not_repeating=介面請求地址已經存在
api_definition_name_not_repeating=同一模塊下相同的名稱-url組合已存在
api_definition_name_already_exists=同一模塊下介面名稱不能重複
api_definition_module=模塊路徑為