Skip to content

Commit

Permalink
Merge pull request TongchengOpenSource#697 from bugDesigner1/master
Browse files Browse the repository at this point in the history
feat-When uploading Torna, batch uploading of documents is supported
  • Loading branch information
shalousun authored Dec 28, 2023
2 parents 938b647 + f19000f commit 733f6c8
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@
<artifactId>org.eclipse.jgit</artifactId>
<version>5.13.2.202306221912-r</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.4</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/ly/doc/model/ApiConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,12 @@ public class ApiConfig {
*/
private String baseDir;

/**
* upload api split number
* @since 3.0.2
*/
private Integer apiUploadNums;

public static ApiConfig getInstance() {
return instance;
}
Expand Down Expand Up @@ -1022,4 +1028,12 @@ public String getBaseDir() {
public void setBaseDir(String baseDir) {
this.baseDir = baseDir;
}

public Integer getApiUploadNums() {
return apiUploadNums;
}

public void setApiUploadNums(Integer apiUploadNums) {
this.apiUploadNums = apiUploadNums;
}
}
14 changes: 14 additions & 0 deletions src/main/java/com/ly/doc/utils/TornaUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@

import com.thoughtworks.qdox.model.JavaMethod;
import com.thoughtworks.qdox.model.JavaParameter;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;

import static com.ly.doc.constants.TornaConstants.ENUM_PUSH;
Expand All @@ -58,6 +60,18 @@
public class TornaUtil {

public static void pushToTorna(TornaApi tornaApi, ApiConfig apiConfig, JavaProjectBuilder builder) {
if(ObjectUtils.isEmpty(apiConfig.getApiUploadNums())){
pushToTornaAll(tornaApi, apiConfig, builder);
return;
}

ListUtils.partition(tornaApi.getApis(), apiConfig.getApiUploadNums()).stream().forEach(apis -> {
tornaApi.setApis(apis);
pushToTornaAll(tornaApi, apiConfig, builder);
});
}

private static void pushToTornaAll(TornaApi tornaApi, ApiConfig apiConfig, JavaProjectBuilder builder) {
//Build push document information
Map<String, String> requestJson = TornaConstants.buildParams(PUSH, new Gson().toJson(tornaApi), apiConfig);
//Push dictionary information
Expand Down

0 comments on commit 733f6c8

Please sign in to comment.