fix(接口测试): 修复查看报告报错的缺陷

This commit is contained in:
wxg0103 2024-03-20 18:51:19 +08:00 committed by Craftsman
parent 352eead6ea
commit d0c9c417b3
2 changed files with 4 additions and 2 deletions

View File

@ -17,6 +17,7 @@ import io.metersphere.system.service.UserLoginService;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
@ -183,7 +184,7 @@ public class ApiReportService {
//查询资源池名称
apiReportDTO.setPoolName(testResourcePoolMapper.selectByPrimaryKey(apiReportDTO.getPoolId()).getName());
//查询环境名称
apiReportDTO.setEnvironmentName(environmentMapper.selectByPrimaryKey(apiReportDTO.getEnvironmentId()).getName());
apiReportDTO.setEnvironmentName(StringUtils.isNoneBlank(apiReportDTO.getEnvironmentId()) ? environmentMapper.selectByPrimaryKey(apiReportDTO.getEnvironmentId()).getName() : null);
apiReportDTO.setCreatUserName(userMapper.selectByPrimaryKey(apiReportDTO.getCreateUser()).getName());
//需要查询出所有的步骤
if (BooleanUtils.isTrue(apiReport.getIntegrated())) {

View File

@ -20,6 +20,7 @@ import io.metersphere.system.mapper.UserMapper;
import io.metersphere.system.service.UserLoginService;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
@ -196,7 +197,7 @@ public class ApiScenarioReportService {
//查询资源池名称
scenarioReportDTO.setPoolName(testResourcePoolMapper.selectByPrimaryKey(scenarioReport.getPoolId()).getName());
//查询环境名称
scenarioReportDTO.setEnvironmentName(environmentMapper.selectByPrimaryKey(scenarioReport.getEnvironmentId()).getName());
scenarioReportDTO.setEnvironmentName(StringUtils.isNotBlank(scenarioReport.getEnvironmentId()) ? environmentMapper.selectByPrimaryKey(scenarioReport.getEnvironmentId()).getName(): null);
scenarioReportDTO.setCreatUserName(userMapper.selectByPrimaryKey(scenarioReport.getCreateUser()).getName());
return scenarioReportDTO;
}