diff --git a/zyplayer-doc-dubbo/src/main/resources/doc-dubbo.html b/zyplayer-doc-dubbo/src/main/resources/doc-dubbo.html
index 3d14519b..c3179e38 100644
--- a/zyplayer-doc-dubbo/src/main/resources/doc-dubbo.html
+++ b/zyplayer-doc-dubbo/src/main/resources/doc-dubbo.html
@@ -1,4 +1,4 @@
-
+
@@ -10,101 +10,133 @@
-
-
-
- 展开
- 收起
-
-
-
-
+
+
+
+
+
diff --git a/zyplayer-doc-dubbo/src/main/resources/webjars/doc-dubbo/js/doc-dubbo-tree.js b/zyplayer-doc-dubbo/src/main/resources/webjars/doc-dubbo/js/doc-dubbo-tree.js
new file mode 100644
index 00000000..eaac135e
--- /dev/null
+++ b/zyplayer-doc-dubbo/src/main/resources/webjars/doc-dubbo/js/doc-dubbo-tree.js
@@ -0,0 +1,139 @@
+/**
+ * 以树形方式生成并展示:
+ * /api
+ * /data
+ * /getDateList
+ * post
+ * get
+ * @author 暮光:城中城
+ * @since 2018年5月26日
+*/
+
+/**
+ * 把原始的json字符串转换成对象列表的方式,方便后续使用
+ * @param json swagger的原始对象
+ * @returns
+ */
+function createTreeViewByTree(json, keywords) {
+ var pathIndex = [];
+ if (isEmptyObject(json)) {
+ return;
+ }
+ //console.log(paths);
+ for (var i = 0; i < json.length; i++) {
+ var interface = json[i].interface;
+ //console.log(key, paths[key]);
+ if (!findInPathsValue(json[i], keywords)) {
+ continue;
+ }
+ if (json[i].nodeList.length <= 0) {
+ continue;
+ }
+ var methods = json[i].nodeList[0].methods;
+ for (var j = 0; j < methods.length; j++) {
+ var interfaceTemp = interface + "." + methods[j];
+ var keyArr = interfaceTemp.split(".");
+ var nowPathObj = null;
+ keyArr.forEach(function(val, index) {
+ //console.log(val, index);
+ if(isEmpty(val) && index == 0) {
+ return;
+ }
+ var nowPath = val;
+ // if(nowPathObj == null) {
+ // nowPathObj = [];
+ // var temp = nowPathObj[0] = {};
+ // temp[nowPath] = findNode(pathIndex, nowPath);
+ // if (temp[nowPath] == null) {
+ // temp[nowPath] = {};
+ // pathIndex.push(nowPathObj);
+ // }
+ // }
+ // var tempPathObj = findNode(nowPathObj, nowPath);
+ // if(isEmpty(tempPathObj)) {
+ // var temp = [];
+ // tempPathObj = temp[0] = {};
+ // nowPathObj.push(temp);
+ // }
+ // nowPathObj = tempPathObj;
+ // nowPathObj.label = nowPath;
+ if (nowPathObj == null) {
+ nowPathObj = findNode(pathIndex, nowPath);
+ if (nowPathObj == null) {
+ nowPathObj = {label: nowPath, children: []};
+ pathIndex.push(nowPathObj);
+ }
+ nowPathObj = nowPathObj.children;
+ } else {
+ var tempPathObj = findNode(nowPathObj, nowPath);
+ if(tempPathObj == null) {
+ tempPathObj = {label: nowPath, children: []};
+ nowPathObj.push(tempPathObj);
+ }
+ nowPathObj = tempPathObj.children;
+ if (index == keyArr.length - 1) {
+ var tempPath = app.projectTreeIdIndex + ":" + interfaceTemp;
+ tempPathObj.children = null;
+ tempPathObj.method = methods[j];
+ tempPathObj.interface = tempPath;
+ app.treePathDataMap.set(tempPath, json[i]);
+ }
+ }
+ });
+ }
+ }
+ app.projectTreeIdIndex++;
+ //var htmlStr = getTreeHtmlForTree(pathIndex, app.projectTreeIdIndex);
+ console.log(pathIndex);
+ return pathIndex;
+}
+
+function findNode(arr, service){
+ for (var i = 0; i < arr.length; i++) {
+ if(arr[i].label == service) {
+ return arr[i];
+ }
+ }
+ return null;
+}
+
+/**
+ * 将对象列表递归的方式转换成文档格式html字符串
+ * @param pathData 处理后的对象列表
+ * @returns 生成的html字符串
+ */
+function getTreeHtmlForTree(pathData, treeIdStr) {
+ var tempStr = "";
+ var indexNow = 1;
+ Object.keys(pathData).forEach(function (key) {
+ var tempNode = pathData[key];
+ var tempTreeId = treeIdStr + "_" + indexNow;
+ if (isNotEmpty(tempNode.interface)) {
+ tempNode.treeId = tempTreeId;
+ tempStr += '' + key + '';
+ } else {
+ tempStr += '';
+ tempStr += '' + key + '';
+ tempStr += '';
+ tempStr += getTreeHtmlForTree(tempNode, tempTreeId);
+ tempStr += '
';
+ tempStr += '';
+ }
+ indexNow++;
+ });
+ return tempStr;
+}
+
+function findInPathsValue(pathsValue, keywords) {
+ if (isEmpty(keywords)) {
+ return true;
+ }
+ keywords = keywords.toLowerCase();
+ // 找路径和说明里面包含关键字的
+ var interface = pathsValue.interface;
+ if (isNotEmpty(interface) && interface.toLowerCase().indexOf(keywords) >= 0) {
+ return true;
+ }
+ return false;
+}
+
diff --git a/zyplayer-doc-dubbo/src/main/resources/webjars/doc-dubbo/js/doc-dubbo.js b/zyplayer-doc-dubbo/src/main/resources/webjars/doc-dubbo/js/doc-dubbo.js
index 3d4364ec..97824bdc 100644
--- a/zyplayer-doc-dubbo/src/main/resources/webjars/doc-dubbo/js/doc-dubbo.js
+++ b/zyplayer-doc-dubbo/src/main/resources/webjars/doc-dubbo/js/doc-dubbo.js
@@ -20,9 +20,9 @@ $(document).ready(function(){
globalLoadingMessager = new $.zui.Messager({type: 'primary', close: false, time: 0}).show();
showGlobalLoadingMessage('获取文档列表中,请稍候...', true);
ajaxTemp("zyplayer-doc-dubbo/doc-dubbo/getDocList", "get", "json", {}, function (json) {
- if (validateResult(json) && json.data.length >= 1) {
- dubboDocList = json.data;
- createTreeViewByTree(json.data);
+ if (validateResult(json)) {
+ dubboDocList = json.data || [];
+ createTreeViewByTree(dubboDocList);
initDashboard();
documentLoadFinish();
}
diff --git a/zyplayer-doc-manage/src/main/resources/application.yml b/zyplayer-doc-manage/src/main/resources/application.yml
index f49da431..9d9eba8a 100644
--- a/zyplayer-doc-manage/src/main/resources/application.yml
+++ b/zyplayer-doc-manage/src/main/resources/application.yml
@@ -15,7 +15,7 @@ zyplayer:
dubbo:
# 优先使用zookeeper,未配置时找nacos的配置
zookeeper:
-# url: 127.0.0.1:2181
+ url: 127.0.0.1:2181
nacos:
url: http://127.0.0.1:8848/nacos
# 服务名称,多个使用 ; 分割,nacos没办法获取所有的服务列表,所以需要指定