Commit e1f0030f authored by liaozan's avatar liaozan 🏀

chore: update dependencies

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