1、API升级

Former-commit-id: 64a883ef12b7d5d26b40ee503859ce681ae4fa4e
master
wangbing 5 years ago
parent a43cc1c13e
commit 48cd76544c

@ -11,7 +11,6 @@ import xyz.wbsite.dbtool.javafx.tool.ResponseReader;
import xyz.wbsite.dbtool.javafx.tool.Tool;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@ -221,41 +220,35 @@ public class ApiCallable implements Callable {
Matcher matcher = compile.matcher(s);
if (matcher.find()) {
String Package = matcher.group(1);
String EntName = matcher.group(2);
entNames.add(EntName);
List<File> files = Tool.findEntity(this.module, EntName + ".java");
for (File file : files) {
try {
EntityReader entReader = new EntityReader(file);
generateEntity(entReader);
} catch (IOException e) {
e.printStackTrace();
}
EntityReader entReader = new EntityReader(file);
generateEntity(entReader);
}
}
}
List<String> reqNames = new ArrayList<>();
for (String depReqName : reader.getDeptReqList()) {
Pattern compile = Pattern.compile("(.*\\.req)\\.(.*)");
Matcher matcher = compile.matcher(depReqName);
if (matcher.find()) {
String Package = matcher.group(1);
String ReqName = matcher.group(2);
entNames.add(depReqName);
List<File> files = Tool.findRequest(this.module, depReqName + ".java");
for (File file : files) {
try {
if (depReqName.matches("(.*\\.req)\\.(.*)")) {
Pattern compile = Pattern.compile("(.*\\.req)\\.(.*)");
Matcher matcher = compile.matcher(depReqName);
if (matcher.find()) {
entNames.add(depReqName);
List<File> files = Tool.findRequest(this.module, depReqName + ".java");
for (File file : files) {
RequestReader reqReader = new RequestReader(file);
generateRequest(reqReader);
} catch (IOException e) {
e.printStackTrace();
}
}
} else {
List<File> files = Tool.findRequest(this.module, depReqName + ".java");
for (File file : files) {
generateRequest(new RequestReader(file));
}
}
}
@ -304,12 +297,8 @@ public class ApiCallable implements Callable {
List<File> files = Tool.findEntity(this.module, EntName + ".java");
for (File file : files) {
try {
EntityReader entReader = new EntityReader(file);
generateEntity(entReader);
} catch (IOException e) {
e.printStackTrace();
}
EntityReader entReader = new EntityReader(file);
generateEntity(entReader);
}
}
}

@ -24,7 +24,7 @@ public class EntityReader {
private String findOrSearchflag = "0";
private String Tclass = null;
public EntityReader(File javaClass) throws IOException {
public EntityReader(File javaClass) {
this.javaClass = javaClass;
importList = new ArrayList<>();
notesList = new ArrayList<>();
@ -35,88 +35,89 @@ public class EntityReader {
read();
}
private void read() throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(javaClass), "utf-8"));
private 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\\.(.*).ent;");
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\\..*);");
String line = null;
while ((line = bufferedReader.readLine()) != null) {
if (line.matches("\\s*package\\s(.*);")) {
Pattern compile = Pattern.compile("\\s*package\\s(.*)\\.module\\.(.*).ent;");
Matcher matcher = compile.matcher(line);
if (matcher.find()) {
String group = matcher.group(1);
deptEntList.add(group);
domainName = matcher.group(1);
moduleName = matcher.group(2);
}
} else if (line.contains("frame")) {
} else if (line.contains("javax.validation")) {
} else if (line.contains("org.hibernate.validator")) {
} else {
importList.add(line);
continue;
}
continue;
}
if ((line.contains("/**") || line.contains("*") || line.contains("*/")) && body.size() == 0) {
notesList.add(line);
}
if (line.matches("public class\\s+(.*)\\s+extends\\s+BaseEntity\\s*\\{")) {
Pattern compile = Pattern.compile("public class\\s+(.*)\\s+extends\\s+BaseEntity\\s*\\{");
Matcher matcher = compile.matcher(line);
if (matcher.find()) {
className = matcher.group(1);
fatherName = "BaseEntity";
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);
}
continue;
}
continue;
}
if (className != null) {
if (line.matches("\\s*private\\s+(.*Request)\\s+(.*);")) {
Pattern compile = Pattern.compile("\\s*private\\s+(.*Request)\\s+(.*);");
if ((line.contains("/**") || line.contains("*") || line.contains("*/")) && body.size() == 0) {
notesList.add(line);
}
if (line.matches("public class\\s+(.*)\\s+extends\\s+BaseEntity\\s*\\{")) {
Pattern compile = Pattern.compile("public class\\s+(.*)\\s+extends\\s+BaseEntity\\s*\\{");
Matcher matcher = compile.matcher(line);
if (matcher.find()) {
String group = matcher.group(1);
deptReqList.add(group);
className = matcher.group(1);
fatherName = "BaseEntity";
}
}
if (line.contains("@ColumnName") ||
line.contains("@ColumnDescription")
) {
continue;
}
if (className != null) {
if (line.contains("@ColumnName") ||
line.contains("@ColumnDescription")
) {
continue;
}
body.add(line);
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;
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);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
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);
}
bufferedReader.close();
}
public String getDomainName() {

@ -24,7 +24,7 @@ public class RequestReader {
private String findOrSearchflag = "0";
private String Tclass = null;
public RequestReader(File javaClass) throws IOException {
public RequestReader(File javaClass) {
this.javaClass = javaClass;
importList = new ArrayList<>();
notesList = new ArrayList<>();
@ -35,99 +35,116 @@ public class RequestReader {
read();
}
private void read() throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(javaClass), "utf-8"));
private 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\\..*);");
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()) {
String group = matcher.group(1);
deptEntList.add(group);
domainName = matcher.group(1);
moduleName = matcher.group(2);
}
} else if (line.contains("frame")) {
} else if (line.contains("javax.validation")) {
} else if (line.contains("org.hibernate.validator")) {
} else {
importList.add(line);
continue;
}
continue;
}
if ((line.contains("/**") || line.contains("*") || line.contains("*/")) && body.size() == 0) {
notesList.add(line);
}
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 (fatherName.contains("BaseFindRequest")) {
hasList = true;
findOrSearchflag = "1";
}
if (fatherName.contains("BaseGetAllRequest")) {
hasList = true;
findOrSearchflag = "2";
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);
}
continue;
}
if ((line.contains("/**") || line.contains("*") || line.contains("*/")) && body.size() == 0) {
notesList.add(line);
}
continue;
}
if (className != null) {
if (line.matches("\\s*private\\s+(.*Request)\\s+(.*);")) {
Pattern compile = Pattern.compile("\\s*private\\s+(.*Request)\\s+(.*);");
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()) {
String group = matcher.group(1);
deptReqList.add(group);
className = matcher.group(1);
fatherName = matcher.group(2);
if (fatherName.contains("BaseFindRequest")) {
hasList = true;
findOrSearchflag = "1";
}
if (fatherName.contains("BaseGetAllRequest")) {
hasList = true;
findOrSearchflag = "2";
}
}
}
if (line.contains("@ColumnName") ||
line.contains("@ColumnDescription")
) {
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);
deptEntList.add(group);
}
}
if (line.contains("@ColumnName") ||
line.contains("@ColumnDescription")
) {
continue;
}
body.add(line);
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;
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);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
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);
}
bufferedReader.close();
}
public String getDomainName() {

@ -24,7 +24,7 @@ public class ResponseReader {
private String findOrSearchflag = "0";
private String Tclass = null;
public ResponseReader(File javaClass) throws IOException {
public ResponseReader(File javaClass){
this.javaClass = javaClass;
importList = new ArrayList<>();
notesList = new ArrayList<>();
@ -35,93 +35,105 @@ public class ResponseReader {
read();
}
private void read() throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(javaClass), "utf-8"));
private 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\\.(.*).rsp;");
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\\..*);");
String line = null;
while ((line = bufferedReader.readLine()) != null) {
if (line.matches("\\s*package\\s(.*);")) {
Pattern compile = Pattern.compile("\\s*package\\s(.*)\\.module\\.(.*).rsp;");
Matcher matcher = compile.matcher(line);
if (matcher.find()) {
String group = matcher.group(1);
deptEntList.add(group);
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(".req.")) {
Pattern compile = Pattern.compile("import\\s+(.*\\.req\\..*);");
Matcher matcher = compile.matcher(line);
if (matcher.find()) {
String group = matcher.group(1);
deptReqList.add(group);
}
} else if (!line.contains("frame")) {
importList.add(line);
}
} else if (line.contains(".req.")) {
Pattern compile = Pattern.compile("import\\s+(.*\\.req\\..*);");
continue;
}
if ((line.contains("/**") || line.contains("*") || line.contains("*/")) && body.size() == 0) {
notesList.add(line);
}
if (line.matches("public class (.*Response) extends (.*)Response\\s*\\{")) {
Pattern compile = Pattern.compile("public class (.*Response) extends (.*)Response\\s*\\{");
Matcher matcher = compile.matcher(line);
if (matcher.find()) {
String group = matcher.group(1);
deptReqList.add(group);
className = matcher.group(1);
fatherName = matcher.group(2);
if (fatherName.contains("BaseFindResponse")) {
hasList = true;
findOrSearchflag = "1";
}
}
} else if (!line.contains("frame")) {
importList.add(line);
continue;
}
continue;
}
if ((line.contains("/**") || line.contains("*") || line.contains("*/")) && body.size() == 0) {
notesList.add(line);
}
if (line.matches("public class (.*Response) extends (.*)Response\\s*\\{")) {
Pattern compile = Pattern.compile("public class (.*Response) extends (.*)Response\\s*\\{");
Matcher matcher = compile.matcher(line);
if (matcher.find()) {
className = matcher.group(1);
fatherName = matcher.group(2);
if (line.matches("public class (.*Response) extends (.*)Response<(.*)>\\s*\\{")) {
Pattern compile = Pattern.compile("public class (.*Response) extends (.*)Response<(.*)>\\s*\\{");
Matcher matcher = compile.matcher(line);
if (fatherName.contains("BaseFindResponse")) {
hasList = true;
findOrSearchflag = "1";
if (matcher.find()) {
className = matcher.group(1);
fatherName = matcher.group(2);
Tclass = matcher.group(3);
if (fatherName.contains("BaseFindResponse")) {
hasList = true;
findOrSearchflag = "1";
}
}
continue;
}
if (className != null) {
body.add(line);
}
continue;
}
if (line.matches("public class (.*Response) extends (.*)Response<(.*)>\\s*\\{")) {
Pattern compile = Pattern.compile("public class (.*Response) extends (.*)Response<(.*)>\\s*\\{");
Matcher matcher = compile.matcher(line);
if (matcher.find()) {
className = matcher.group(1);
fatherName = matcher.group(2);
Tclass = matcher.group(3);
if (fatherName.contains("BaseFindResponse")) {
hasList = true;
findOrSearchflag = "1";
}
for (int i = body.size() - 1; i >= 0; i--) {
if (body.get(i).contains("}")) {
body.set(i, body.get(i).replaceAll("}", ""));
break;
}
continue;
}
if (className != null) {
body.add(line);
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);
}
}
for (int i = body.size() - 1; i >= 0; i--) {
if (body.get(i).contains("}")) {
body.set(i, body.get(i).replaceAll("}", ""));
break;
} catch (IOException e) {
e.printStackTrace();
} finally {
if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
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);
}
bufferedReader.close();
}
public String getDomainName() {

@ -2,10 +2,7 @@ package xyz.wbsite.dbtool.javafx.tool;
import java.io.*;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -421,6 +418,36 @@ public class Tool {
return files;
}
private static Set<String> javaFieldSet = new HashSet<>();
static {
javaFieldSet.add("boolean");
javaFieldSet.add("Boolean");
javaFieldSet.add("byte");
javaFieldSet.add("Byte");
javaFieldSet.add("byte[]");
javaFieldSet.add("Byte[]");
javaFieldSet.add("char");
javaFieldSet.add("Character");
javaFieldSet.add("short");
javaFieldSet.add("Short");
javaFieldSet.add("int");
javaFieldSet.add("Integer");
javaFieldSet.add("long");
javaFieldSet.add("Long");
javaFieldSet.add("float");
javaFieldSet.add("Float");
javaFieldSet.add("double");
javaFieldSet.add("Double");
javaFieldSet.add("Date");
javaFieldSet.add("BigDecimal");
javaFieldSet.add("String");
}
public static Set<String> getJavaField() {
return javaFieldSet;
}
public static File createPath(String... subdir) {
if (subdir.length == 0) {
return null;

Loading…
Cancel
Save

Powered by TurnKey Linux.