From 0a0b048b674a92fabffab8338ee05d5f07c2773e Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Wed, 3 Jun 2020 11:44:27 +0800 Subject: [PATCH] =?UTF-8?q?fix=20api=E6=B5=8B=E8=AF=95=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../metersphere/api/service/APITestService.java | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/APITestService.java b/backend/src/main/java/io/metersphere/api/service/APITestService.java index 306fd61c94..83274c87ad 100644 --- a/backend/src/main/java/io/metersphere/api/service/APITestService.java +++ b/backend/src/main/java/io/metersphere/api/service/APITestService.java @@ -139,7 +139,9 @@ public class APITestService { if (apiTest.getName() != null) { ApiTestExample example = new ApiTestExample(); example.createCriteria() - .andNameEqualTo(apiTest.getName()); + .andNameEqualTo(apiTest.getName()) + .andProjectIdEqualTo(apiTest.getProjectId()) + .andIdNotEqualTo(apiTest.getId()); if (apiTestMapper.selectByExample(example).size() > 0) { MSException.throwException(Translator.get("api_test_name_already_exists")); } @@ -162,22 +164,10 @@ public class APITestService { test.setUpdateTime(System.currentTimeMillis()); test.setStatus(APITestStatus.Saved.name()); test.setUserId(Objects.requireNonNull(SessionUtils.getUser()).getId()); - checkApiTestPlanExist(test); apiTestMapper.insert(test); return test; } - private void checkApiTestPlanExist(ApiTest apiTest) { - if (apiTest.getName() != null) { - ApiTestExample example = new ApiTestExample(); - example.createCriteria() - .andNameEqualTo(apiTest.getName()); - if (apiTestMapper.selectByExample(example).size() > 0) { - MSException.throwException(Translator.get("api_test_name_already_exists")); - } - } - } - private void saveFile(String testId, List files) { files.forEach(file -> { final FileMetadata fileMetadata = fileService.saveFile(file);