架构升级

Former-commit-id: dfa05f717f321b2392721fa0b9f03e2a941b18f6
master
wangbing 4 years ago
parent 3fd54a5502
commit ac63e29d15

@ -57,6 +57,7 @@ import xyz.wbsite.dbtool.javafx.po.Module;
import xyz.wbsite.dbtool.javafx.po.Project;
import xyz.wbsite.dbtool.javafx.po.SelectItem;
import xyz.wbsite.dbtool.javafx.po.Table;
import xyz.wbsite.dbtool.javafx.po.TableMethod;
import xyz.wbsite.dbtool.javafx.tool.Dialog;
import xyz.wbsite.dbtool.javafx.tool.Tool;
import xyz.wbsite.dbtool.javafx.view.DBCheckBoxTableCell;
@ -682,10 +683,10 @@ public class JavaFxApplication extends Application {
detailTableController.getAdd().setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
Dialog.showInput("新增业务", "请输入:", new Dialog.InputCall() {
Dialog.showMethodInput("新增业务", "请输入:", new Dialog.InputMethodCall() {
@Override
public void call(String input) {
if (input.matches("create|delete|update|find|get|search")){
public void call(String name, String note) {
if (name.matches("create|delete|update|find|get|search")) {
Dialog.showYesNo("已经存在的基础业务方法!");
return;
}
@ -694,17 +695,39 @@ public class JavaFxApplication extends Application {
if (node instanceof CheckBox) {
CheckBox checkBox = (CheckBox) node;
if (input.equals(checkBox.getText())) {
if (name.equals(checkBox.getText())) {
Dialog.showYesNo("已经存在的业务方法!");
return;
}
}
}
CheckBox checkBox = new CheckBox(input);
TableMethod method = new TableMethod(name, note, true);
CheckBox checkBox = new CheckBox(name);
checkBox.setSelected(true);
checkBox.selectedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
for (TableMethod tableMethod : currentTable.getMethods()) {
if (tableMethod.getName().equals(checkBox.getText())) {
tableMethod.setSelected(newValue);
}
}
}
});
ContextMenu contextMenu = new ContextMenu(new MenuItem("删除"));
contextMenu.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
detailTableController.getMethods().getChildren().remove(checkBox);
currentTable.getMethods().remove(method);
}
});
checkBox.setContextMenu(contextMenu);
int size = detailTableController.getMethods().getChildren().size();
detailTableController.getMethods().getChildren().add(size - 1, checkBox);
currentTable.getMethods().add(method);
}
});
}
@ -845,6 +868,33 @@ public class JavaFxApplication extends Application {
detailTableController.getAjax().setSelected(currentTable.getAjax());
detailTableController.getHtml().setSelected(currentTable.getHtml());
detailTableController.getApi().setSelected(currentTable.getApi());
for (TableMethod method : currentTable.getMethods()) {
CheckBox checkBox = new CheckBox(method.getName());
checkBox.setSelected(method.isSelected());
checkBox.selectedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
for (TableMethod tableMethod : currentTable.getMethods()) {
if (tableMethod.getName().equals(checkBox.getText())) {
tableMethod.setSelected(newValue);
}
}
}
});
ContextMenu contextMenu = new ContextMenu(new MenuItem("删除"));
contextMenu.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
detailTableController.getMethods().getChildren().remove(checkBox);
currentTable.getMethods().remove(method);
}
});
checkBox.setContextMenu(contextMenu);
int size = detailTableController.getMethods().getChildren().size();
detailTableController.getMethods().getChildren().add(size - 1, checkBox);
}
}
if (gridPane != null) {
@ -1514,7 +1564,6 @@ public class JavaFxApplication extends Application {
}
public static void main(String[] args) {
launch(args);
}

@ -14,6 +14,7 @@ import xyz.wbsite.dbtool.javafx.po.Module;
import xyz.wbsite.dbtool.javafx.po.Project;
import xyz.wbsite.dbtool.javafx.po.SelectItem;
import xyz.wbsite.dbtool.javafx.po.Table;
import xyz.wbsite.dbtool.javafx.po.TableMethod;
import xyz.wbsite.dbtool.web.frame.utils.ClassUtil;
import javax.xml.parsers.DocumentBuilder;
@ -76,6 +77,17 @@ public class XmlManager {
// 映射属性
map(tableElement, table);
NodeList methods = tableElement.getElementsByTagName("method");
if (methods.getLength() > 0) {
for (int k = 0; k < methods.getLength(); k++) {
Element fieldElement = (Element) methods.item(k);
TableMethod method = new TableMethod();
// 映射属性
map(fieldElement, method);
table.getMethods().add(method);
}
}
NodeList fields = tableElement.getElementsByTagName("field");
if (fields.getLength() > 0) {
for (int k = 0; k < fields.getLength(); k++) {
@ -146,6 +158,13 @@ public class XmlManager {
Element table = doc.createElement("table");
module.appendChild(table);
map(t, table);
for (TableMethod tableMethod : t.getMethods()) {
Element method = doc.createElement("method");
map(tableMethod, method);
table.appendChild(method);
}
for (Field f : t.getFields()) {
// 写入field信息
Element field = doc.createElement("field");

@ -12,6 +12,7 @@ import xyz.wbsite.dbtool.javafx.po.OracleDBmapper;
import xyz.wbsite.dbtool.javafx.po.Project;
import xyz.wbsite.dbtool.javafx.po.SQLiteDBmapper;
import xyz.wbsite.dbtool.javafx.po.Table;
import xyz.wbsite.dbtool.javafx.po.TableMethod;
import xyz.wbsite.dbtool.javafx.tool.Tool;
import xyz.wbsite.dbtool.web.frame.utils.FileUtil;
import xyz.wbsite.dbtool.web.frame.utils.ResourceUtil;
@ -304,10 +305,19 @@ public class SpringBootCallable implements Callable {
freeMarkerManager.outputTemp(Tool.createFile(req, Tool.ABB2Abb(table.getTableName()) + "SearchRequest" + ".java"), "SpringBoot/java/module/req/searchRequestClass.ftl", ctx);
freeMarkerManager.outputTemp(Tool.createFile(rsp, Tool.ABB2Abb(table.getTableName()) + "SearchResponse" + ".java"), "SpringBoot/java/module/rsp/searchResponseClass.ftl", ctx);
}
for (TableMethod tableMethod : table.getMethods()) {
String method = Tool.abb2Abb(tableMethod.getName());
ctx.put("method", method);
ctx.put("methodNote", tableMethod.getNote());
freeMarkerManager.outputTemp(Tool.createFile(req, Tool.ABB2Abb(table.getTableName()) + method + "Request" + ".java"), "SpringBoot/java/module/req/methodRequestClass.ftl", ctx);
freeMarkerManager.outputTemp(Tool.createFile(rsp, Tool.ABB2Abb(table.getTableName()) + method + "Response" + ".java"), "SpringBoot/java/module/rsp/methodResponseClass.ftl", ctx);
}
}
}
{// 生成系统模块
Module module = tryGetModule(project, "wsys");
if (module== null || !module.getNeedGenerate()){// 生成系统模块
HashMap<String, Object> ctx = new HashMap<String, Object>();
ctx.put("project", project);
ctx.put("domain", project.getDomain());

@ -55,6 +55,9 @@ public class Table extends TreeItem {
@Property("api")
private boolean api = false;
@Property("methods")
private List<TableMethod> methods = new ArrayList<>();
/**
*
*/
@ -255,4 +258,12 @@ public class Table extends TreeItem {
}
return false;
}
public List<TableMethod> getMethods() {
return methods;
}
public void setMethods(List<TableMethod> methods) {
this.methods = methods;
}
}

@ -0,0 +1,53 @@
package xyz.wbsite.dbtool.javafx.po;
import xyz.wbsite.dbtool.javafx.annotation.Property;
import xyz.wbsite.dbtool.javafx.tool.Tool;
public class TableMethod {
public TableMethod() {
}
public TableMethod(String name, String note, boolean selected) {
this.name = name;
this.note = note;
this.selected = selected;
}
@Property("name")
private String name;
@Property("note")
private String note;
@Property("selected")
private boolean selected;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNote() {
return note;
}
public void setNote(String note) {
this.note = note;
}
public boolean isSelected() {
return selected;
}
public void setSelected(boolean selected) {
this.selected = selected;
}
public String getAbbName() {
return Tool.abb2Abb(this.name);
}
}

@ -25,11 +25,13 @@ import javafx.scene.control.TextField;
import javafx.scene.control.TextInputDialog;
import javafx.scene.control.ToggleGroup;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import javafx.stage.DirectoryChooser;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import javafx.util.Callback;
import xyz.wbsite.dbtool.Application;
import xyz.wbsite.dbtool.javafx.JavaFxApplication;
import xyz.wbsite.dbtool.javafx.ctrl.ConnectInfoController;
@ -865,6 +867,47 @@ public class Dialog {
}
}
public static void showMethodInput(String title, String hint, InputMethodCall inputCall) {
javafx.scene.control.Dialog dialog = new javafx.scene.control.Dialog();
dialog.setTitle(title);
dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
GridPane gridPane = new GridPane();
gridPane.setHgap(10);
gridPane.setVgap(10);
gridPane.setPadding(new Insets(10, 10, 10, 10));
dialog.getDialogPane().setContent(gridPane);
TextField nameField = new TextField();
nameField.setPromptText("请输入业务名称");
TextField noteField = new TextField();
noteField.setPromptText("请输入业务注释");
gridPane.add(new Label("业务名称:"), 0, 0);
gridPane.add(nameField, 1, 0);
gridPane.add(new Label("业务注释:"), 0, 1);
gridPane.add(noteField, 1, 1);
dialog.setResultConverter(new Callback() {
@Override
public Object call(Object param) {
Map<String, String> hashMap = new HashMap<>();
if (param == ButtonType.OK) {
hashMap.put("name", nameField.getText());
hashMap.put("note", noteField.getText());
}
return hashMap;
}
});
Optional optional = dialog.showAndWait();
if (optional.isPresent()) {
Map<String, String> map = (Map<String, String>) optional.get();
inputCall.call(map.get("name"),map.get("note"));
}
}
private static void check(OptionApiController controller, boolean check, String key) {
for (Api api : controller.getData()) {
if (api.getMethod().contains(key)) {
@ -878,6 +921,10 @@ public class Dialog {
void call(String input);
}
public interface InputMethodCall {
void call(String name,String note);
}
public interface ConfirmCall {
void call(boolean result);
}

@ -30,6 +30,12 @@ import ${domain}.module.${moduleName}.rsp.${table.getCName()}GetResponse;
<#if table.getUpdate()>
import ${domain}.module.${moduleName}.rsp.${table.getCName()}UpdateResponse;
</#if>
<#list table.methods as item>
<#if item.selected>
import ${domain}.module.${moduleName}.req.${table.getCName()}${item.getAbbName()?default("")}Request;
import ${domain}.module.${moduleName}.rsp.${table.getCName()}${item.getAbbName()?default("")}Response;
</#if>
</#list>
import ${domain}.frame.auth.Token;
/**
@ -106,4 +112,17 @@ public interface ${table.getCName()}Manager {
*/
${table.getCName()}GetResponse get(${table.getCName()}GetRequest request, Token token);
</#if>
<#list table.methods as item>
<#if item.selected>
/**
* ${item.note?default("")}
*
* @param request 请求对象
* @param token 令牌
* @return
*/
${table.getCName()}${item.getAbbName()?default("")}Response ${item.name}(${table.getCName()}${item.getAbbName()?default("")}Request request, Token token);
</#if>
</#list>
}

@ -38,6 +38,12 @@ import ${domain}.module.${moduleName}.rsp.${table.getCName()}GetResponse;
<#if table.getUpdate()>
import ${domain}.module.${moduleName}.rsp.${table.getCName()}UpdateResponse;
</#if>
<#list table.methods as item>
<#if item.selected>
import ${domain}.module.${moduleName}.req.${table.getCName()}${item.getAbbName()?default("")}Request;
import ${domain}.module.${moduleName}.rsp.${table.getCName()}${item.getAbbName()?default("")}Response;
</#if>
</#list>
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.util.StringUtil;
@ -266,4 +272,26 @@ public class ${table.getCName()}ManagerImpl implements ${table.getCName()}Manage
return response;
}
</#if>
<#list table.methods as item>
<#if item.selected>
/**
* ${item.note?default("")}
*
* @param request 请求对象
* @param token 令牌
* @return
*/
public ${table.getCName()}${item.getAbbName()?default("")}Response ${item.name}(${table.getCName()}${item.getAbbName()?default("")}Request request, Token token) {
${table.getCName()}${item.getAbbName()?default("")}Response response = new ${table.getCName()}${item.getAbbName()?default("")}Response();
ValidationUtil.validate(request, response);
if (response.hasError()) {
return response;
}
return response;
}
</#if>
</#list>
}

@ -0,0 +1,14 @@
package ${domain}.module.${moduleName}.req;
import ${domain}.frame.base.BaseRequest;
/**
* ${table.getCName()}${method?default("")}Request - ${table.tableComment}${methodNote?default("")}
*
* @author ${author?default("")}
* @version 0.0.1
* @since ${.now?string["yyyy-MM-dd"]}
*/
public class ${table.getCName()}${method?default("")}Request extends BaseRequest {
}

@ -0,0 +1,14 @@
package ${domain}.module.${moduleName}.rsp;
import ${domain}.frame.base.BaseResponse;
/**
* ${table.getCName()}${method?default("")}Response - ${table.tableComment}${methodNote?default("")}
*
* @author ${author?default("")}
* @version 0.0.1
* @since ${.now?string["yyyy-MM-dd"]}
*/
public class ${table.getCName()}${method?default("")}Response extends BaseResponse {
}
Loading…
Cancel
Save

Powered by TurnKey Linux.