From 6b247b17721e2eade4045f0fe7df5aa85eb121e6 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Tue, 15 Mar 2022 18:26:34 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A5=E5=8F=A3=E5=88=97=E8=A1=A8=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E4=B8=BA=E7=A9=BA=E6=8A=A5=E9=94=99=E7=9A=84=E7=BC=BA?= =?UTF-8?q?=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/service/ApiDefinitionEnvService.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionEnvService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionEnvService.java index 832b7e97e6..11c6b1b30b 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionEnvService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionEnvService.java @@ -6,6 +6,7 @@ import io.metersphere.base.domain.ApiTestEnvironmentExample; import io.metersphere.base.mapper.ApiDefinitionEnvMapper; import io.metersphere.base.mapper.ApiTestEnvironmentMapper; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -42,10 +43,12 @@ public class ApiDefinitionEnvService { if (CollectionUtils.isNotEmpty(list)) { ApiTestEnvironmentExample environmentExample = new ApiTestEnvironmentExample(); - environmentExample.createCriteria().andProjectIdEqualTo(projectId).andIdEqualTo(list.get(0).getEnvId()); - long count = apiTestEnvironmentMapper.countByExample(environmentExample); - if (count > 0) { - return list.get(0); + if (StringUtils.isNotEmpty(list.get(0).getEnvId())) { + environmentExample.createCriteria().andProjectIdEqualTo(projectId).andIdEqualTo(list.get(0).getEnvId()); + long count = apiTestEnvironmentMapper.countByExample(environmentExample); + if (count > 0) { + return list.get(0); + } } } return null;