fix: application 列表接口支持名称搜索
1. application 列表接口支持名称搜索 2. application 列表接口返回 icon 字段 3. master 改为 main, 初始分支是 main 分支
This commit is contained in:
@@ -93,6 +93,7 @@ public class GitServiceImpl implements IGitService {
|
|||||||
return Git.init()
|
return Git.init()
|
||||||
.setBare(true)
|
.setBare(true)
|
||||||
.setDirectory(repoDir)
|
.setDirectory(repoDir)
|
||||||
|
.setInitialBranch("main")
|
||||||
.call();
|
.call();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,6 +111,7 @@ public class GitServiceImpl implements IGitService {
|
|||||||
return Git.init()
|
return Git.init()
|
||||||
.setBare(true)
|
.setBare(true)
|
||||||
.setDirectory(repoDir)
|
.setDirectory(repoDir)
|
||||||
|
.setInitialBranch("main")
|
||||||
.call();
|
.call();
|
||||||
}
|
}
|
||||||
} catch (GitAPIException | IOException e) {
|
} catch (GitAPIException | IOException e) {
|
||||||
@@ -212,6 +214,7 @@ public class GitServiceImpl implements IGitService {
|
|||||||
treeWalk.setFilter(PathFilter.create("applications/"));
|
treeWalk.setFilter(PathFilter.create("applications/"));
|
||||||
treeWalk.setRecursive(true);
|
treeWalk.setRecursive(true);
|
||||||
|
|
||||||
|
Map<String, String> appIconDataMapping = T.MapUtil.newHashMap();
|
||||||
while (treeWalk.next()) {
|
while (treeWalk.next()) {
|
||||||
String fileName = treeWalk.getNameString();
|
String fileName = treeWalk.getNameString();
|
||||||
if (T.StrUtil.equals("basic.json", fileName)) {
|
if (T.StrUtil.equals("basic.json", fileName)) {
|
||||||
@@ -220,6 +223,14 @@ public class GitServiceImpl implements IGitService {
|
|||||||
basicJsonStr = T.StrUtil.emptyToDefault(basicJsonStr, T.StrUtil.EMPTY_JSON);
|
basicJsonStr = T.StrUtil.emptyToDefault(basicJsonStr, T.StrUtil.EMPTY_JSON);
|
||||||
Map basicJsonMap = T.JSONUtil.toBean(basicJsonStr, Map.class);
|
Map basicJsonMap = T.JSONUtil.toBean(basicJsonStr, Map.class);
|
||||||
|
|
||||||
|
// filter by name
|
||||||
|
if (T.StrUtil.isNotEmpty(q)) {
|
||||||
|
String appName = T.MapUtil.getStr(basicJsonMap, "name", "");
|
||||||
|
if (!appName.contains(q)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Map<Object, Object> m = T.MapUtil.newHashMap(true);
|
Map<Object, Object> m = T.MapUtil.newHashMap(true);
|
||||||
m.putAll(basicJsonMap);
|
m.putAll(basicJsonMap);
|
||||||
|
|
||||||
@@ -232,6 +243,21 @@ public class GitServiceImpl implements IGitService {
|
|||||||
m.put("commit", this.buildAswCommitInfo(commit));
|
m.put("commit", this.buildAswCommitInfo(commit));
|
||||||
|
|
||||||
resultList.add(m);
|
resultList.add(m);
|
||||||
|
} else if (T.StrUtil.equals("icon.png", fileName)) {
|
||||||
|
ObjectLoader loader = repository.open(treeWalk.getObjectId(0));
|
||||||
|
byte[] bytes = loader.getBytes();
|
||||||
|
if (T.ObjectUtil.isNotEmpty(bytes)) {
|
||||||
|
String dirPath = treeWalk.getPathString().replaceAll(fileName, "");
|
||||||
|
appIconDataMapping.put(dirPath, Base64.getEncoder().encodeToString(bytes));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Map<Object, Object> map : resultList) {
|
||||||
|
String applicationName = T.MapUtil.getStr(map, "name");
|
||||||
|
if (T.StrUtil.isNotEmpty(applicationName)) {
|
||||||
|
String iconBase64Str = appIconDataMapping.get(T.StrUtil.concat(true, "applications/", applicationName, "/"));
|
||||||
|
map.put("icon", iconBase64Str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -536,7 +562,7 @@ public class GitServiceImpl implements IGitService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<Object, Object> infoApplicationFileContent(String workspaceId, String branch, String applicationName, String commitId1111, String file) {
|
public Map<Object, Object> infoApplicationFileContent(String workspaceId, String branch, String applicationName, String commitId, String file) {
|
||||||
// applications/qq/basic.json
|
// applications/qq/basic.json
|
||||||
String path = T.StrUtil.concat(true, "applications/", applicationName, "/", file);
|
String path = T.StrUtil.concat(true, "applications/", applicationName, "/", file);
|
||||||
|
|
||||||
@@ -551,7 +577,7 @@ public class GitServiceImpl implements IGitService {
|
|||||||
try (TreeWalk treeWalk = new TreeWalk(repository);
|
try (TreeWalk treeWalk = new TreeWalk(repository);
|
||||||
RevWalk revWalk = new RevWalk(repository);
|
RevWalk revWalk = new RevWalk(repository);
|
||||||
) {
|
) {
|
||||||
RevCommit revCommit = revWalk.parseCommit(ObjectId.fromString(commitId1111));
|
RevCommit revCommit = revWalk.parseCommit(ObjectId.fromString(commitId));
|
||||||
ObjectId treeId = revCommit.getTree().getId();
|
ObjectId treeId = revCommit.getTree().getId();
|
||||||
|
|
||||||
treeWalk.addTree(treeId);
|
treeWalk.addTree(treeId);
|
||||||
|
|||||||
Reference in New Issue
Block a user