parent
0c39560fd2
commit
4b3e30d449
@ -0,0 +1,521 @@
|
||||
package xyz.wbsite.dbtool.javafx.ctrl;
|
||||
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.TableCell;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.control.cell.TextFieldTableCell;
|
||||
import javafx.util.Callback;
|
||||
import javafx.util.converter.DefaultStringConverter;
|
||||
import xyz.wbsite.dbtool.javafx.po.Api;
|
||||
import xyz.wbsite.dbtool.javafx.po.ApiMethod;
|
||||
import xyz.wbsite.dbtool.javafx.po.Doc;
|
||||
import xyz.wbsite.dbtool.javafx.tool.ApiClassReader;
|
||||
import xyz.wbsite.dbtool.javafx.tool.DocClassReader;
|
||||
import xyz.wbsite.dbtool.javafx.tool.Tool;
|
||||
import xyz.wbsite.dbtool.javafx.view.DBCheckBoxTableCell;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class OptionDocController {
|
||||
|
||||
@FXML
|
||||
private TextField modulePath;
|
||||
@FXML
|
||||
private TextField docPath;
|
||||
@FXML
|
||||
private Button selectModulePath;
|
||||
@FXML
|
||||
private Button selectDocPath;
|
||||
@FXML
|
||||
private Button start;
|
||||
@FXML
|
||||
private Button cancel;
|
||||
@FXML
|
||||
private TableView apis;
|
||||
@FXML
|
||||
private CheckBox AjaxDoc;
|
||||
@FXML
|
||||
private CheckBox ApiDoc;
|
||||
@FXML
|
||||
private List<Doc> data = new ArrayList<>();
|
||||
|
||||
public Button getSelectModulePath() {
|
||||
return selectModulePath;
|
||||
}
|
||||
|
||||
public void setSelectModulePath(Button selectModulePath) {
|
||||
this.selectModulePath = selectModulePath;
|
||||
}
|
||||
|
||||
public Button getSelectDocPath() {
|
||||
return selectDocPath;
|
||||
}
|
||||
|
||||
public void setSelectDocPath(Button selectDocPath) {
|
||||
this.selectDocPath = selectDocPath;
|
||||
}
|
||||
|
||||
public List<Doc> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(List<Doc> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public TextField getModulePath() {
|
||||
return modulePath;
|
||||
}
|
||||
|
||||
public void setModulePath(TextField modulePath) {
|
||||
this.modulePath = modulePath;
|
||||
}
|
||||
|
||||
public TextField getDocPath() {
|
||||
return docPath;
|
||||
}
|
||||
|
||||
public void setDocPath(TextField docPath) {
|
||||
this.docPath = docPath;
|
||||
}
|
||||
|
||||
public Button getStart() {
|
||||
return start;
|
||||
}
|
||||
|
||||
public void setStart(Button start) {
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
public Button getCancel() {
|
||||
return cancel;
|
||||
}
|
||||
|
||||
public void setCancel(Button cancel) {
|
||||
this.cancel = cancel;
|
||||
}
|
||||
|
||||
public TableView getApis() {
|
||||
return apis;
|
||||
}
|
||||
|
||||
public void setApis(TableView apis) {
|
||||
this.apis = apis;
|
||||
}
|
||||
|
||||
public CheckBox getAjaxDoc() {
|
||||
return AjaxDoc;
|
||||
}
|
||||
|
||||
public void setAjaxDoc(CheckBox ajaxDoc) {
|
||||
AjaxDoc = ajaxDoc;
|
||||
}
|
||||
|
||||
public CheckBox getApiDoc() {
|
||||
return ApiDoc;
|
||||
}
|
||||
|
||||
public void setApiDoc(CheckBox apiDoc) {
|
||||
ApiDoc = apiDoc;
|
||||
}
|
||||
|
||||
public void load() {
|
||||
File moduleFile = new File(modulePath.getText());
|
||||
|
||||
data.clear();
|
||||
if (moduleFile.exists()) {
|
||||
|
||||
List<File> actionPath = Tool.find(moduleFile, "action");
|
||||
|
||||
if (actionPath.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
File ajaxPath = Tool.createPath(actionPath.get(0), "ajax");
|
||||
for (File file : ajaxPath.listFiles()) {
|
||||
String module = file.getName();
|
||||
for (File tar : file.listFiles()) {
|
||||
try {
|
||||
String target = tar.getName().replaceAll("Ajax$", "").replaceAll(".java", "");
|
||||
DocClassReader docClassReader = new DocClassReader(tar);
|
||||
|
||||
for (ApiMethod apiMethod : docClassReader.getMethodList()) {
|
||||
Doc doc = new Doc();
|
||||
doc.setType("Ajax");
|
||||
doc.setModule(module);
|
||||
doc.setTarget(target);
|
||||
doc.setRequest(apiMethod.getRequest());
|
||||
doc.setResponse(apiMethod.getResponse());
|
||||
doc.setMethod(apiMethod.getMethod());
|
||||
|
||||
List<File> reqFiles = Tool.findRequest(moduleFile, apiMethod.getRequest() + ".java");
|
||||
if (reqFiles.size() == 0) {
|
||||
doc.setError(doc.getError() + "未找到请求");
|
||||
} else if (reqFiles.size() > 1) {
|
||||
doc.setError(doc.getError() + "找到多个请求");
|
||||
} else {
|
||||
doc.setRequestFile(reqFiles.get(0));
|
||||
//查找依赖ent
|
||||
List<String> entities = findEntities(reqFiles.get(0));
|
||||
for (String entity : entities) {
|
||||
doc.getDepEnt().add(entity);
|
||||
}
|
||||
|
||||
//查找依赖req
|
||||
List<String> reqss = findReq(reqFiles.get(0));
|
||||
for (String string : reqss) {
|
||||
doc.getDepReq().add(string);
|
||||
}
|
||||
}
|
||||
|
||||
List<File> rspfiles = Tool.findResponse(moduleFile, apiMethod.getResponse() + ".java");
|
||||
if (rspfiles.size() == 0) {
|
||||
doc.setError(doc.getError() + "未找到响应");
|
||||
} else if (rspfiles.size() > 1) {
|
||||
doc.setError(doc.getError() + "找到多个响应");
|
||||
} else {
|
||||
doc.setResponseFile(rspfiles.get(0));
|
||||
//查找依赖ent
|
||||
List<String> entities = findEntities(rspfiles.get(0));
|
||||
for (String entity : entities) {
|
||||
doc.getDepEnt().add(entity);
|
||||
}
|
||||
|
||||
//查找依赖req
|
||||
List<String> reqss = findReq(rspfiles.get(0));
|
||||
for (String string : reqss) {
|
||||
doc.getDepReq().add(string);
|
||||
}
|
||||
}
|
||||
|
||||
doc.setCheck(true);
|
||||
data.add(doc);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File apiPath = Tool.createPath(actionPath.get(0), "api");
|
||||
for (File file : apiPath.listFiles()) {
|
||||
String module = file.getName();
|
||||
for (File tar : file.listFiles()) {
|
||||
try {
|
||||
String target = tar.getName().replaceAll("Api$", "").replaceAll(".java", "");
|
||||
DocClassReader docClassReader = new DocClassReader(tar);
|
||||
|
||||
for (ApiMethod apiMethod : docClassReader.getMethodList()) {
|
||||
Doc doc = new Doc();
|
||||
doc.setType("Api");
|
||||
doc.setModule(module);
|
||||
doc.setTarget(target);
|
||||
doc.setRequest(apiMethod.getRequest());
|
||||
doc.setResponse(apiMethod.getResponse());
|
||||
doc.setMethod(apiMethod.getMethod());
|
||||
|
||||
List<File> reqFiles = Tool.findRequest(moduleFile, apiMethod.getRequest() + ".java");
|
||||
if (reqFiles.size() == 0) {
|
||||
doc.setError(doc.getError() + "未找到请求");
|
||||
} else if (reqFiles.size() > 1) {
|
||||
doc.setError(doc.getError() + "找到多个请求");
|
||||
} else {
|
||||
doc.setRequestFile(reqFiles.get(0));
|
||||
//查找依赖ent
|
||||
List<String> entities = findEntities(reqFiles.get(0));
|
||||
for (String entity : entities) {
|
||||
doc.getDepEnt().add(entity);
|
||||
}
|
||||
|
||||
//查找依赖req
|
||||
List<String> reqss = findReq(reqFiles.get(0));
|
||||
for (String string : reqss) {
|
||||
doc.getDepReq().add(string);
|
||||
}
|
||||
}
|
||||
|
||||
List<File> rspfiles = Tool.findResponse(moduleFile, apiMethod.getResponse() + ".java");
|
||||
if (rspfiles.size() == 0) {
|
||||
doc.setError(doc.getError() + "未找到响应");
|
||||
} else if (rspfiles.size() > 1) {
|
||||
doc.setError(doc.getError() + "找到多个响应");
|
||||
} else {
|
||||
doc.setResponseFile(rspfiles.get(0));
|
||||
//查找依赖ent
|
||||
List<String> entities = findEntities(rspfiles.get(0));
|
||||
for (String entity : entities) {
|
||||
doc.getDepEnt().add(entity);
|
||||
}
|
||||
|
||||
//查找依赖req
|
||||
List<String> reqss = findReq(rspfiles.get(0));
|
||||
for (String string : reqss) {
|
||||
doc.getDepReq().add(string);
|
||||
}
|
||||
}
|
||||
|
||||
doc.setCheck(true);
|
||||
data.add(doc);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
initData();
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> findEntities(File file) {
|
||||
ArrayList<String> strings = new ArrayList<>();
|
||||
InputStreamReader read = null;//考虑到编码格式
|
||||
try {
|
||||
read = new InputStreamReader(new FileInputStream(file), "UTF-8");
|
||||
BufferedReader bufferedReader = new BufferedReader(read);
|
||||
String line = null;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
//指定字符串判断处
|
||||
if (line.contains(".ent.")) {
|
||||
Pattern compile = Pattern.compile(".*\\.ent\\.(.*);");
|
||||
|
||||
Matcher matcher = compile.matcher(line);
|
||||
|
||||
if (matcher.find()) {
|
||||
String group = matcher.group(1);
|
||||
strings.add(group);
|
||||
// System.out.println(group);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return strings;
|
||||
}
|
||||
|
||||
public List<String> findReq(File file) {
|
||||
ArrayList<String> strings = new ArrayList<>();
|
||||
InputStreamReader read = null;//考虑到编码格式
|
||||
try {
|
||||
read = new InputStreamReader(new FileInputStream(file), "UTF-8");
|
||||
BufferedReader bufferedReader = new BufferedReader(read);
|
||||
String line = null;
|
||||
Pattern compile1 = Pattern.compile(".*private\\s([a-zA-Z_]*Request)\\s[a-zA-Z_]*Request;.*");
|
||||
Pattern compile2 = Pattern.compile(".*private\\sList<([a-zA-Z_]*Request)>\\s[a-zA-Z_]*Requests;.*");
|
||||
Pattern compile3 = Pattern.compile(".*private\\sList<([a-zA-Z_]*Request)>\\s[a-zA-Z_]*RequestList;.*");
|
||||
|
||||
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
//携带一个Request
|
||||
if (line.matches(".*private\\s([a-zA-Z_]*Request)\\s[a-zA-Z_]*Request;.*")) {
|
||||
Matcher matcher = compile1.matcher(line);
|
||||
|
||||
if (matcher.find()) {
|
||||
String group = matcher.group(1);
|
||||
|
||||
strings.add(group);
|
||||
System.out.println(group);
|
||||
}
|
||||
}
|
||||
//携带一个List<*Request> *Requests;
|
||||
if (line.matches(".*private\\sList<([a-zA-Z_]*Request)>\\s[a-zA-Z_]*Requests;.*")) {
|
||||
Matcher matcher = compile2.matcher(line);
|
||||
|
||||
if (matcher.find()) {
|
||||
String group = matcher.group(1);
|
||||
|
||||
strings.add(group);
|
||||
System.out.println(group);
|
||||
}
|
||||
}
|
||||
//携带一个List<*Request> *RequestList;
|
||||
if (line.matches(".*private\\sList<([a-zA-Z_]*Request)>\\s[a-zA-Z_]*RequestList;.*")) {
|
||||
Matcher matcher = compile3.matcher(line);
|
||||
|
||||
if (matcher.find()) {
|
||||
String group = matcher.group(1);
|
||||
|
||||
strings.add(group);
|
||||
System.out.println(group);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return strings;
|
||||
}
|
||||
|
||||
public void initData() {
|
||||
apis.setEditable(true);
|
||||
apis.setSortPolicy(new Callback<TableView, Boolean>() {
|
||||
@Override
|
||||
public Boolean call(TableView param) {
|
||||
//禁止点击列头排序
|
||||
return false;
|
||||
}
|
||||
});
|
||||
ObservableList<TableColumn> columns = apis.getColumns();
|
||||
columns.get(0).setCellValueFactory(new PropertyValueFactory("check"));
|
||||
columns.get(0).setCellFactory(new Callback<TableColumn, TableCell>() {
|
||||
@Override
|
||||
public TableCell call(TableColumn param) {
|
||||
final DBCheckBoxTableCell checkBoxTableCell = new DBCheckBoxTableCell();
|
||||
DBCheckBoxTableCell.sCallback sCallback = checkBoxTableCell.new sCallback() {
|
||||
@Override
|
||||
public ObservableValue<Boolean> call(Integer param) {
|
||||
super.call(param);
|
||||
if (data.get(param).isCheck()) {
|
||||
return new SimpleBooleanProperty(true);
|
||||
} else {
|
||||
return new SimpleBooleanProperty(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
checkBoxTableCell.setSelectedStateCallback(sCallback);
|
||||
checkBoxTableCell.setOnChangeListener(new ChangeListener<Boolean>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
|
||||
int param1 = checkBoxTableCell.getParam();
|
||||
Doc api = data.get(param1);
|
||||
api.setCheck(newValue);
|
||||
}
|
||||
});
|
||||
return checkBoxTableCell;
|
||||
}
|
||||
});
|
||||
columns.get(1).setCellValueFactory(new PropertyValueFactory("type"));
|
||||
columns.get(1).setCellFactory(new Callback<TableColumn, TableCell>() {
|
||||
@Override
|
||||
public TableCell call(TableColumn param) {
|
||||
TextFieldTableCell textFieldTableCell = new TextFieldTableCell(new DefaultStringConverter()) {
|
||||
@Override
|
||||
public void updateItem(Object item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
}
|
||||
};
|
||||
|
||||
textFieldTableCell.setEditable(false);
|
||||
return textFieldTableCell;
|
||||
}
|
||||
});
|
||||
columns.get(2).setCellValueFactory(new PropertyValueFactory("module"));
|
||||
columns.get(2).setCellFactory(new Callback<TableColumn, TableCell>() {
|
||||
@Override
|
||||
public TableCell call(TableColumn param) {
|
||||
TextFieldTableCell textFieldTableCell = new TextFieldTableCell(new DefaultStringConverter()) {
|
||||
@Override
|
||||
public void updateItem(Object item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
}
|
||||
};
|
||||
|
||||
textFieldTableCell.setEditable(false);
|
||||
return textFieldTableCell;
|
||||
}
|
||||
});
|
||||
columns.get(3).setCellValueFactory(new PropertyValueFactory("target"));
|
||||
columns.get(3).setCellFactory(new Callback<TableColumn, TableCell>() {
|
||||
@Override
|
||||
public TableCell call(TableColumn param) {
|
||||
TextFieldTableCell textFieldTableCell = new TextFieldTableCell(new DefaultStringConverter()) {
|
||||
@Override
|
||||
public void updateItem(Object item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
}
|
||||
};
|
||||
|
||||
textFieldTableCell.setEditable(false);
|
||||
return textFieldTableCell;
|
||||
}
|
||||
});
|
||||
columns.get(4).setCellValueFactory(new PropertyValueFactory("method"));
|
||||
columns.get(4).setCellFactory(new Callback<TableColumn, TableCell>() {
|
||||
@Override
|
||||
public TableCell call(TableColumn param) {
|
||||
TextFieldTableCell textFieldTableCell = new TextFieldTableCell(new DefaultStringConverter()) {
|
||||
@Override
|
||||
public void updateItem(Object item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
}
|
||||
};
|
||||
textFieldTableCell.setEditable(false);
|
||||
return textFieldTableCell;
|
||||
}
|
||||
});
|
||||
columns.get(5).setCellValueFactory(new PropertyValueFactory("error"));
|
||||
columns.get(5).setCellFactory(new Callback<TableColumn, TableCell>() {
|
||||
@Override
|
||||
public TableCell call(TableColumn param) {
|
||||
TextFieldTableCell textFieldTableCell = new TextFieldTableCell(new DefaultStringConverter()) {
|
||||
@Override
|
||||
public void updateItem(Object item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
}
|
||||
};
|
||||
textFieldTableCell.setEditable(false);
|
||||
return textFieldTableCell;
|
||||
}
|
||||
});
|
||||
columns.get(6).setCellValueFactory(new PropertyValueFactory("request"));
|
||||
columns.get(6).setCellFactory(new Callback<TableColumn, TableCell>() {
|
||||
@Override
|
||||
public TableCell call(TableColumn param) {
|
||||
TextFieldTableCell textFieldTableCell = new TextFieldTableCell(new DefaultStringConverter()) {
|
||||
@Override
|
||||
public void updateItem(Object item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
}
|
||||
};
|
||||
textFieldTableCell.setEditable(false);
|
||||
return textFieldTableCell;
|
||||
}
|
||||
});
|
||||
columns.get(7).setCellValueFactory(new PropertyValueFactory("response"));
|
||||
columns.get(7).setCellFactory(new Callback<TableColumn, TableCell>() {
|
||||
@Override
|
||||
public TableCell call(TableColumn param) {
|
||||
TextFieldTableCell textFieldTableCell = new TextFieldTableCell(new DefaultStringConverter()) {
|
||||
@Override
|
||||
public void updateItem(Object item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
}
|
||||
};
|
||||
textFieldTableCell.setEditable(false);
|
||||
return textFieldTableCell;
|
||||
}
|
||||
});
|
||||
ObservableList<Doc> ObservableList = FXCollections.observableArrayList();
|
||||
ObservableList.addAll(data);
|
||||
apis.setItems(ObservableList);
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package xyz.wbsite.dbtool.javafx.manger.callable;
|
||||
|
||||
import xyz.wbsite.dbtool.javafx.manger.FreeMarkerManager;
|
||||
import xyz.wbsite.dbtool.javafx.manger.ManagerFactory;
|
||||
import xyz.wbsite.dbtool.javafx.po.Doc;
|
||||
import xyz.wbsite.dbtool.javafx.tool.RequestReader;
|
||||
import xyz.wbsite.dbtool.javafx.tool.ResponseReader;
|
||||
import xyz.wbsite.dbtool.javafx.tool.Tool;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public class DocCallable implements Callable {
|
||||
|
||||
private File module;
|
||||
private File docFile;
|
||||
private List<Doc> ajaxDocList;
|
||||
private List<Doc> apiDocList;
|
||||
private Tool tool = new Tool();
|
||||
File docModule;
|
||||
private FreeMarkerManager freeMarkerManager;
|
||||
|
||||
public DocCallable(File module, File docFile, List<Doc> docList) {
|
||||
this.module = module;
|
||||
this.docFile = docFile;
|
||||
this.ajaxDocList = docList;
|
||||
this.apiDocList = docList;
|
||||
this.freeMarkerManager = ManagerFactory.getFreeMarkerManager();
|
||||
}
|
||||
|
||||
public Boolean call() throws Exception {
|
||||
if (!docFile.exists()) {
|
||||
docFile.mkdir();
|
||||
} else {
|
||||
Tool.clear(docFile);
|
||||
}
|
||||
|
||||
List<Doc> ajaxList = new ArrayList<>();
|
||||
List<Doc> apiList = new ArrayList<>();
|
||||
for (Doc doc : ajaxDocList) {
|
||||
if ("ajax".equals(doc.getType())) {
|
||||
ajaxList.add(doc);
|
||||
}
|
||||
if ("api".equals(doc.getType())) {
|
||||
apiList.add(doc);
|
||||
}
|
||||
}
|
||||
if (ajaxList.size() > 0) {
|
||||
File ajax = Tool.createPath(this.docFile, "ajax");
|
||||
for (Doc doc : ajaxList) {
|
||||
if (doc.isCheck()) {
|
||||
|
||||
RequestReader requestReader = new RequestReader(doc.getRequestFile());
|
||||
// generateRequest(requestReader);
|
||||
|
||||
ResponseReader responseReader = new ResponseReader(doc.getResponseFile());
|
||||
// generateResponse(responseReader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (apiList.size() > 0) {
|
||||
File api = Tool.createPath(this.docFile, "api");
|
||||
for (Doc doc : apiList) {
|
||||
if (doc.isCheck()) {
|
||||
RequestReader requestReader = new RequestReader(doc.getRequestFile());
|
||||
// generateRequest(requestReader);
|
||||
|
||||
ResponseReader responseReader = new ResponseReader(doc.getResponseFile());
|
||||
// generateResponse(responseReader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("finish");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
package xyz.wbsite.dbtool.javafx.po;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class Doc {
|
||||
private boolean check;
|
||||
|
||||
private String type;
|
||||
//目标请求对象
|
||||
private String request;
|
||||
//目标请求响应
|
||||
private String response;
|
||||
private String module;
|
||||
private String target;
|
||||
private String method;
|
||||
|
||||
private File requestFile;
|
||||
private File responseFile;
|
||||
|
||||
private Set<String> depReq = new HashSet<>();
|
||||
private Set<String> depEnt = new HashSet<>();
|
||||
|
||||
private String error = "";
|
||||
|
||||
public boolean isCheck() {
|
||||
return check;
|
||||
}
|
||||
|
||||
public void setCheck(boolean check) {
|
||||
this.check = check;
|
||||
}
|
||||
|
||||
public String getRequest() {
|
||||
return request;
|
||||
}
|
||||
|
||||
public void setRequest(String request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public String getResponse() {
|
||||
return response;
|
||||
}
|
||||
|
||||
public void setResponse(String response) {
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
public String getModule() {
|
||||
return module;
|
||||
}
|
||||
|
||||
public void setModule(String module) {
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
public String getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public void setTarget(String target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public String getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
public void setMethod(String method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public File getRequestFile() {
|
||||
return requestFile;
|
||||
}
|
||||
|
||||
public void setRequestFile(File requestFile) {
|
||||
this.requestFile = requestFile;
|
||||
}
|
||||
|
||||
public File getResponseFile() {
|
||||
return responseFile;
|
||||
}
|
||||
|
||||
public void setResponseFile(File responseFile) {
|
||||
this.responseFile = responseFile;
|
||||
}
|
||||
|
||||
public Set<String> getDepReq() {
|
||||
return depReq;
|
||||
}
|
||||
|
||||
public void setDepReq(Set<String> depReq) {
|
||||
this.depReq = depReq;
|
||||
}
|
||||
|
||||
public Set<String> getDepEnt() {
|
||||
return depEnt;
|
||||
}
|
||||
|
||||
public void setDepEnt(Set<String> depEnt) {
|
||||
this.depEnt = depEnt;
|
||||
}
|
||||
|
||||
public String getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public void setError(String error) {
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package xyz.wbsite.dbtool.javafx.tool;
|
||||
|
||||
import xyz.wbsite.dbtool.javafx.po.ApiMethod;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class DocClassReader {
|
||||
private File javaClass;
|
||||
|
||||
private List<ApiMethod> methodList;
|
||||
|
||||
public DocClassReader(File javaClass) throws IOException {
|
||||
this.javaClass = javaClass;
|
||||
methodList = new ArrayList<>();
|
||||
read();
|
||||
}
|
||||
|
||||
private void read() throws IOException {
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(javaClass), "utf-8"));
|
||||
|
||||
String line = null;
|
||||
Pattern compile = Pattern.compile("\\s+public (.*Response)\\s+(.*)\\((.*Request) request.*\\) \\{");
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
|
||||
Matcher matcher = compile.matcher(line);
|
||||
|
||||
if (matcher.find()) {
|
||||
ApiMethod apiMethod = new ApiMethod();
|
||||
apiMethod.setResponse(matcher.group(1));
|
||||
apiMethod.setMethod(matcher.group(2));
|
||||
apiMethod.setRequest(matcher.group(3));
|
||||
methodList.add(apiMethod);
|
||||
}
|
||||
}
|
||||
bufferedReader.close();
|
||||
}
|
||||
|
||||
public File getJavaClass() {
|
||||
return javaClass;
|
||||
}
|
||||
|
||||
public void setJavaClass(File javaClass) {
|
||||
this.javaClass = javaClass;
|
||||
}
|
||||
|
||||
public List<ApiMethod> getMethodList() {
|
||||
return methodList;
|
||||
}
|
||||
|
||||
public void setMethodList(List<ApiMethod> methodList) {
|
||||
this.methodList = methodList;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
DocClassReader javaClassReader = new DocClassReader(new File("D:\\wangbing\\Project\\dbtool\\target\\project\\example-web\\src\\main\\java\\com\\example\\action\\api\\system\\DictApi.java"));
|
||||
|
||||
System.out.println();
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<BorderPane fx:controller="xyz.wbsite.dbtool.javafx.ctrl.OptionDocController"
|
||||
maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity"
|
||||
minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0"
|
||||
xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
|
||||
<top>
|
||||
<GridPane prefHeight="65.0" prefWidth="601.0" BorderPane.alignment="CENTER">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="295.0" minWidth="10.0" prefWidth="90.0"/>
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="496.0" minWidth="10.0" prefWidth="425.0"/>
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="496.0" minWidth="10.0" prefWidth="88.0"/>
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints maxHeight="38.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||
<RowConstraints maxHeight="33.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Label maxHeight="-Infinity" maxWidth="-Infinity" text="模块路径" GridPane.halignment="CENTER"
|
||||
GridPane.valignment="CENTER"/>
|
||||
<Label text="生成路径" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER"/>
|
||||
<TextField GridPane.columnIndex="1" fx:id="modulePath" promptText="...\**\module\"/>
|
||||
<TextField GridPane.columnIndex="1" fx:id="docPath" GridPane.rowIndex="1"/>
|
||||
<Button mnemonicParsing="false" fx:id="selectModulePath" text="选择路径" GridPane.columnIndex="2"
|
||||
GridPane.halignment="CENTER"
|
||||
GridPane.valignment="CENTER"/>
|
||||
<Button mnemonicParsing="false" fx:id="selectDocPath" text="选择路径" GridPane.columnIndex="2"
|
||||
GridPane.halignment="CENTER"
|
||||
GridPane.rowIndex="1" GridPane.valignment="CENTER"/>
|
||||
</children>
|
||||
<opaqueInsets>
|
||||
<Insets/>
|
||||
</opaqueInsets>
|
||||
</GridPane>
|
||||
</top>
|
||||
<opaqueInsets>
|
||||
<Insets/>
|
||||
</opaqueInsets>
|
||||
<center>
|
||||
|
||||
<BorderPane>
|
||||
<center>
|
||||
<TableView fx:id="apis" prefHeight="270.0" prefWidth="700.0" BorderPane.alignment="CENTER">
|
||||
<columns>
|
||||
<TableColumn prefWidth="30.0" text="选择"/>
|
||||
<TableColumn prefWidth="50.0" text="类型"/>
|
||||
<TableColumn prefWidth="80.0" text="模块"/>
|
||||
<TableColumn prefWidth="80.0" text="对象"/>
|
||||
<TableColumn prefWidth="80.0" text="方法"/>
|
||||
<TableColumn prefWidth="80.0" text="信息"/>
|
||||
<TableColumn prefWidth="150.0" text="请求"/>
|
||||
<TableColumn prefWidth="150.0" text="响应"/>
|
||||
</columns>
|
||||
|
||||
</TableView>
|
||||
</center>
|
||||
<top>
|
||||
<ToolBar prefHeight="30.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
||||
<items>
|
||||
<CheckBox mnemonicParsing="false" fx:id="AjaxDoc" text="AjaxDoc" selected="true">
|
||||
</CheckBox>
|
||||
<CheckBox mnemonicParsing="false" fx:id="ApiDoc" text="ApiDoc" selected="true">
|
||||
</CheckBox>
|
||||
</items>
|
||||
</ToolBar>
|
||||
</top>
|
||||
<BorderPane.margin>
|
||||
<Insets top="20.0"/>
|
||||
</BorderPane.margin>
|
||||
</BorderPane>
|
||||
|
||||
</center>
|
||||
<bottom>
|
||||
<GridPane prefHeight="45.0" prefWidth="600.0" BorderPane.alignment="CENTER">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Button fx:id="start" mnemonicParsing="false" text="确认" GridPane.halignment="CENTER"
|
||||
GridPane.valignment="CENTER"/>
|
||||
<Button fx:id="cancel" mnemonicParsing="false" text="取消" GridPane.columnIndex="1"
|
||||
GridPane.halignment="CENTER"
|
||||
GridPane.valignment="CENTER"/>
|
||||
</children>
|
||||
</GridPane>
|
||||
</bottom>
|
||||
</BorderPane>
|
Loading…
Reference in new issue