mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
4.0.3
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
<groupId>com.gitee.sop</groupId>
|
||||
<artifactId>sop-bridge-nacos</artifactId>
|
||||
<!--<artifactId>sop-bridge-eureka</artifactId>-->
|
||||
<version>4.0.2-SNAPSHOT</version>
|
||||
<version>4.0.3-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@@ -0,0 +1,13 @@
|
||||
package com.gitee.sop.websiteserver.bean;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author tanghc
|
||||
*/
|
||||
@Data
|
||||
public class BizCode {
|
||||
private String code;
|
||||
private String msg;
|
||||
private String solution;
|
||||
}
|
@@ -30,6 +30,7 @@ public class DocItem {
|
||||
|
||||
List<DocParameter> requestParameters;
|
||||
List<DocParameter> responseParameters;
|
||||
List<BizCode> bizCodeList;
|
||||
|
||||
public String getNameVersion() {
|
||||
return name + version;
|
||||
|
@@ -1,7 +1,9 @@
|
||||
package com.gitee.sop.websiteserver.manager;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.gitee.sop.websiteserver.bean.BizCode;
|
||||
import com.gitee.sop.websiteserver.bean.DocInfo;
|
||||
import com.gitee.sop.websiteserver.bean.DocItem;
|
||||
import com.gitee.sop.websiteserver.bean.DocModule;
|
||||
@@ -121,6 +123,10 @@ public class SwaggerDocParser implements DocParser {
|
||||
docItem.setDescription(docInfo.getString("description"));
|
||||
docItem.setMultiple(docInfo.getString("multiple") != null);
|
||||
docItem.setProduces(docInfo.getJSONArray("produces").toJavaList(String.class));
|
||||
String bizCodeStr = docInfo.getString("biz_code");
|
||||
if (bizCodeStr != null) {
|
||||
docItem.setBizCodeList(JSON.parseArray(bizCodeStr, BizCode.class));
|
||||
}
|
||||
docItem.setModuleOrder(NumberUtils.toInt(docInfo.getString("module_order"), 0));
|
||||
docItem.setApiOrder(NumberUtils.toInt(docInfo.getString("api_order"), 0));
|
||||
String moduleName = this.buildModuleName(docInfo, docRoot);
|
||||
@@ -208,6 +214,8 @@ public class SwaggerDocParser implements DocParser {
|
||||
|
||||
protected List<DocParameter> buildDocParameters(String ref, JSONObject docRoot, boolean doSubRef) {
|
||||
JSONObject responseObject = docRoot.getJSONObject("definitions").getJSONObject(ref);
|
||||
String className = responseObject.getString("title");
|
||||
JSONObject extProperties = docRoot.getJSONObject(className);
|
||||
JSONObject properties = responseObject.getJSONObject("properties");
|
||||
List<DocParameter> docParameterList = new ArrayList<>();
|
||||
if (properties == null) {
|
||||
@@ -224,10 +232,20 @@ public class SwaggerDocParser implements DocParser {
|
||||
JSONObject fieldInfo = properties.getJSONObject(fieldName);
|
||||
DocParameter docParameter = fieldInfo.toJavaObject(DocParameter.class);
|
||||
docParameter.setName(fieldName);
|
||||
if (extProperties != null) {
|
||||
JSONObject prop = extProperties.getJSONObject(fieldName);
|
||||
if (prop != null) {
|
||||
String maxLength = prop.getString("maxLength");
|
||||
docParameter.setMaxLength(maxLength == null ? "-" : maxLength);
|
||||
String required = prop.getString("required");
|
||||
if (required != null) {
|
||||
docParameter.setRequired(Boolean.parseBoolean(required));
|
||||
}
|
||||
}
|
||||
}
|
||||
docParameterList.add(docParameter);
|
||||
RefInfo refInfo = this.getRefInfo(fieldInfo);
|
||||
if (refInfo != null && doSubRef) {
|
||||
// 如果是树状菜单的话,这里可能触发死循环
|
||||
String subRef = refInfo.ref;
|
||||
boolean nextDoRef = !Objects.equals(ref, subRef);
|
||||
List<DocParameter> refs = buildDocParameters(subRef, docRoot, nextDoRef);
|
||||
|
@@ -367,6 +367,29 @@
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<div class="site-title">
|
||||
<fieldset class="layui-elem-field layui-field-title site-title">
|
||||
<legend>业务错误码</legend>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="site-text">
|
||||
<p>
|
||||
<a href="code.html" target="_blank">公共错误码</a>
|
||||
</p>
|
||||
<div class="site-text">
|
||||
<table id="bizCode" class="layui-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>错误码</th>
|
||||
<th>错误描述</th>
|
||||
<th>解决方案</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div><!-- layui-main end~ -->
|
||||
|
@@ -16,6 +16,7 @@ function selectItem(docItem, layui) {
|
||||
createRequestParameter(docItem);
|
||||
createResponseParameter(docItem);
|
||||
createResponseCode(docItem);
|
||||
buildBizCode(docItem);
|
||||
|
||||
var $li = $('#docItemTree').find('li[nameversion="'+nameVersion+'"]');
|
||||
$li.addClass('layui-this').siblings().removeClass('layui-this');
|
||||
@@ -124,3 +125,21 @@ function buildExample(parameter) {
|
||||
return '\"' + parameter.example + '\"';
|
||||
}
|
||||
}
|
||||
|
||||
function buildBizCode(docItem) {
|
||||
var html = []
|
||||
var bizCodeList = docItem.bizCodeList;
|
||||
if (bizCodeList && bizCodeList.length > 0) {
|
||||
for (var i = 0; i < bizCodeList.length; i++) {
|
||||
var bizCode = bizCodeList[i];
|
||||
html.push('<tr>')
|
||||
html.push('<td>'+bizCode.code+'</td>')
|
||||
html.push('<td>'+bizCode.msg+'</td>')
|
||||
html.push('<td>'+bizCode.solution+'</td>')
|
||||
html.push('</tr>')
|
||||
}
|
||||
$('#bizCode').find('tbody').html(html.join(''));
|
||||
} else {
|
||||
$('#bizCode').find('tbody').html('<tr><td colspan="3" style="text-align: center">暂无数据</td></tr>');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user