|
|
|
@ -1,10 +1,9 @@
|
|
|
|
|
package xyz.wbsite.dbtool.javafx.tool;
|
|
|
|
|
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
|
import xyz.wbsite.dbtool.web.frame.utils.FileUtil;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
import java.util.List;
|
|
|
|
@ -24,8 +23,6 @@ public class RequestReader {
|
|
|
|
|
private String className;
|
|
|
|
|
private String fatherName;
|
|
|
|
|
private List<String> body;
|
|
|
|
|
private boolean hasList = false;
|
|
|
|
|
private String findOrSearchflag = "0";
|
|
|
|
|
private String Tclass = null;
|
|
|
|
|
|
|
|
|
|
public RequestReader(File javaClass) {
|
|
|
|
@ -44,114 +41,84 @@ public class RequestReader {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void read() {
|
|
|
|
|
BufferedReader bufferedReader = null;
|
|
|
|
|
try {
|
|
|
|
|
bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(javaClass), "utf-8"));
|
|
|
|
|
|
|
|
|
|
String line = null;
|
|
|
|
|
while ((line = bufferedReader.readLine()) != null) {
|
|
|
|
|
if (line.matches("\\s*package\\s(.*);")) {
|
|
|
|
|
Pattern compile = Pattern.compile("\\s*package\\s(.*)\\.module\\.(.*).req;");
|
|
|
|
|
Matcher matcher = compile.matcher(line);
|
|
|
|
|
if (matcher.find()) {
|
|
|
|
|
domainName = matcher.group(1);
|
|
|
|
|
moduleName = matcher.group(2);
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (line.matches("import\\s.*")) {
|
|
|
|
|
if (line.contains(".ent.")) {
|
|
|
|
|
Pattern compile = Pattern.compile("import\\s+(.*\\.ent\\..*);");
|
|
|
|
|
Matcher matcher = compile.matcher(line);
|
|
|
|
|
if (matcher.find()) {
|
|
|
|
|
String group = matcher.group(1);
|
|
|
|
|
deptEntList.add(group);
|
|
|
|
|
}
|
|
|
|
|
} else if (line.contains("frame")) {
|
|
|
|
|
|
|
|
|
|
} else if (line.contains("javax.validation")) {
|
|
|
|
|
|
|
|
|
|
} else if (line.contains("org.hibernate.validator")) {
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
importList.add(line);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<String> strings = FileUtil.readFileToLines(javaClass);
|
|
|
|
|
|
|
|
|
|
Pattern p1 = Pattern.compile("package\\s+(.*)\\.module\\.(.*).req;");
|
|
|
|
|
Pattern p2 = Pattern.compile("import\\s+(.*\\.ent\\..*);");
|
|
|
|
|
Pattern p3 = Pattern.compile("public\\s+class\\s+(.*Request)\\s+extends\\s+(.*Request)\\s*\\{");
|
|
|
|
|
Pattern p4 = Pattern.compile("private\\s+(.*Request)\\s+(.*);");
|
|
|
|
|
Pattern p5 = Pattern.compile("private\\s+(.*\\.)*([^\\\\.]*)\\s+(.*);");
|
|
|
|
|
for (String line : strings) {
|
|
|
|
|
{
|
|
|
|
|
Matcher matcher = p1.matcher(line.trim());
|
|
|
|
|
if (matcher.find()) {
|
|
|
|
|
domainName = matcher.group(1);
|
|
|
|
|
moduleName = matcher.group(2);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if ((line.contains("/**") || line.contains("*") || line.contains("*/")) && body.size() == 0) {
|
|
|
|
|
notesList.add(line);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (line.startsWith("import")) {
|
|
|
|
|
Matcher matcher = p2.matcher(line.trim());
|
|
|
|
|
if (matcher.find()) {
|
|
|
|
|
deptEntList.add(matcher.group(1));
|
|
|
|
|
} else if (line.contains("frame")) {
|
|
|
|
|
|
|
|
|
|
} else if (line.contains("javax.validation")) {
|
|
|
|
|
|
|
|
|
|
} else if (line.contains("org.hibernate.validator")) {
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
importList.add(line);
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (line.matches("public\\s+class\\s+(.*Request)\\s+extends\\s+(.*)Request\\s*\\{")) {
|
|
|
|
|
Pattern compile = Pattern.compile("public\\s+class\\s+(.*Request)\\s+extends\\s+(.*)Request\\s*\\{");
|
|
|
|
|
Matcher matcher = compile.matcher(line);
|
|
|
|
|
|
|
|
|
|
if (matcher.find()) {
|
|
|
|
|
className = matcher.group(1);
|
|
|
|
|
fatherName = matcher.group(2);
|
|
|
|
|
if ((line.contains("/**") || line.contains("*") || line.contains("*/")) && className == null) {//未读取到类名之前注释为类注释
|
|
|
|
|
notesList.add(line);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (fatherName.contains("BaseFindRequest")) {
|
|
|
|
|
hasList = true;
|
|
|
|
|
findOrSearchflag = "1";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
Matcher matcher = p3.matcher(line.trim());
|
|
|
|
|
if (matcher.find()) {
|
|
|
|
|
className = matcher.group(1);
|
|
|
|
|
fatherName = matcher.group(2);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (className != null) {
|
|
|
|
|
if (line.matches("\\s*private\\s+(.*Request)\\s+(.*);")) {
|
|
|
|
|
Pattern compile = Pattern.compile("\\s*private\\s+(.*Request)\\s+(.*);");
|
|
|
|
|
Matcher matcher = compile.matcher(line);
|
|
|
|
|
|
|
|
|
|
if (matcher.find()) {
|
|
|
|
|
String group = matcher.group(1);
|
|
|
|
|
deptReqList.add(group);
|
|
|
|
|
}
|
|
|
|
|
} else if (line.matches("\\s*private\\s+(.*\\.)*([^\\\\.]*)\\s+(.*);")) {
|
|
|
|
|
Pattern compile = Pattern.compile("\\s*private\\s+(.*\\.)*([^\\\\.]*)\\s+(.*);");
|
|
|
|
|
Matcher matcher = compile.matcher(line);
|
|
|
|
|
|
|
|
|
|
if (matcher.find()) {
|
|
|
|
|
String group = matcher.group(2);
|
|
|
|
|
Set<String> javaField = Tool.getJavaField();
|
|
|
|
|
if (!javaField.contains(group)) {
|
|
|
|
|
deptEntList.add(group);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (line.contains("@ColumnName") ||
|
|
|
|
|
line.contains("@ColumnDescription")
|
|
|
|
|
) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
body.add(line);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = body.size() - 1; i >= 0; i--) {
|
|
|
|
|
if (body.get(i).contains("}")) {
|
|
|
|
|
body.set(i, body.get(i).replaceAll("}", ""));
|
|
|
|
|
break;
|
|
|
|
|
if (className != null) {
|
|
|
|
|
Matcher matcher = p4.matcher(line.trim());
|
|
|
|
|
if (matcher.find()) {
|
|
|
|
|
deptReqList.add(matcher.group(1));
|
|
|
|
|
} else if (matcher.find()) {
|
|
|
|
|
deptEntList.add(matcher.group(2));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (body.size() > 1 && "".equals(body.get(0))) {
|
|
|
|
|
body.remove(0);
|
|
|
|
|
}
|
|
|
|
|
if (body.size() > 1 && "".equals(body.get(body.size() - 1))) {
|
|
|
|
|
body.remove(body.size() - 1);
|
|
|
|
|
}
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} finally {
|
|
|
|
|
if (bufferedReader != null) {
|
|
|
|
|
try {
|
|
|
|
|
bufferedReader.close();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
|
|
if (line.contains("@ColumnName") ||
|
|
|
|
|
line.contains("@ColumnDescription")
|
|
|
|
|
) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
body.add(line);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = body.size() - 1; i >= 0; i--) {
|
|
|
|
|
if (body.get(i).contains("}")) {
|
|
|
|
|
body.set(i, body.get(i).replaceAll("}", ""));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (body.size() > 1 && "".equals(body.get(0))) {
|
|
|
|
|
body.remove(0);
|
|
|
|
|
}
|
|
|
|
|
if (body.size() > 1 && "".equals(body.get(body.size() - 1))) {
|
|
|
|
|
body.remove(body.size() - 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getDomainName() {
|
|
|
|
@ -218,26 +185,6 @@ public class RequestReader {
|
|
|
|
|
this.javaClass = javaClass;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isHasList() {
|
|
|
|
|
return hasList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setHasList(boolean hasList) {
|
|
|
|
|
this.hasList = hasList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getTclass() {
|
|
|
|
|
return Tclass;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getFindOrSearchflag() {
|
|
|
|
|
return findOrSearchflag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setFindOrSearchflag(String findOrSearchflag) {
|
|
|
|
|
this.findOrSearchflag = findOrSearchflag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setTclass(String tclass) {
|
|
|
|
|
Tclass = tclass;
|
|
|
|
|
}
|
|
|
|
|