fix(接口测试): 修复接口列表环境为空报错的缺陷
This commit is contained in:
parent
e97cbeb964
commit
d8c0130e1c
|
@ -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,12 +43,14 @@ public class ApiDefinitionEnvService {
|
|||
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
ApiTestEnvironmentExample environmentExample = new ApiTestEnvironmentExample();
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue