diff --git a/backend/src/main/java/io/metersphere/api/service/ApiTestEnvironmentService.java b/backend/src/main/java/io/metersphere/api/service/ApiTestEnvironmentService.java index 7e50ea9dbd..622e0b94b1 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestEnvironmentService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestEnvironmentService.java @@ -382,9 +382,8 @@ public class ApiTestEnvironmentService { private String getSystemIdByProjectId(String projectId){ ProjectService projectService = CommonBeanFactory.getBean(ProjectService.class); - - if(projectService != null){ - Project project = projectService.getProjectById(projectId); + Project project = projectService.getProjectById(projectId); + if(project != null){ project = projectService.checkSystemId(project); return projectService.getSystemIdByProjectId(projectId); }else { diff --git a/backend/src/main/java/io/metersphere/service/ProjectService.java b/backend/src/main/java/io/metersphere/service/ProjectService.java index 0833fa6896..f7a42b8468 100644 --- a/backend/src/main/java/io/metersphere/service/ProjectService.java +++ b/backend/src/main/java/io/metersphere/service/ProjectService.java @@ -412,11 +412,13 @@ public class ProjectService { public Project getProjectById(String id) { Project project = projectMapper.selectByPrimaryKey(id); - String createUser = project.getCreateUser(); - if (StringUtils.isNotBlank(createUser)) { - User user = userMapper.selectByPrimaryKey(createUser); - if (user != null) { - project.setCreateUser(user.getName()); + if(project != null){ + String createUser = project.getCreateUser(); + if (StringUtils.isNotBlank(createUser)) { + User user = userMapper.selectByPrimaryKey(createUser); + if (user != null) { + project.setCreateUser(user.getName()); + } } } return project;