com.gitee.easyopen.doc.ResultHtmlBuilder Maven / Gradle / Ivy
package com.gitee.easyopen.doc;
import java.util.List;
/**
*
${resultDefinition.name}
${resultDefinition.dataType}
#if(${resultDefinition.dataType} == 'array')
名称
类型
示例值
描述
#foreach($elDefinition in ${resultDefinition.elements})
${elDefinition.name}
${elDefinition.dataType}
${elDefinition.example}
${elDefinition.description}
#end
#else
${resultDefinition.example}
#end
${resultDefinition.description}
*
* @author tanghc
*
*/
public class ResultHtmlBuilder {
public String buildHtml(ApiDocFieldDefinition definition) {
StringBuilder html = new StringBuilder();
html.append("")
.append(""+definition.getName()+" ")
.append(""+definition.getDataType()+" ")
.append(""+buildExample(definition)+" ")
.append(""+definition.getDescription()+" ");
html.append(" ");
return html.toString();
}
protected String buildExample(ApiDocFieldDefinition definition) {
StringBuilder html = new StringBuilder();
if(definition.getElements().size() > 0) {
html.append("")
.append("")
.append("名称 ")
.append("类型 ")
.append("示例值 ")
.append("描述 ")
.append(" ");
List els = definition.getElements();
for (ApiDocFieldDefinition apiDocFieldDefinition : els) {
html.append("")
.append(""+apiDocFieldDefinition.getName()+" ")
.append(""+apiDocFieldDefinition.getDataType()+" ")
.append(""+buildExample(apiDocFieldDefinition)+" ")
.append(""+apiDocFieldDefinition.getDescription()+" ")
.append(" ");
}
html.append("
");
}else{
html.append(buildExampleValue(definition));
}
return html.toString();
}
protected String buildExampleValue(ApiDocFieldDefinition definition) {
return definition.getExample();
}
}