fix(接口测试): 修复接口列表环境为空报错的缺陷
This commit is contained in:
parent
0cadb808ac
commit
6b247b1772
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue