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();
}
}
}
}
List<String> reqNames = new ArrayList<>();
for (String depReqName : reader.getDeptReqList()) {
if (depReqName.matches("(.*\\.req)\\.(.*)")) {
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 {
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();
}
}
}
}

@ -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,8 +35,10 @@ 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) {
@ -83,16 +85,6 @@ public class EntityReader {
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);
}
}
if (line.contains("@ColumnName") ||
line.contains("@ColumnDescription")
) {
@ -115,8 +107,17 @@ public class EntityReader {
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();
}
}
}
}
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,8 +35,10 @@ 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) {
@ -92,9 +94,7 @@ public class RequestReader {
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);
@ -102,6 +102,14 @@ public class RequestReader {
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") ||
@ -126,8 +134,17 @@ public class RequestReader {
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();
}
}
}
}
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,8 +35,10 @@ 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) {
@ -121,7 +123,17 @@ public class ResponseReader {
body.remove(body.size() - 1);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
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.