Commit e1f0030f authored by liaozan's avatar liaozan 🏀

chore: update dependencies

parent 0304197a
...@@ -2,9 +2,7 @@ package com.schbrain.archetype.initializer; ...@@ -2,9 +2,7 @@ package com.schbrain.archetype.initializer;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
@EnableScheduling
@SpringBootApplication @SpringBootApplication
public class InitializerBackendApplication { public class InitializerBackendApplication {
......
package com.schbrain.archetype.initializer.controller; package com.schbrain.archetype.initializer.controller;
import cn.hutool.core.lang.tree.Tree; import cn.hutool.core.lang.tree.Tree;
import com.schbrain.archetype.initializer.schedule.GitlabGroupFetchTask; import com.schbrain.archetype.initializer.service.GitlabService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -16,11 +16,11 @@ import java.util.List; ...@@ -16,11 +16,11 @@ import java.util.List;
public class GitlabController { public class GitlabController {
@Autowired @Autowired
private GitlabGroupFetchTask gitlabGroupFetchTask; private GitlabService gitlabService;
@GetMapping("/gitlab/groups") @GetMapping("/gitlab/groups")
public List<Tree<Long>> groupList() { public List<Tree<Long>> groupList() {
return gitlabGroupFetchTask.getGroupTree(); return gitlabService.fetchGroups();
} }
} }
\ No newline at end of file
...@@ -111,6 +111,7 @@ public class MavenUtils { ...@@ -111,6 +111,7 @@ public class MavenUtils {
return SETTINGS_FILE; return SETTINGS_FILE;
} }
Settings settings = new Settings(); Settings settings = new Settings();
settings.setLocalRepository("/data/maven/repository");
Mirror mirror = new Mirror(); Mirror mirror = new Mirror();
mirror.setId("aliyun"); mirror.setId("aliyun");
......
package com.schbrain.archetype.initializer.schedule; package com.schbrain.archetype.initializer.service;
import cn.hutool.core.lang.tree.*; import cn.hutool.core.lang.tree.*;
import com.schbrain.common.exception.BaseException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.gitlab4j.api.GitLabApi; import org.gitlab4j.api.GitLabApi;
import org.gitlab4j.api.GroupApi; import org.gitlab4j.api.GroupApi;
import org.gitlab4j.api.models.Group;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -20,23 +17,15 @@ import java.util.stream.Collectors; ...@@ -20,23 +17,15 @@ import java.util.stream.Collectors;
*/ */
@Slf4j @Slf4j
@Component @Component
public class GitlabGroupFetchTask { public class GitlabService {
@Autowired @Autowired
private GitLabApi gitLabApi; private GitLabApi gitLabApi;
private List<Tree<Long>> groupTree = Collections.emptyList(); public List<Tree<Long>> fetchGroups() {
public List<Tree<Long>> getGroupTree() {
return groupTree;
}
@Scheduled(fixedRate = 1, timeUnit = TimeUnit.HOURS)
public void fetchGroups() {
try { try {
GroupApi groupApi = gitLabApi.getGroupApi(); GroupApi groupApi = gitLabApi.getGroupApi();
List<Group> groups = groupApi.getGroups(); List<TreeNode<Long>> treeNodes = groupApi.getGroupsStream()
List<TreeNode<Long>> treeNodes = groups.stream()
.map(group -> { .map(group -> {
TreeNode<Long> treeNode = new TreeNode<>(); TreeNode<Long> treeNode = new TreeNode<>();
treeNode.setId(group.getId()); treeNode.setId(group.getId());
...@@ -44,9 +33,9 @@ public class GitlabGroupFetchTask { ...@@ -44,9 +33,9 @@ public class GitlabGroupFetchTask {
treeNode.setParentId(group.getParentId()); treeNode.setParentId(group.getParentId());
return treeNode; return treeNode;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
this.groupTree = TreeUtil.build(treeNodes, null); return TreeUtil.build(treeNodes, null);
} catch (Exception e) { } catch (Exception e) {
log.warn("Failed to fetch Gitlab groups", e); throw new BaseException("Failed to fetch Gitlab groups", e);
} }
} }
......
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
"@highlightjs/vue-plugin": "^2.1.0" "@highlightjs/vue-plugin": "^2.1.0"
}, },
"devDependencies": { "devDependencies": {
"@vitejs/plugin-vue": "^3.1.2", "@vitejs/plugin-vue": "^3.2.0",
"typescript": "^4.8.4", "typescript": "^4.8.4",
"vite": "^3.1.8", "vite": "^3.2.2",
"vue-tsc": "^1.0.8" "vue-tsc": "^1.0.9"
} }
} }
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment