|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|