Ver Fonte

fix: 获取gitlab用户改成通过门户id的方式

370774330@qq.com há 5 anos atrás
pai
commit
bf1a877c5e

+ 4 - 3
seecoder-gitlab-server/src/main/java/com/nju/edu/gitlab/service/impl/ProjectServiceImpl.java

@@ -60,7 +60,7 @@ public class ProjectServiceImpl implements ProjectService {
         Integer namespaceId=gitlabUser.getNamespaceId();
         Project project;
         try{
-            gitlabApi.setSudoAsId(userId);
+            gitlabApi.setSudoAsId(gitlabUser.getGitlabUserId());
             project=gitlabApi.getProjectApi().forkProject(projectId,namespaceId);
             project.setVisibility(Visibility.PRIVATE);
             project=gitlabApi.getProjectApi().updateProject(project);
@@ -259,8 +259,9 @@ public class ProjectServiceImpl implements ProjectService {
     }
 
     private GitlabUser getGitlabUser(int userId) throws GitLabApiException {
-        if(gitlabUserRepository.existsById(userId))
-            return gitlabUserRepository.getOne(userId);
+        GitlabUser user = gitlabUserRepository.findByUserId(userId);
+        if(user != null)
+            return user;
         else
             throw new GitLabApiException("user not exists");
     }