diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/JavaFxApplication.java b/src/main/java/xyz/wbsite/dbtool/javafx/JavaFxApplication.java index e5a5ef6d..8d984e72 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/JavaFxApplication.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/JavaFxApplication.java @@ -11,12 +11,24 @@ import javafx.event.Event; import javafx.event.EventHandler; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; -import javafx.scene.control.*; +import javafx.scene.control.Button; +import javafx.scene.control.ContextMenu; +import javafx.scene.control.MenuItem; +import javafx.scene.control.TableCell; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; +import javafx.scene.control.TreeCell; +import javafx.scene.control.TreeItem; +import javafx.scene.control.TreeView; import javafx.scene.control.cell.ChoiceBoxTableCell; import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.control.cell.TextFieldTableCell; import javafx.scene.control.cell.TextFieldTreeCell; -import javafx.scene.input.*; +import javafx.scene.input.ClipboardContent; +import javafx.scene.input.DragEvent; +import javafx.scene.input.Dragboard; +import javafx.scene.input.MouseEvent; +import javafx.scene.input.TransferMode; import javafx.scene.layout.BorderPane; import javafx.scene.layout.GridPane; import javafx.scene.layout.Pane; @@ -27,10 +39,9 @@ import javafx.util.Callback; import javafx.util.converter.DefaultStringConverter; import javafx.util.converter.IntegerStringConverter; import xyz.wbsite.dbtool.javafx.ctrl.DetailModuleController; -import xyz.wbsite.dbtool.javafx.ctrl.MainController; import xyz.wbsite.dbtool.javafx.ctrl.DetailProjectController; import xyz.wbsite.dbtool.javafx.ctrl.DetailTableController; -import xyz.wbsite.dbtool.javafx.view.DBCheckBoxTableCell; +import xyz.wbsite.dbtool.javafx.ctrl.MainController; import xyz.wbsite.dbtool.javafx.enums.FieldType; import xyz.wbsite.dbtool.javafx.manger.ManagerFactory; import xyz.wbsite.dbtool.javafx.manger.ProjectManager; @@ -38,21 +49,20 @@ import xyz.wbsite.dbtool.javafx.po.Field; import xyz.wbsite.dbtool.javafx.po.Module; import xyz.wbsite.dbtool.javafx.po.Project; import xyz.wbsite.dbtool.javafx.po.Table; -import xyz.wbsite.dbtool.javafx.tool.*; +import xyz.wbsite.dbtool.javafx.tool.Tool; +import xyz.wbsite.dbtool.javafx.view.DBCheckBoxTableCell; import java.net.URL; -import java.util.Iterator; import java.util.List; public class JavaFxApplication extends Application { - private ProjectManager dBmanger = ManagerFactory.getdBManager(); + private ProjectManager dBmanger = ManagerFactory.getProjectManager(); private TreeView mdtree = null; private Pane detail = null; private TableView feilds = null; private Button add = null; private Button sub = null; - private CheckBox addSysFields = null; private FXMLLoader mainloader; private FXMLLoader projectdetailloader; private FXMLLoader mddetailloader; @@ -125,14 +135,6 @@ public class JavaFxApplication extends Application { } }); - addSysFields = mainController.getAddSysFields(); - addSysFields.setOnMouseClicked(new EventHandler() { - @Override - public void handle(MouseEvent event) { - checkSysFields(); - } - }); - ContextMenu con = new ContextMenu(new MenuItem("新增"), new MenuItem("删除"), new MenuItem("向上调整"), new MenuItem("向下调整")); con.setOnAction(new EventHandler() { @Override @@ -442,6 +444,12 @@ public class JavaFxApplication extends Application { currentProject.setProjectAuthor(newValue); } }); + detailProjectController.getMultiDB().selectedProperty().addListener(new ChangeListener() { + @Override + public void changed(ObservableValue observable, Boolean oldValue, Boolean newValue) { + currentProject.setMultiDB(newValue); + } + }); } {//初始化表面板 @@ -498,136 +506,26 @@ public class JavaFxApplication extends Application { currentTable.setSearch(newValue); } }); - detailTableController.getGetAll().selectedProperty().addListener(new ChangeListener() { + detailTableController.getHtml().selectedProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observable, Boolean oldValue, Boolean newValue) { - currentTable.setGetAll(newValue); + currentTable.setHtml(newValue); } }); - detailTableController.getHtml().selectedProperty().addListener(new ChangeListener() { + detailTableController.getSys().selectedProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observable, Boolean oldValue, Boolean newValue) { - currentTable.setHtml(newValue); + currentTable.setSys(newValue); + loadingTable(); } }); } ManagerFactory.getReflashManager(this).start(); loadingProjectTree(); - checkSysFields(); super.init(); } - private void checkSysFields() { - if (currentMD != null) { - boolean selected = addSysFields.isSelected(); - removeSysFields(currentMD); - if (selected) { - bitchInsertSysFields(currentMD); - } - if (currentTable != null) { - loadingTable(); - } - } - } - - private void removeSysFields() { - for (Module md : dBmanger.getMds()) { - for (Table table : md.getTables()) { - Iterator iterator = table.getFields().iterator(); - while (iterator.hasNext()) { - Field next = iterator.next(); - if (next.getIsSystem()) { - iterator.remove(); - } - } - } - } - } - - private void removeSysFields(Module md) { - md.setHasSysFields(false); - for (Table table : md.getTables()) { - Iterator iterator = table.getFields().iterator(); - while (iterator.hasNext()) { - Field next = iterator.next(); - if (next.getIsSystem()) { - iterator.remove(); - } - } - } - } - - private void insertSysFields(Table table) { - Field id = new Field("ID"); - id.setIsSystem(true); - id.setIsMust(true); - id.setIsPrimaryKey(true); - id.setFieldType(FieldType.Long); - id.setFieldLength(19); - id.setFieldComment("主键"); - - Field row_version = new Field("ROW_VERSION"); - row_version.setIsSystem(true); - row_version.setIsMust(true); - row_version.setFieldType(FieldType.Long); - row_version.setFieldLength(19); - row_version.setFieldComment("行版本"); - - Field is_deleted = new Field("IS_DELETED"); - is_deleted.setIsSystem(true); - is_deleted.setIsMust(true); - is_deleted.setDefaultValue("0"); - is_deleted.setFieldType(FieldType.Boolean); - is_deleted.setFieldLength(1); - is_deleted.setFieldComment("是否已删除"); - - Field created_by = new Field("CREATE_BY"); - created_by.setIsSystem(true); - created_by.setIsMust(true); - created_by.setFieldType(FieldType.Long); - created_by.setFieldLength(19); - created_by.setFieldComment("创建用户"); - - Field creation_time = new Field("CREATE_TIME"); - creation_time.setIsSystem(true); - creation_time.setIsMust(true); - creation_time.setDefaultValue("NULL"); - creation_time.setFieldType(FieldType.Date); - creation_time.setFieldComment("创建时间"); - - Field last_updated_by = new Field("LAST_UPDATE_BY"); - last_updated_by.setIsSystem(true); - creation_time.setDefaultValue("NULL"); - last_updated_by.setFieldType(FieldType.Long); - last_updated_by.setFieldLength(19); - last_updated_by.setFieldComment("最后更新用户"); - - Field last_update_time = new Field("LAST_UPDATE_TIME"); - last_update_time.setIsSystem(true); - last_update_time.setFieldType(FieldType.Date); - last_update_time.setFieldComment("最后更新时间"); - - table.putFirstField(id); - table.putField(row_version); - table.putField(is_deleted); - table.putField(created_by); - table.putField(creation_time); - table.putField(last_updated_by); - table.putField(last_update_time); - } - - private void bitchInsertSysFields() { - for (Module md : dBmanger.getMds()) { - md.getTables().forEach(this::insertSysFields); - } - } - - private void bitchInsertSysFields(Module md) { - md.setHasSysFields(true); - md.getTables().forEach(this::insertSysFields); - } - private void addField() { if (currentTable != null && feilds != null) { List fields = currentTable.getFields(); @@ -683,10 +581,6 @@ public class JavaFxApplication extends Application { } private void loadingModule() { - if (currentMD != null) { - addSysFields.setSelected(currentMD.isHasSysFields()); - } - if (currentMD == null) { return; } @@ -710,6 +604,7 @@ public class JavaFxApplication extends Application { detailProjectController.getProjectName().setText(currentProject.getProjectName()); detailProjectController.getProjectBasePackage().setText(currentProject.getProjectBasePackage()); detailProjectController.getProjectAuthor().setText(currentProject.getProjectAuthor()); + detailProjectController.getMultiDB().setSelected(currentProject.getMultiDB()); if (gridPane != null) { detail.getChildren().clear(); @@ -724,11 +619,6 @@ public class JavaFxApplication extends Application { * 加载对象信息 */ private void loadingTable() { - if (currentMD != null) { - addSysFields.setSelected(currentMD.isHasSysFields()); - } else if (currentTable != null && currentTable.getdBhandle() != null) { - addSysFields.setSelected(currentTable.getdBhandle().isHasSysFields()); - } GridPane gridPane = tabledetailloader.getRoot(); if (currentTable != null) { detailTableController.getTablename().setText(currentTable.getTableName()); @@ -739,11 +629,10 @@ public class JavaFxApplication extends Application { detailTableController.getFind().setSelected(currentTable.getFind()); detailTableController.getGet().setSelected(currentTable.getGet()); detailTableController.getSearch().setSelected(currentTable.getSearch()); - detailTableController.getGetAll().setSelected(currentTable.getGetAll()); detailTableController.getHtml().setSelected(currentTable.getHtml()); + detailTableController.getSys().setSelected(currentTable.getSys()); } - if (gridPane != null) { detail.getChildren().clear(); detail.getChildren().add(gridPane); @@ -1293,9 +1182,6 @@ public class JavaFxApplication extends Application { Module md = dBmanger.findDBByDBName((String) targetItem.getValue()); if (md != null) { Table newTableName = dBmanger.getNewTableName(md); - if (addSysFields.isSelected()) { - insertSysFields(newTableName); - } targetItem.getChildren().add(newTableName); } } @@ -1305,9 +1191,6 @@ public class JavaFxApplication extends Application { System.out.println("对象:" + parent.getValue()); Module md = dBmanger.findDBByDBName((String) parent.getValue()); Table newTableName = dBmanger.getNewTableName(md); - if (addSysFields.isSelected()) { - insertSysFields(newTableName); - } parent.getChildren().add(new TreeItem<>(newTableName.getTableName())); break; } @@ -1327,9 +1210,6 @@ public class JavaFxApplication extends Application { System.out.println("模块:" + targetItem.getValue()); Module md = dBmanger.findDBByDBName((String) targetItem.getValue()); Table newTableName = dBmanger.getNewTableName(md); - if (addSysFields.isSelected()) { - insertSysFields(newTableName); - } targetItem.getChildren().add(new TreeItem<>(newTableName.getTableName())); } break; diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/DetailProjectController.java b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/DetailProjectController.java index 7ccfb34e..2ba9ea0d 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/DetailProjectController.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/DetailProjectController.java @@ -1,6 +1,7 @@ package xyz.wbsite.dbtool.javafx.ctrl; import javafx.fxml.FXML; +import javafx.scene.control.CheckBox; import javafx.scene.control.TextField; public class DetailProjectController { @@ -11,7 +12,16 @@ public class DetailProjectController { private TextField projectBasePackage; @FXML private TextField projectAuthor; + @FXML + private CheckBox multiDB; + + public CheckBox getMultiDB() { + return multiDB; + } + public void setMultiDB(CheckBox multiDB) { + this.multiDB = multiDB; + } public TextField getProjectName() { return projectName; diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/DetailTableController.java b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/DetailTableController.java index 825d359e..28492095 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/DetailTableController.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/DetailTableController.java @@ -24,9 +24,9 @@ public class DetailTableController { @FXML private CheckBox search; @FXML - private CheckBox getAll; - @FXML private CheckBox html; + @FXML + private CheckBox sys; public CheckBox getCreate() { return create; @@ -76,14 +76,6 @@ public class DetailTableController { this.search = search; } - public CheckBox getGetAll() { - return getAll; - } - - public void setGetAll(CheckBox getAll) { - this.getAll = getAll; - } - public TextField getTablename() { return tablename; } @@ -107,4 +99,12 @@ public class DetailTableController { public void setHtml(CheckBox html) { this.html = html; } + + public CheckBox getSys() { + return sys; + } + + public void setSys(CheckBox sys) { + this.sys = sys; + } } diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/MainController.java b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/MainController.java index 8815286d..430e708f 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/MainController.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/MainController.java @@ -5,7 +5,6 @@ import javafx.event.Event; import javafx.event.EventHandler; import javafx.fxml.FXML; import javafx.scene.control.Button; -import javafx.scene.control.CheckBox; import javafx.scene.control.TableView; import javafx.scene.control.TreeView; import javafx.scene.layout.Pane; @@ -22,7 +21,7 @@ import xyz.wbsite.dbtool.javafx.tool.Dialog; import java.io.File; public class MainController { - private ProjectManager dBmanger = ManagerFactory.getdBManager(); + private ProjectManager dBmanger = ManagerFactory.getProjectManager(); @FXML private TreeView dbtree; @@ -34,8 +33,6 @@ public class MainController { private Button add; @FXML private Button sub; - @FXML - private CheckBox addSysFields; private JavaFxApplication main; @@ -67,14 +64,6 @@ public class MainController { return sub; } - public CheckBox getAddSysFields() { - return addSysFields; - } - - public void setAddSysFields(CheckBox addSysFields) { - this.addSysFields = addSysFields; - } - public void setSub(Button sub) { this.sub = sub; } diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/OptionApiController.java b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/OptionApiController.java index d8059d52..3340aa9a 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/OptionApiController.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/OptionApiController.java @@ -54,8 +54,6 @@ public class OptionApiController { @FXML private CheckBox get; @FXML - private CheckBox getAll; - @FXML private TableView apis; @FXML private List data = new ArrayList<>(); @@ -178,14 +176,6 @@ public class OptionApiController { return apis; } - public CheckBox getGetAll() { - return getAll; - } - - public void setGetAll(CheckBox getAll) { - this.getAll = getAll; - } - public void setApis(TableView apis) { this.apis = apis; } diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/manger/ManagerFactory.java b/src/main/java/xyz/wbsite/dbtool/javafx/manger/ManagerFactory.java index 60c36c66..faedc098 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/manger/ManagerFactory.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/ManagerFactory.java @@ -5,17 +5,17 @@ import xyz.wbsite.dbtool.javafx.JavaFxApplication; public class ManagerFactory { private static XmlManager xmlManager = null; private static ReflashManager reflashManager =null; - private static ProjectManager dBManager; + private static ProjectManager projectManager; private static FreeMarkerManager freeMarkerManager; static { xmlManager = new XmlManager(); - dBManager = new ProjectManager(); + projectManager = new ProjectManager(); freeMarkerManager = new FreeMarkerManager(); } - public static ProjectManager getdBManager() { - return dBManager; + public static ProjectManager getProjectManager() { + return projectManager; } public static FreeMarkerManager getFreeMarkerManager() { diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/manger/ProjectManager.java b/src/main/java/xyz/wbsite/dbtool/javafx/manger/ProjectManager.java index ccf47cd8..74d3fae1 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/manger/ProjectManager.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/ProjectManager.java @@ -3,16 +3,41 @@ package xyz.wbsite.dbtool.javafx.manger; import org.springframework.boot.system.ApplicationHome; import xyz.wbsite.dbtool.javafx.enums.DataBase; import xyz.wbsite.dbtool.javafx.enums.FieldType; -import xyz.wbsite.dbtool.javafx.manger.callable.*; -import xyz.wbsite.dbtool.javafx.po.*; +import xyz.wbsite.dbtool.javafx.manger.callable.AndroidCallable; +import xyz.wbsite.dbtool.javafx.manger.callable.ApiCallable; +import xyz.wbsite.dbtool.javafx.manger.callable.SBMDBCallable; +import xyz.wbsite.dbtool.javafx.manger.callable.SpringBootCallable; +import xyz.wbsite.dbtool.javafx.manger.callable.SpringMVCCallable; +import xyz.wbsite.dbtool.javafx.manger.callable.VueCallable; +import xyz.wbsite.dbtool.javafx.po.AbstractDBmapper; +import xyz.wbsite.dbtool.javafx.po.AndroidOption; +import xyz.wbsite.dbtool.javafx.po.Api; +import xyz.wbsite.dbtool.javafx.po.Field; +import xyz.wbsite.dbtool.javafx.po.Module; +import xyz.wbsite.dbtool.javafx.po.MySQLDBmapper; +import xyz.wbsite.dbtool.javafx.po.OracleDBmapper; +import xyz.wbsite.dbtool.javafx.po.Project; +import xyz.wbsite.dbtool.javafx.po.SBMDBOption; +import xyz.wbsite.dbtool.javafx.po.SQLiteDBmapper; +import xyz.wbsite.dbtool.javafx.po.Table; +import xyz.wbsite.dbtool.javafx.po.VueOption; import xyz.wbsite.dbtool.javafx.tool.Dialog; import java.io.File; import java.io.FilenameFilter; -import java.sql.*; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.concurrent.*; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; public class ProjectManager { @@ -101,14 +126,94 @@ public class ProjectManager { table.setFind(true); table.setGet(true); table.setSearch(false); - table.setGetAll(false); - + table.setSys(md.isHasSysFields());//获取是否默认添加系统字段 + checkSysFields(table);// 检查或移除系统字段 md.putTable(table); return table; } } while (true); } + public void checkSysFields(Table table) { + if (table != null) { + if (table.getSys()) { + removeSysFields(table); + insertSysFields(table); + } else { + removeSysFields(table); + } + } + } + + private void removeSysFields(Table table) { + Iterator iterator = table.getFields().iterator(); + while (iterator.hasNext()) { + Field next = iterator.next(); + if (next.getIsSystem()) { + iterator.remove(); + } + } + } + + private void insertSysFields(Table table) { + Field id = new Field("ID"); + id.setIsSystem(true); + id.setIsMust(true); + id.setIsPrimaryKey(true); + id.setFieldType(FieldType.Long); + id.setFieldLength(19); + id.setFieldComment("主键"); + + Field row_version = new Field("ROW_VERSION"); + row_version.setIsSystem(true); + row_version.setIsMust(true); + row_version.setFieldType(FieldType.Long); + row_version.setFieldLength(19); + row_version.setFieldComment("行版本"); + + Field is_deleted = new Field("IS_DELETED"); + is_deleted.setIsSystem(true); + is_deleted.setIsMust(true); + is_deleted.setDefaultValue("0"); + is_deleted.setFieldType(FieldType.Boolean); + is_deleted.setFieldLength(1); + is_deleted.setFieldComment("是否已删除"); + + Field created_by = new Field("CREATE_BY"); + created_by.setIsSystem(true); + created_by.setIsMust(true); + created_by.setFieldType(FieldType.Long); + created_by.setFieldLength(19); + created_by.setFieldComment("创建用户"); + + Field creation_time = new Field("CREATE_TIME"); + creation_time.setIsSystem(true); + creation_time.setIsMust(true); + creation_time.setDefaultValue("NULL"); + creation_time.setFieldType(FieldType.Date); + creation_time.setFieldComment("创建时间"); + + Field last_updated_by = new Field("LAST_UPDATE_BY"); + last_updated_by.setIsSystem(true); + creation_time.setDefaultValue("NULL"); + last_updated_by.setFieldType(FieldType.Long); + last_updated_by.setFieldLength(19); + last_updated_by.setFieldComment("最后更新用户"); + + Field last_update_time = new Field("LAST_UPDATE_TIME"); + last_update_time.setIsSystem(true); + last_update_time.setFieldType(FieldType.Date); + last_update_time.setFieldComment("最后更新时间"); + + table.putFirstField(id); + table.putField(row_version); + table.putField(is_deleted); + table.putField(created_by); + table.putField(creation_time); + table.putField(last_updated_by); + table.putField(last_update_time); + } + public String getNewModuleName() { String base = "example"; String name = base; @@ -445,7 +550,6 @@ public class ProjectManager { table.setUpdate(true); table.setFind(true); table.setGet(false); - table.setGetAll(false); table.setSearch(false); md.putTable(table); } @@ -485,7 +589,7 @@ public class ProjectManager { } } - ManagerFactory.getdBManager().project.putModule(md); + ManagerFactory.getProjectManager().project.putModule(md); isUpdate = true; return true; } catch (Exception e) { @@ -520,7 +624,6 @@ public class ProjectManager { table.setUpdate(true); table.setFind(true); table.setGet(false); - table.setGetAll(false); table.setSearch(false); md.putTable(table); } @@ -564,7 +667,7 @@ public class ProjectManager { } } - ManagerFactory.getdBManager().project.putModule(md); + ManagerFactory.getProjectManager().project.putModule(md); isUpdate = true; return true; } catch (ClassNotFoundException e) { diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/manger/XmlManager.java b/src/main/java/xyz/wbsite/dbtool/javafx/manger/XmlManager.java index 5789083a..8fc4f691 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/manger/XmlManager.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/XmlManager.java @@ -59,6 +59,11 @@ public class XmlManager { project.setProjectAuthor(projectAuthor.item(0).getTextContent()); } + NodeList multiDB = dbElement.getElementsByTagName("multiDB"); + if (multiDB.getLength() == 1) { + project.setMultiDB(getBoolean(multiDB.item(0).getTextContent())); + } + NodeList modules = dbElement.getElementsByTagName("module"); if (modules.getLength() > 0) { @@ -83,7 +88,7 @@ public class XmlManager { NodeList hasSysFields = moduleElement.getElementsByTagName("hasSysFields"); if (hasSysFields.getLength() == 1) { - module.setHasSysFields(Boolean.parseBoolean(hasSysFields.item(0).getTextContent())); + module.setHasSysFields(getBoolean(hasSysFields.item(0).getTextContent())); } NodeList tables = moduleElement.getElementsByTagName("table"); @@ -94,14 +99,14 @@ public class XmlManager { table.setdBhandle(module); table.setTableName(tableElement.getAttribute("tableName")); table.setTableComment(tableElement.getAttribute("tableComment")); - table.setCreate(Boolean.parseBoolean(tableElement.getAttribute("create"))); - table.setDelete(Boolean.parseBoolean(tableElement.getAttribute("delete"))); - table.setUpdate(Boolean.parseBoolean(tableElement.getAttribute("update"))); - table.setFind(Boolean.parseBoolean(tableElement.getAttribute("find"))); - table.setGet(Boolean.parseBoolean(tableElement.getAttribute("get"))); - table.setSearch(Boolean.parseBoolean(tableElement.getAttribute("search"))); - table.setGetAll(Boolean.parseBoolean(tableElement.getAttribute("getAll"))); - table.setHtml(Boolean.parseBoolean(tableElement.getAttribute("html"))); + table.setCreate(getBoolean(tableElement.getAttribute("create"))); + table.setDelete(getBoolean(tableElement.getAttribute("delete"))); + table.setUpdate(getBoolean(tableElement.getAttribute("update"))); + table.setFind(getBoolean(tableElement.getAttribute("find"))); + table.setGet(getBoolean(tableElement.getAttribute("get"))); + table.setSearch(getBoolean(tableElement.getAttribute("search"))); + table.setHtml(getBoolean(tableElement.getAttribute("html"))); + table.setSys(getBoolean(tableElement.getAttribute("sys"))); NodeList fields = tableElement.getElementsByTagName("field"); @@ -114,11 +119,11 @@ public class XmlManager { field.setFieldLength(Integer.parseInt(fieldElement.getAttribute("fieldLength"))); field.setFieldComment(fieldElement.getAttribute("fieldComment")); field.setDefaultValue(fieldElement.getAttribute("defaultValue")); - field.setIsSystem(Boolean.parseBoolean(fieldElement.getAttribute("IsSystem"))); - field.setIsMust(Boolean.parseBoolean(fieldElement.getAttribute("isMust"))); - field.setIsPrimaryKey(Boolean.parseBoolean(fieldElement.getAttribute("isPrimaryKey"))); - field.setIsQuery(Boolean.parseBoolean(fieldElement.getAttribute("isQuery"))); - field.setIsSearch(Boolean.parseBoolean(fieldElement.getAttribute("isSearch"))); + field.setIsSystem(getBoolean(fieldElement.getAttribute("IsSystem"))); + field.setIsMust(getBoolean(fieldElement.getAttribute("isMust"))); + field.setIsPrimaryKey(getBoolean(fieldElement.getAttribute("isPrimaryKey"))); + field.setIsQuery(getBoolean(fieldElement.getAttribute("isQuery"))); + field.setIsSearch(getBoolean(fieldElement.getAttribute("isSearch"))); table.putField(field); } } @@ -164,9 +169,12 @@ public class XmlManager { projectBasePackage.setTextContent(project.getProjectBasePackage()); Element projectAuthor = doc.createElement("projectAuthor"); projectAuthor.setTextContent(project.getProjectAuthor()); + Element multiDB = doc.createElement("multiDB"); + multiDB.setTextContent(String.valueOf(project.getMultiDB())); rootProject.appendChild(projectName); rootProject.appendChild(projectBasePackage); rootProject.appendChild(projectAuthor); + rootProject.appendChild(multiDB); Element modules = doc.createElement("modules"); rootProject.appendChild(modules); @@ -200,8 +208,8 @@ public class XmlManager { table.setAttribute("find", Boolean.toString(t.getFind())); table.setAttribute("get", Boolean.toString(t.getGet())); table.setAttribute("search", Boolean.toString(t.getSearch())); - table.setAttribute("getAll", Boolean.toString(t.getGetAll())); table.setAttribute("html", Boolean.toString(t.getHtml())); + table.setAttribute("sys", Boolean.toString(t.getSys())); Element fields = doc.createElement("fields"); @@ -249,7 +257,7 @@ public class XmlManager { if (!path.exists()) { path.mkdirs(); } - File file = new File(path, project.getProjectName() + ".xml"); + File file = new File(path, project.getProjectName() + ".xml"); if (!file.exists()) { file.createNewFile(); } @@ -275,4 +283,11 @@ public class XmlManager { } return true; } + + private boolean getBoolean(String str) { + if (str != null && str.matches("true|1")) { + return true; + } + return false; + } } diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java b/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java index 17dc9fb7..1001d91d 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java @@ -250,6 +250,10 @@ public class SpringBootCallable implements Callable { freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "TaskConfig.java"), option + "/java/config/TaskConfig.java", ctx); freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "ThreadPoolConfig.java"), option + "/java/config/ThreadPoolConfig.java", ctx); freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "WebMvcConfig.java"), option + "/java/config/WebMvcConfig.java", ctx); + if (project.getMultiDB()){ + freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "MapperMainConfig.java"), option + "/java/config/MapperMainConfig.java", ctx); + freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "MapperTwoConfig.java"), option + "/java/config/MapperTwoConfig.java", ctx); + } } /** @@ -305,7 +309,7 @@ public class SpringBootCallable implements Callable { ctx.put("table", table); freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "Mapper" + ".java"), option + "/java/module/mpr/mapperJava.ftl", ctx); - if (md.isHasSysFields()) { + if (table.getSys()) { freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "Mapper" + ".xml"), option + "/java/module/mpr/mapper.ftl", ctx); } else { freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "Mapper" + ".xml"), option + "/java/module/mpr/mapper_nosys.ftl", ctx); @@ -391,9 +395,6 @@ public class SpringBootCallable implements Callable { if (table.getSearch()) { freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "SearchRequest" + ".java"), option + "/java/module/req/searchRequestClass.ftl", ctx); } - if (table.getGetAll()) { - freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "GetAllRequest" + ".java"), option + "/java/module/req/getAllRequestClass.ftl", ctx); - } } } @@ -448,9 +449,6 @@ public class SpringBootCallable implements Callable { if (table.getSearch()) { freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "SearchResponse" + ".java"), option + "/java/module/rsp/searchResponseClass.ftl", ctx); } - if (table.getGetAll()) { - freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "GetAllResponse" + ".java"), option + "/java/module/rsp/getAllResponseClass.ftl", ctx); - } } } @@ -560,7 +558,6 @@ public class SpringBootCallable implements Callable { freeMarkerManager.outputTemp(Tool.createFile(base.getAbsolutePath(), "BaseEntity.java"), option + "/java/frame/base/BaseEntity.java", ctx); freeMarkerManager.outputTemp(Tool.createFile(base.getAbsolutePath(), "BaseFindRequest.java"), option + "/java/frame/base/BaseFindRequest.java", ctx); freeMarkerManager.outputTemp(Tool.createFile(base.getAbsolutePath(), "BaseFindResponse.java"), option + "/java/frame/base/BaseFindResponse.java", ctx); - freeMarkerManager.outputTemp(Tool.createFile(base.getAbsolutePath(), "BaseGetAllRequest.java"), option + "/java/frame/base/BaseGetAllRequest.java", ctx); freeMarkerManager.outputTemp(Tool.createFile(base.getAbsolutePath(), "BaseRequest.java"), option + "/java/frame/base/BaseRequest.java", ctx); freeMarkerManager.outputTemp(Tool.createFile(base.getAbsolutePath(), "BaseResponse.java"), option + "/java/frame/base/BaseResponse.java", ctx); freeMarkerManager.outputTemp(Tool.createFile(base.getAbsolutePath(), "BaseSearchRequest.java"), option + "/java/frame/base/BaseSearchRequest.java", ctx); @@ -645,6 +642,7 @@ public class SpringBootCallable implements Callable { HashMap ctx = new HashMap(); ctx.put("basePackage", project.getProjectBasePackage()); ctx.put("moduleName", project.getProjectName()); + ctx.put("multiDB", project.getMultiDB()); ctx.put("timestamp", new Date().getTime()); freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "Application.java"), option + "/java/Application.ftl", ctx); @@ -667,6 +665,7 @@ public class SpringBootCallable implements Callable { ctx.put("date", new Date()); ctx.put("author", project.getProjectAuthor()); ctx.put("projectName", project.getProjectName()); + ctx.put("multiDB", project.getMultiDB()); ctx.put("cloud", cloud); freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "start-dev.bat"), option + "/resources/start-dev.bat", ctx); freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "start-prod.bat"), option + "/resources/start-prod.bat", ctx); @@ -748,8 +747,9 @@ public class SpringBootCallable implements Callable { ctx.put("author", project.getProjectAuthor()); ctx.put("dBmapper", dBmapper); ctx.put("date", new Date()); + ctx.put("multiDB", project.getMultiDB()); ctx.put("cloud", cloud); - freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "application.properties"), option + "/test/application.properties", ctx); + freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "application.properties"), option + "/test/application.ftl", ctx); Tool.outputResource(option + "/test/logback-spring.xml", Tool.createFile(root.getAbsolutePath(), "logback-spring.xml")); } diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringMVCCallable.java b/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringMVCCallable.java index b2cc3362..50d698f8 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringMVCCallable.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringMVCCallable.java @@ -348,7 +348,6 @@ public class SpringMVCCallable implements Callable { freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + Tool.lineToClassName(table.getTableName()) + "UpdateRequest" + ".java"), option + "/java/req/updateRequestClass.ftl", ctx); freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + Tool.lineToClassName(table.getTableName()) + "FindRequest" + ".java"), option + "/java/req/findRequestClass.ftl", ctx); freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + Tool.lineToClassName(table.getTableName()) + "SearchRequest" + ".java"), option + "/java/req/searchRequestClass.ftl", ctx); - freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + Tool.lineToClassName(table.getTableName()) + "GetAllRequest" + ".java"), option + "/java/req/GetAllRequestClass.ftl", ctx); freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + Tool.lineToClassName(table.getTableName()) + "GetRequest" + ".java"), option + "/java/req/getRequestClass.ftl", ctx); } } catch (Exception e) { @@ -384,7 +383,6 @@ public class SpringMVCCallable implements Callable { freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + Tool.lineToClassName(table.getTableName()) + "UpdateResponse" + ".java"), option + "/java/rsp/updateResponseClass.ftl", ctx); freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + Tool.lineToClassName(table.getTableName()) + "FindResponse" + ".java"), option + "/java/rsp/findResponseClass.ftl", ctx); freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + Tool.lineToClassName(table.getTableName()) + "SearchResponse" + ".java"), option + "/java/rsp/searchResponseClass.ftl", ctx); - freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + Tool.lineToClassName(table.getTableName()) + "GetAllResponse" + ".java"), option + "/java/rsp/GetAllResponseClass.ftl", ctx); freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + Tool.lineToClassName(table.getTableName()) + "GetResponse" + ".java"), option + "/java/rsp/getResponseClass.ftl", ctx); } } catch (Exception e) { @@ -422,7 +420,6 @@ public class SpringMVCCallable implements Callable { freeMarkerManager.outputTemp(new File(base.getAbsolutePath() + File.separator + "BaseEntity.java"), option + "/java/frame/base/BaseEntity.java", ctx); freeMarkerManager.outputTemp(new File(base.getAbsolutePath() + File.separator + "BaseFindRequest.java"), option + "/java/frame/base/BaseFindRequest.java", ctx); freeMarkerManager.outputTemp(new File(base.getAbsolutePath() + File.separator + "BaseFindResponse.java"), option + "/java/frame/base/BaseFindResponse.java", ctx); - freeMarkerManager.outputTemp(new File(base.getAbsolutePath() + File.separator + "BaseGetAllRequest.java"), option + "/java/frame/base/BaseGetAllRequest.java", ctx); freeMarkerManager.outputTemp(new File(base.getAbsolutePath() + File.separator + "BaseRequest.java"), option + "/java/frame/base/BaseRequest.java", ctx); freeMarkerManager.outputTemp(new File(base.getAbsolutePath() + File.separator + "BaseResponse.java"), option + "/java/frame/base/BaseResponse.java", ctx); freeMarkerManager.outputTemp(new File(base.getAbsolutePath() + File.separator + "BaseSearchRequest.java"), option + "/java/frame/base/BaseSearchRequest.java", ctx); diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/po/Module.java b/src/main/java/xyz/wbsite/dbtool/javafx/po/Module.java index 35c9948d..f97cac03 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/po/Module.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/po/Module.java @@ -31,7 +31,7 @@ public class Module extends TreeItem { private List tables = new ArrayList(); private String moduleName; - private boolean hasSysFields; + private boolean hasSysFields = true; private String projectName; private String projectBasePackage; private String projectAuthor; diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/po/Project.java b/src/main/java/xyz/wbsite/dbtool/javafx/po/Project.java index 632dd2bf..a6abfa73 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/po/Project.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/po/Project.java @@ -11,6 +11,7 @@ public class Project extends TreeItem{ this.projectName = "EXAMPLE-WEB"; this.projectBasePackage = "com.example"; this.projectAuthor = "author"; + this.multiDB = false; } public Project(String projectName) { @@ -22,6 +23,7 @@ public class Project extends TreeItem{ private String projectName; private String projectBasePackage; private String projectAuthor; + private boolean multiDB; /** * 对象 @@ -66,4 +68,12 @@ public class Project extends TreeItem{ public void setModules(List modules) { this.modules = modules; } + + public boolean getMultiDB() { + return multiDB; + } + + public void setMultiDB(boolean multiDB) { + this.multiDB = multiDB; + } } diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/po/Table.java b/src/main/java/xyz/wbsite/dbtool/javafx/po/Table.java index ebd3d80b..182cc5ff 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/po/Table.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/po/Table.java @@ -1,6 +1,8 @@ package xyz.wbsite.dbtool.javafx.po; import javafx.scene.control.TreeItem; +import xyz.wbsite.dbtool.javafx.manger.ManagerFactory; +import xyz.wbsite.dbtool.javafx.manger.ProjectManager; import xyz.wbsite.dbtool.javafx.tool.Tool; import java.util.ArrayList; @@ -41,8 +43,8 @@ public class Table extends TreeItem { private boolean find = true; private boolean get = true; private boolean search = false; - private boolean getAll = false; private boolean html = false; + private boolean sys = true; /** * 对象字段 @@ -179,14 +181,6 @@ public class Table extends TreeItem { this.search = search; } - public boolean getGetAll() { - return getAll; - } - - public void setGetAll(boolean getAll) { - this.getAll = getAll; - } - public boolean getHtml() { return html; } @@ -194,4 +188,14 @@ public class Table extends TreeItem { public void setHtml(boolean html) { this.html = html; } + + public boolean getSys() { + return sys; + } + + public void setSys(boolean sys) { + this.sys = sys; + ProjectManager projectManager = ManagerFactory.getProjectManager(); + if (projectManager != null) projectManager.checkSysFields(this); + } } diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/tool/Dialog.java b/src/main/java/xyz/wbsite/dbtool/javafx/tool/Dialog.java index a2704ab9..933543e4 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/tool/Dialog.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/tool/Dialog.java @@ -327,7 +327,7 @@ public class Dialog { return; } - for (Module db : ManagerFactory.getdBManager().getMds()) { + for (Module db : ManagerFactory.getProjectManager().getMds()) { if (db.getModuleName().equals(userName)) { Dialog.showConfirmDialog("已经存的模块!"); return; @@ -477,12 +477,6 @@ public class Dialog { check(controller, controller.getGet().isSelected(), ".get"); } }); - controller.getGetAll().setOnAction(new EventHandler() { - @Override - public void handle(ActionEvent event) { - check(controller, controller.getGetAll().isSelected(), ".get.all"); - } - }); apiPath.requestFocus(); modulePath.textProperty().addListener(new ChangeListener() { @@ -492,7 +486,7 @@ public class Dialog { } }); - ProjectManager dBmanger = ManagerFactory.getdBManager(); + ProjectManager dBmanger = ManagerFactory.getProjectManager(); File file = dBmanger.getPath(); File[] files = file.listFiles(); @@ -567,7 +561,7 @@ public class Dialog { controller.getOk().setOnAction(new EventHandler() { @Override public void handle(ActionEvent event) { - ProjectManager dBmanger = ManagerFactory.getdBManager(); + ProjectManager dBmanger = ManagerFactory.getProjectManager(); DirectoryChooser directoryChooser = new DirectoryChooser(); directoryChooser.setInitialDirectory(dBmanger.getPath()); Stage stage = new Stage(); @@ -607,7 +601,7 @@ public class Dialog { } public static void showSBMDB() { - ProjectManager dBmanger = ManagerFactory.getdBManager(); + ProjectManager dBmanger = ManagerFactory.getProjectManager(); DirectoryChooser directoryChooser = new DirectoryChooser(); directoryChooser.setInitialDirectory(dBmanger.getPath()); Stage stage = new Stage(); @@ -645,7 +639,7 @@ public class Dialog { controller.getOk().setOnAction(new EventHandler() { @Override public void handle(ActionEvent event) { - ProjectManager dBmanger = ManagerFactory.getdBManager(); + ProjectManager dBmanger = ManagerFactory.getProjectManager(); DirectoryChooser directoryChooser = new DirectoryChooser(); directoryChooser.setInitialDirectory(dBmanger.getPath()); Stage stage = new Stage(); diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/tool/RequestReader.java b/src/main/java/xyz/wbsite/dbtool/javafx/tool/RequestReader.java index 86ff4dfd..5f4ea355 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/tool/RequestReader.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/tool/RequestReader.java @@ -86,10 +86,6 @@ public class RequestReader { hasList = true; findOrSearchflag = "1"; } - if (fatherName.contains("BaseGetAllRequest")) { - hasList = true; - findOrSearchflag = "2"; - } } continue; } diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/tool/Tool.java b/src/main/java/xyz/wbsite/dbtool/javafx/tool/Tool.java index c7933938..7da71939 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/tool/Tool.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/tool/Tool.java @@ -81,9 +81,6 @@ public class Tool { * @return */ public static String getRequestTarget(String requestName) { - if (requestName.contains("GetAllRequest")) { - return Abb2abb(requestName.substring(0, requestName.indexOf("GetAllRequest"))); - } if (requestName.startsWith("Api")) { return "api"; } @@ -109,9 +106,6 @@ public class Tool { public static String getRequestAction(String requestName) { String s = camelToPoint(requestName); - if (requestName.contains("GetAllRequest")) { - return "getAll"; - } if (requestName.startsWith("Api")) { return Abb2abb(requestName.substring(3, requestName.indexOf("Request"))); } diff --git a/src/main/java/xyz/wbsite/dbtool/web/frame/base/BaseFindRequest.java b/src/main/java/xyz/wbsite/dbtool/web/frame/base/BaseFindRequest.java index 189f0d23..52fc6c0c 100644 --- a/src/main/java/xyz/wbsite/dbtool/web/frame/base/BaseFindRequest.java +++ b/src/main/java/xyz/wbsite/dbtool/web/frame/base/BaseFindRequest.java @@ -7,9 +7,11 @@ package xyz.wbsite.dbtool.web.frame.base; * @version 0.0.1 * @since 2017-01-01 */ -public class BaseFindRequest extends BaseGetAllRequest { +public class BaseFindRequest extends BaseRequest { private int pageNumber = 1; private int pageSize = 10; + private String sortKey; + private SortType sortType; public int getPageNumber() { return pageNumber; @@ -26,4 +28,20 @@ public class BaseFindRequest extends BaseGetAllRequest { public void setPageSize(int pageSize) { this.pageSize = pageSize; } + + public String getSortKey() { + return sortKey; + } + + public void setSortKey(String sortKey) { + this.sortKey = sortKey; + } + + public SortType getSortType() { + return sortType; + } + + public void setSortType(SortType sortType) { + this.sortType = sortType; + } } diff --git a/src/main/java/xyz/wbsite/dbtool/web/frame/base/BaseGetAllRequest.java b/src/main/java/xyz/wbsite/dbtool/web/frame/base/BaseGetAllRequest.java deleted file mode 100644 index 45eba716..00000000 --- a/src/main/java/xyz/wbsite/dbtool/web/frame/base/BaseGetAllRequest.java +++ /dev/null @@ -1,32 +0,0 @@ -package xyz.wbsite.dbtool.web.frame.base; - -/** - * BaseFindRequest - 基类 - * - * @author wangbing - * @version 0.0.1 - * @since 2017-01-01 - */ -public class BaseGetAllRequest extends BaseRequest { - - private String sortKey; - - private SortType sortType; - - public String getSortKey() { - return sortKey; - } - - public void setSortKey(String sortKey) { - this.sortKey = sortKey; - } - - public SortType getSortType() { - return sortType; - } - - public void setSortType(SortType sortType) { - this.sortType = sortType; - } - -} diff --git a/src/main/resources/fxml/main.fxml b/src/main/resources/fxml/main.fxml index 71153325..492ce1bd 100644 --- a/src/main/resources/fxml/main.fxml +++ b/src/main/resources/fxml/main.fxml @@ -75,18 +75,10 @@
+
@@ -25,7 +25,7 @@
- +
@@ -41,7 +41,7 @@
- +
diff --git a/src/main/resources/modules/SpringBoot/test/application.properties b/src/main/resources/modules/SpringBoot/test/application.ftl similarity index 63% rename from src/main/resources/modules/SpringBoot/test/application.properties rename to src/main/resources/modules/SpringBoot/test/application.ftl index 2bc0f8d4..a5a96a22 100644 --- a/src/main/resources/modules/SpringBoot/test/application.properties +++ b/src/main/resources/modules/SpringBoot/test/application.ftl @@ -17,15 +17,55 @@ server.tomcat.uri-encoding=UTF-8 # 日志配置 logging.path=D:// logging.levels=DEBUG +<#if multiDB> +# ================================================================================== +<#if dataBase == 'Oracle'> +# 主数据库 +spring.datasource.main.driver-class-name=oracle.jdbc.driver.OracleDriver +spring.datasource.main.jdbc-url=jdbc:oracle:thin:@127.0.0.1:1521:main +spring.datasource.main.username=main_user +spring.datasource.main.password=main_pws + +# 副数据库 +spring.datasource.two.driver-class-name=oracle.jdbc.driver.OracleDriver +spring.datasource.two.jdbc-url=jdbc:oracle:thin:@127.0.0.1:1521:two +spring.datasource.two.username=two_user +spring.datasource.two.password=two_pwd + +<#if dataBase == 'MySQL'> +# 主数据库 +spring.datasource.main.driver-class-name=com.mysql.jdbc.Driver +spring.datasource.main.url=jdbc:mysql://192.168.31.81:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false +spring.datasource.main.username=test +spring.datasource.main.password=123456# mybatis + +# 副数据库 +spring.datasource.two.driver-class-name=com.mysql.jdbc.Driver +spring.datasource.two.url=jdbc:mysql://192.168.31.81:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false +spring.datasource.two.username=test +spring.datasource.two.password=123456 + +<#if dataBase == 'SQLite'> +# 主数据库 +spring.datasource.main.driver-class-name=org.sqlite.JDBC +spring.datasource.main.url=jdbc:sqlite:${projectName?default("SpringBoot")}.db?date_string_format=yyyy-MM-dd HH:mm:ss +spring.datasource.main.username=test +spring.datasource.main.password=123456 + +# 副数据库 +spring.datasource.two.driver-class-name=org.sqlite.JDBC +spring.datasource.two.url=jdbc:sqlite:${projectName?default("SpringBoot")}.db?date_string_format=yyyy-MM-dd HH:mm:ss +spring.datasource.two.username=test +spring.datasource.two.password=123456 + +# ================================================================================== +<#else> <#if dataBase == 'Oracle'> # Oracle spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver spring.datasource.url=jdbc:oracle:thin:@127.0.0.1:1521:orcl spring.datasource.username=TEST spring.datasource.password=123456 -# mybatis -mybatis.mapper-locations=classpath:**/mpr/*.xml -mybatis.configuration.map-underscore-to-camel-case=true <#if dataBase == 'MySQL'> # MySQL @@ -33,9 +73,6 @@ spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.url=jdbc:mysql://192.168.31.81:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false spring.datasource.username=test spring.datasource.password=123456# mybatis -# mybatis -mybatis.mapper-locations=classpath:**/mpr/*.xml -mybatis.configuration.map-underscore-to-camel-case=true <#if dataBase == 'SQLite'> # SQLite spring.datasource.url=jdbc:sqlite::resource:example.db @@ -43,6 +80,7 @@ spring.datasource.driver-class-name=org.sqlite.JDBC spring.datasource.url=jdbc:sqlite:${projectName?default("SpringBoot")}.db?date_string_format=yyyy-MM-dd HH:mm:ss spring.datasource.username=test spring.datasource.password=123456 + # mybatis mybatis.mapper-locations=classpath:**/mpr/*.xml mybatis.configuration.map-underscore-to-camel-case=true diff --git a/src/main/resources/modules/SpringBoot/test/test.ftl b/src/main/resources/modules/SpringBoot/test/test.ftl index e5f078be..c1713720 100644 --- a/src/main/resources/modules/SpringBoot/test/test.ftl +++ b/src/main/resources/modules/SpringBoot/test/test.ftl @@ -68,7 +68,7 @@ public class ${table.getCName()}Test { //删除数据 ${table.getCName()}DeleteRequest request = new ${table.getCName()}DeleteRequest(); - <#if module.isHasSysFields()> + <#if table.getSys()> request.setId(createResponse.getId()); <#else> @@ -94,15 +94,15 @@ public class ${table.getCName()}Test { //更新数据 ${table.getCName()}UpdateRequest request = new ${table.getCName()}UpdateRequest(); -<#if module.isHasSysFields()> +<#if table.getSys()> request.setId(createResponse.getId()); <#else> - <#list table.fields as field> <#if !field.isSystem> request.${field.setterName()}(${field.getTestValue()}); + ${table.getCName()}UpdateResponse response = ${table.getFName()}Manager.update(request,token); @@ -125,7 +125,7 @@ public class ${table.getCName()}Test { assertTrue(!response.hasError()); } -<#if table.getGet() && module.hasSysFields> +<#if table.getGet() && table.getSys()> @Test public void testGet() { @@ -141,24 +141,15 @@ public class ${table.getCName()}Test { //获得数据 ${table.getCName()}GetRequest request = new ${table.getCName()}GetRequest(); +<#if table.getSys()> request.setId(createResponse.getId()); + ${table.getCName()}GetResponse response = ${table.getFName()}Manager.get(request,token); assertTrue(!response.hasError() && response.get${table.getCName()}() != null); } -<#if table.getGetAll()> - - @Test - public void testGetAll() { - ${table.getCName()}GetAllRequest request = new ${table.getCName()}GetAllRequest(); - - ${table.getCName()}GetAllResponse response = ${table.getFName()}Manager.getAll(request,token); - - assertTrue(!response.hasError()); - } - <#if table.getSearch()> @Test diff --git a/src/main/resources/modules/SpringMVC_Mybatis/java/controller/AjaxController.ftl b/src/main/resources/modules/SpringMVC_Mybatis/java/controller/AjaxController.ftl index 548d6574..c11d0c27 100644 --- a/src/main/resources/modules/SpringMVC_Mybatis/java/controller/AjaxController.ftl +++ b/src/main/resources/modules/SpringMVC_Mybatis/java/controller/AjaxController.ftl @@ -137,14 +137,6 @@ public class AjaxController { return ${table.getFName()}Manager.find(request, token); } - /** - * 查询所有${table.tableComment} - */ - private BaseResponse getAll${table.getCName()}(JSONObject jsonObject, Token token) { - ${table.getCName()}GetAllRequest request = JSON.toJavaObject(jsonObject, ${table.getCName()}GetAllRequest.class); - return ${table.getFName()}Manager.getAll(request, token); - } - /** * 获得${table.tableComment} */ diff --git a/src/main/resources/modules/SpringMVC_Mybatis/java/framework/base/BaseFindRequest.java b/src/main/resources/modules/SpringMVC_Mybatis/java/framework/base/BaseFindRequest.java index 70de1543..ee546bc2 100644 --- a/src/main/resources/modules/SpringMVC_Mybatis/java/framework/base/BaseFindRequest.java +++ b/src/main/resources/modules/SpringMVC_Mybatis/java/framework/base/BaseFindRequest.java @@ -7,12 +7,32 @@ package ${basePackage}.framework.base; * @version 0.0.1 * @since 2017-01-01 */ -public class BaseFindRequest extends BaseGetAllRequest { +public class BaseFindRequest extends BaseRequest { private int pageNumber = 1; private int pageSize = 10; private int beginIndex = 0; private int endIndex = 10; + private String sortKey; + + private SortType sortType; + + public String getSortKey() { + return sortKey; + } + + public void setSortKey(String sortKey) { + this.sortKey = sortKey; + } + + public SortType getSortType() { + return sortType; + } + + public void setSortType(SortType sortType) { + this.sortType = sortType; + } + public int getPageNumber() { return pageNumber; } diff --git a/src/main/resources/modules/SpringMVC_Mybatis/java/framework/base/BaseGetAllRequest.java b/src/main/resources/modules/SpringMVC_Mybatis/java/framework/base/BaseGetAllRequest.java deleted file mode 100644 index f6f95d5d..00000000 --- a/src/main/resources/modules/SpringMVC_Mybatis/java/framework/base/BaseGetAllRequest.java +++ /dev/null @@ -1,32 +0,0 @@ -package ${basePackage}.framework.base; - -/** - * BaseFindRequest - 基类 - * - * @author wangbing - * @version 0.0.1 - * @since 2017-01-01 - */ -public class BaseGetAllRequest extends BaseRequest { - - private String sortKey; - - private SortType sortType; - - public String getSortKey() { - return sortKey; - } - - public void setSortKey(String sortKey) { - this.sortKey = sortKey; - } - - public SortType getSortType() { - return sortType; - } - - public void setSortType(SortType sortType) { - this.sortType = sortType; - } - -} diff --git a/src/main/resources/modules/SpringMVC_Mybatis/java/mgr/manager.ftl b/src/main/resources/modules/SpringMVC_Mybatis/java/mgr/manager.ftl index e517218a..6fa27974 100644 --- a/src/main/resources/modules/SpringMVC_Mybatis/java/mgr/manager.ftl +++ b/src/main/resources/modules/SpringMVC_Mybatis/java/mgr/manager.ftl @@ -58,15 +58,6 @@ public interface ${table.getCName()}Manager { */ ${table.getCName()}SearchResponse search(${table.getCName()}SearchRequest request, Token token); - /** - * 查询所有 - * - * @param request 请求对象 - * @param token 令牌 - * @return - */ - ${table.getCName()}GetAllResponse getAll(${table.getCName()}GetAllRequest request, Token token); - /** * 获得对象 * diff --git a/src/main/resources/modules/SpringMVC_Mybatis/java/rsp/getAllResponseClass.ftl b/src/main/resources/modules/SpringMVC_Mybatis/java/rsp/getAllResponseClass.ftl deleted file mode 100644 index 099aeea2..00000000 --- a/src/main/resources/modules/SpringMVC_Mybatis/java/rsp/getAllResponseClass.ftl +++ /dev/null @@ -1,14 +0,0 @@ -package ${basePackage}.${moduleName}.rsp; - -import ${basePackage}.framework.base.BaseFindResponse; -import ${basePackage}.${moduleName}.ent.${table.getCName()}; - -/** - * ${table.getCName()}GetAllResponse - ${table.tableComment} - * - * @author ${author?default("")} - * @version 0.0.1 - * @since ${date?string("yyyy-MM-dd")} - */ -public class ${table.getCName()}GetAllResponse extends BaseFindResponse<${table.getCName()}>{ -} \ No newline at end of file