mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
2.0
This commit is contained in:
@@ -22,7 +22,7 @@ public class DocItem {
|
||||
|
||||
private Collection<String> produces;
|
||||
|
||||
|
||||
private int moduleOrder;
|
||||
|
||||
List<DocParameter> requestParameters;
|
||||
List<DocParameter> responseParameters;
|
||||
|
@@ -11,4 +11,5 @@ import java.util.List;
|
||||
public class DocModule {
|
||||
private String module;
|
||||
private List<DocItem> docItems;
|
||||
private int order;
|
||||
}
|
||||
|
@@ -8,11 +8,14 @@ import com.gitee.sop.websiteserver.bean.DocModule;
|
||||
import com.gitee.sop.websiteserver.bean.DocParameter;
|
||||
import com.gitee.sop.websiteserver.bean.DocParserContext;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@@ -55,20 +58,30 @@ public class SwaggerDocParser implements DocParser {
|
||||
.entrySet()
|
||||
.stream()
|
||||
.map(entry -> {
|
||||
List<DocItem> docItemList = entry.getValue();
|
||||
DocModule docModule = new DocModule();
|
||||
docModule.setModule(entry.getKey());
|
||||
docModule.setDocItems(entry.getValue());
|
||||
docModule.setDocItems(docItemList);
|
||||
docModule.setOrder(getMuduleOrder(docItemList));
|
||||
return docModule;
|
||||
})
|
||||
}).sorted(Comparator.comparing(DocModule::getOrder))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
DocInfo docInfo = new DocInfo();
|
||||
docInfo.setTitle(title);
|
||||
docInfo.setDocModuleList(docModuleList);
|
||||
return docInfo;
|
||||
}
|
||||
|
||||
private int getMuduleOrder(List<DocItem> items) {
|
||||
if (CollectionUtils.isEmpty(items)) {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
List<DocItem> docItemList = new ArrayList<>(items);
|
||||
docItemList.sort(Comparator.comparing(DocItem::getModuleOrder));
|
||||
return docItemList.get(0).getModuleOrder();
|
||||
}
|
||||
|
||||
protected Collection<String> getHttpMethods(JSONObject pathInfo) {
|
||||
// key: get,post,head...
|
||||
List<String> retList;
|
||||
@@ -93,6 +106,7 @@ public class SwaggerDocParser implements DocParser {
|
||||
docItem.setDescription(docInfo.getString("description"));
|
||||
docItem.setMultiple(docInfo.getString("multiple") != null);
|
||||
docItem.setProduces(docInfo.getJSONArray("produces").toJavaList(String.class));
|
||||
docItem.setModuleOrder(NumberUtils.toInt(docInfo.getString("module_order"), 0));
|
||||
String moduleName = this.buildModuleName(docInfo, docRoot);
|
||||
docItem.setModule(moduleName);
|
||||
List<DocParameter> docParameterList = this.buildRequestParameterList(docInfo, docRoot);
|
||||
|
@@ -48,7 +48,7 @@ layui.config({
|
||||
html.push('<li><h2>' + module.module + '</h2></li>');
|
||||
for (var i = 0; i < docItems.length; i++) {
|
||||
var docItem = docItems[i];
|
||||
var first = j == 0 && j == 0;
|
||||
var first = j === 0 && i === 0;
|
||||
if (first) {
|
||||
firstItem = docItem;
|
||||
}
|
||||
|
Reference in New Issue
Block a user