master
wangbing 4 years ago
parent 9bfda0171c
commit 28c2bec7b1

@ -18,6 +18,8 @@ import javafx.util.Callback;
import javafx.util.converter.DefaultStringConverter;
import xyz.wbsite.dbtool.javafx.po.ApiMethod;
import xyz.wbsite.dbtool.javafx.po.Doc;
import xyz.wbsite.dbtool.javafx.po.DocEnt;
import xyz.wbsite.dbtool.javafx.po.DocParam;
import xyz.wbsite.dbtool.javafx.tool.DocClassReader;
import xyz.wbsite.dbtool.javafx.tool.DocRequestReader;
import xyz.wbsite.dbtool.javafx.tool.DocResponseReader;
@ -176,6 +178,12 @@ public class OptionDocController {
// doc.setFind("1".equals(docRequestReader.getFindOrSearchflag()));
doc.setTitle(docRequestReader.getClassNote());
doc.setReqParams(docRequestReader.getFieldDocList());
for (String key : docRequestReader.getEnts().keySet()) {
List<DocParam> docParams = docRequestReader.getEnts().get(key);
DocEnt docEnt = new DocEnt();
docEnt.setEntParams(docParams);
doc.addParams(key.split("#")[1], docEnt);
}
}
List<File> rspfiles = Tool.findResponse(moduleFile, apiMethod.getResponse() + ".java");
@ -186,6 +194,12 @@ public class OptionDocController {
} else {
DocResponseReader docResponseReader = new DocResponseReader(rspfiles.get(0));
doc.setRspParams(docResponseReader.getFieldDocList());
for (String key : docResponseReader.getEnts().keySet()) {
List<DocParam> docParams = docResponseReader.getEnts().get(key);
DocEnt docEnt = new DocEnt();
docEnt.setEntParams(docParams);
doc.addParams(key.split("#")[1], docEnt);
}
}
doc.setCheck(true);
@ -249,6 +263,7 @@ public class OptionDocController {
initData();
}
System.out.println();
}
public List<String> findEntities(File file) {

@ -23,7 +23,6 @@ public class Doc {
this.check.set(check);
}
//目标请求对象
private String request;
//目标请求响应
@ -122,6 +121,13 @@ public class Doc {
this.entParams = entParams;
}
public void addParams(String name, DocEnt ent) {
if (this.entParams == null) {
this.entParams = new HashMap<>();
}
this.entParams.put(name, ent);
}
public String getTitle() {
return title;
}

@ -1,31 +1,16 @@
package xyz.wbsite.dbtool.javafx.po;
public class DocEnt {
private String name;
private String type;
private String note;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
import java.util.ArrayList;
import java.util.List;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public class DocEnt {
private List<DocParam> entParams = new ArrayList<>();
public String getNote() {
return note;
public List<DocParam> getEntParams() {
return entParams;
}
public void setNote(String note) {
this.note = note;
public void setEntParams(List<DocParam> entParams) {
this.entParams = entParams;
}
}

@ -54,9 +54,9 @@ public class DocRequestReader extends RequestReader {
Matcher matcher = compile.matcher(s);
if (matcher.find()) {
String type = matcher.group(1);
docParam.setName(matcher.group(2));
docParam.setType(type);
if (!Tool.getJavaField().contains(type)) {//读取自定义对象
if (type.endsWith("Request")) {
String module = null;
for (String s1 : getImportList()) {
@ -106,7 +106,6 @@ public class DocRequestReader extends RequestReader {
}
}
}
docParam.setName(matcher.group(2));
fieldDocList.add(docParam);
docParam = new DocParam();
}
@ -133,4 +132,12 @@ public class DocRequestReader extends RequestReader {
public void setClassNote(String classNote) {
this.classNote = classNote;
}
public Map<String, List<DocParam>> getEnts() {
return ents;
}
public void setEnts(Map<String, List<DocParam>> ents) {
this.ents = ents;
}
}

@ -5,16 +5,21 @@ import xyz.wbsite.dbtool.web.frame.utils.MapperUtil;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class DocResponseReader extends ResponseReader {
private List<DocParam> fieldDocList;
private Map<String, List<DocParam>> ents;
public DocResponseReader(File javaClass) {
super(javaClass);
fieldDocList = new ArrayList<>();
ents = new HashMap<>();
DocParam docParam = new DocParam();
for (String s : getBody()) {
s = s.trim();
@ -31,8 +36,59 @@ public class DocResponseReader extends ResponseReader {
Pattern compile = Pattern.compile("private\\s(.*)\\s(.*);");
Matcher matcher = compile.matcher(s);
if (matcher.find()) {
docParam.setType(matcher.group(1));
String type = matcher.group(1);
docParam.setName(matcher.group(2));
docParam.setType(type);
if (!Tool.getJavaField().contains(type)) {//读取自定义对象
if (type.endsWith("Request")) {
String module = null;
for (String s1 : getImportList()) {
Pattern compile1 = Pattern.compile("import\\s+.*\\.module\\.(.*)\\.req\\." + type);
Matcher matcher1 = compile1.matcher(s1);
if (matcher1.find()) {
module = matcher1.group(1);
}
}
if (module == null) {// 同目录下查找
List<File> files = Tool.find(this.getJavaClass().getParentFile().getParentFile(), type + ".java");
if (files.size() == 1) {
DocRequestReader docRequestReader = new DocRequestReader(files.get(0));
ents.put(docRequestReader.getModuleName() + "#" + type, docRequestReader.getFieldDocList());
}
} else {//其他模块下查找
File path = Tool.createPath(this.getJavaClass().getParentFile().getParentFile().getParentFile(), module);
List<File> files = Tool.find(path, type + ".java");
if (files.size() == 1) {
DocRequestReader docRequestReader = new DocRequestReader(files.get(0));
ents.put(docRequestReader.getModuleName() + "#" + type, docRequestReader.getFieldDocList());
}
}
} else {
String module = null;
for (String s1 : getImportList()) {
Pattern compile1 = Pattern.compile("import\\s+.*\\.module\\.(.*)\\.ent\\." + type);
Matcher matcher1 = compile1.matcher(s1);
if (matcher1.find()) {
module = matcher1.group(1);
}
}
if (module == null) {// 同目录下查找
List<File> files = Tool.find(this.getJavaClass().getParentFile().getParentFile(), type + ".java");
if (files.size() == 1) {
DocEntityReader docEntityReader = new DocEntityReader(files.get(0));
ents.put(docEntityReader.getModuleName() + "#" + type, docEntityReader.getFieldDocList());
}
} else {//其他模块下查找
File path = Tool.createPath(this.getJavaClass().getParentFile().getParentFile().getParentFile(), module);
List<File> files = Tool.find(path, type + ".java");
if (files.size() == 1) {
DocEntityReader docEntityReader = new DocEntityReader(files.get(0));
ents.put(docEntityReader.getModuleName() + "#" + type, docEntityReader.getFieldDocList());
}
}
}
}
fieldDocList.add(docParam);
docParam = new DocParam();
}
@ -51,4 +107,12 @@ public class DocResponseReader extends ResponseReader {
public void setFieldDocList(List<DocParam> fieldDocList) {
this.fieldDocList = fieldDocList;
}
public Map<String, List<DocParam>> getEnts() {
return ents;
}
public void setEnts(Map<String, List<DocParam>> ents) {
this.ents = ents;
}
}

@ -47,7 +47,7 @@
<th>说明</th>
</tr>
<tr v-for="p in select.reqParams">
<td>{{p.name}}</td>
<td v-if="p.type == 'Object'"><a href="#{{p.name}}">{{p.name}}</a></td>
<td>{{p.type}}</td>
<td v-if="p.required && p.name" style="color: red"></td>
<td v-if="!p.required && p.name"></td>
@ -72,7 +72,7 @@
<th>说明</th>
</tr>
<tr v-for="p in select.rspParams">
<td v-if="p.type == 'Object'"><a href="#User">{{p.name}}</a></td>
<td v-if="p.type == 'Object'"><a href="#{{p.name}}">{{p.name}}</a></td>
<td v-if="p.type != 'Object'">{{p.name}}</td>
<td>{{p.type}}</td>
<td>{{p.note}}</td>
@ -108,16 +108,16 @@
<pre>Assert.assertTrue(!response.hasError());</pre>
</div>
<h5 id="User">附录参数(<span class="object">User</span>)</h5>
<div class="wrapper" v-for="item in select.entList">
<h5 id="User">附录参数(<span class="object">{{item.name}}</span>)</h5>
<div class="wrapper">
<table>
<tr>
<th width="200">参数</th>
<th width="100">类型</th>
<th>说明</th>
</tr>
<tr v-for="p in select.entParams">
<tr v-for="p in item.entParams">
<td v-if="p.type == 'Object'"><a href="javascript:;">{{p.name}}</a></td>
<td v-if="p.type != 'Object'">{{p.name}}</td>
<td>{{p.type}}</td>

@ -34,11 +34,11 @@ var app = new Vue({
</#list>
],
"entList": [
<#list item.entParams?keys as key>
<#list item.entParams as key,value>
{
"name": "${key}",
"params": [
<#list item.entParams[key] as param>
"entParams": [
<#list value.entParams as param>
{
"name": "${param.name?default('')}",
"type": "${param.type?default('')}",

Loading…
Cancel
Save

Powered by TurnKey Linux.