Parcourir la source

fix: GitlabService 重写

刘一也 il y a 3 ans
Parent
commit
edd310a4e4

+ 15 - 3
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/service/GitlabService.java

@@ -3,8 +3,11 @@ package cn.seecoder.seecoderportalserver.service;
 import com.nju.edu.gitlab.SeecoderGitlabClient;
 import com.nju.edu.gitlab.SeecoderGitlabException;
 import com.nju.edu.gitlab.vo.GitlabUserVO;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import javax.annotation.PostConstruct;
 
 /**
  * @author kunduin
@@ -12,10 +15,19 @@ import org.springframework.stereotype.Service;
 @Service
 public class GitlabService {
 
-    private final SeecoderGitlabClient client;
+    private static final Logger log = LoggerFactory.getLogger(GitlabService.class);
+    @Value("${seec.gitlab.url}")
+    private String url;
+    @Value("${seec.gitlab.host}")
+    private String host;
+    @Value("${seec.gitlab.token}")
+    String token;
+    private SeecoderGitlabClient client;
 
-    public GitlabService(@Value("${seec.gitlab.url}") String url, @Value("${seec.gitlab.token}") String token) {
-        this.client = new SeecoderGitlabClient(url, token);
+    @PostConstruct
+    public void initClient() {
+        log.info(String.format("GitlabService initClient host: %s, token: %s", host, token));
+        client = new SeecoderGitlabClient(host, token);
     }
 
     public GitlabUserVO createGitlabUser(int userId, String username, String password, String email) throws SeecoderGitlabException {

+ 1 - 0
seecoder-portal-server/src/main/resources/application.yml

@@ -3,6 +3,7 @@ seec:
   secret: UenM4KGb6DskRWUenM4KGb6DskRWUenM4KGb6DskRWUenM4KGb6DskRWUenM4KGb6DskRWUenM4KGb6DskRWUenM4KGb6DskRWUenM4KGb6DskRWUenM4KGb6DskRW
   gitlab:
     url: http://seecoder-gitlab-server.seec.seecoder.cn
+    host: http://environment-13-31.seec.svc.cluster.local:8080
     token: wXDeETv2Kmt-JhiApJ9H