fix(接口测试): 修复接口测试在url不可重复的设定下进行批量复制时能复制成功的缺陷

--bug=1009744 --user=宋天阳 【接口定义】-接口定义URL不可重复-批量复制接口到其他模块成功,未提示接口地址重复
https://www.tapd.cn/55049933/s/1094257
This commit is contained in:
song-tianyang 2022-01-19 15:19:58 +08:00 committed by song-tianyang
parent 24c6cfaadb
commit b7b25876df
5 changed files with 21 additions and 4 deletions

View File

@ -46,10 +46,7 @@ import io.metersphere.log.vo.StatusReference;
import io.metersphere.log.vo.api.DefinitionReference; import io.metersphere.log.vo.api.DefinitionReference;
import io.metersphere.notice.sender.NoticeModel; import io.metersphere.notice.sender.NoticeModel;
import io.metersphere.notice.service.NoticeSendService; import io.metersphere.notice.service.NoticeSendService;
import io.metersphere.service.FileService; import io.metersphere.service.*;
import io.metersphere.service.QuotaService;
import io.metersphere.service.RelationshipEdgeService;
import io.metersphere.service.ScheduleService;
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest; import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
import io.metersphere.track.request.testcase.QueryTestPlanRequest; import io.metersphere.track.request.testcase.QueryTestPlanRequest;
import io.metersphere.track.service.TestPlanService; import io.metersphere.track.service.TestPlanService;
@ -1870,6 +1867,9 @@ public class ApiDefinitionService {
} }
public void batchCopy(ApiBatchRequest request) { public void batchCopy(ApiBatchRequest request) {
//检查测试项目是否开启了url可重复
ProjectService projectService = CommonBeanFactory.getBean(ProjectService.class);
projectService.checkProjectIsRepeatable(request.getProjectId());
ServiceUtils.getSelectAllIds(request, request.getCondition(), ServiceUtils.getSelectAllIds(request, request.getCondition(),
(query) -> extApiDefinitionMapper.selectIds(query)); (query) -> extApiDefinitionMapper.selectIds(query));
List<String> ids = request.getIds(); List<String> ids = request.getIds();

View File

@ -860,4 +860,15 @@ public class ProjectService {
} }
performanceReportService.cleanUpReport(time, projectId); performanceReportService.cleanUpReport(time, projectId);
} }
public void checkProjectIsRepeatable(String projectId) {
Project project = this.getProjectById(projectId);
if(project == null){
MSException.throwException(Translator.get("cannot_find_project"));
}else {
if(!project.getRepeatable()){
MSException.throwException(Translator.get("project_repeatable_is_false"));
}
}
}
} }

View File

@ -290,6 +290,8 @@ zentao_test_type_error=invalid Zentao request
#项目报告 #项目报告
enterprise_test_report=Enterprise report enterprise_test_report=Enterprise report
count=Count count=Count
cannot_find_project=Cannot find project
project_repeatable_is_false=Url repeatable not open
#环境组 #环境组
null_environment_group_name = Environment group name is null null_environment_group_name = Environment group name is null
environment_group_name = Environment group name environment_group_name = Environment group name

View File

@ -289,6 +289,8 @@ zentao_test_type_error=无效的 Zentao 请求
#项目报告 #项目报告
enterprise_test_report=项目报告 enterprise_test_report=项目报告
count=统计 count=统计
cannot_find_project=未找到测试项目
project_repeatable_is_false=项目未配置URL可重复
#环境组 #环境组
null_environment_group_name = 环境组名称不存在 null_environment_group_name = 环境组名称不存在
environment_group_name = 环境组名称 environment_group_name = 环境组名称

View File

@ -289,6 +289,8 @@ zentao_test_type_error=請求方式錯誤
#项目报告 #项目报告
enterprise_test_report=項目報告 enterprise_test_report=項目報告
count=統計 count=統計
cannot_find_project=未找到測試項目
project_repeatable_is_false=項目未配置URL可重複
#环境组 #环境组
null_environment_group_name = 環境組名稱不存在 null_environment_group_name = 環境組名稱不存在
environment_group_name = 環境組名稱 environment_group_name = 環境組名稱