diff --git a/pom.xml b/pom.xml
new file mode 100644
index 00000000..9a6f660c
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,119 @@
+
+ 4.0.0
+
+ com.wb
+ dbtool
+ 0.0.1-SNAPSHOT
+ jar
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.0.3.RELEASE
+
+
+
+
+ maven
+ http://repository.jboss.org/nexus/content/groups/public/
+
+ true
+
+
+ true
+
+ default
+
+
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ true
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.boot
+ spring-boot-starter-freemarker
+
+
+
+ org.springframework.boot
+ spring-boot-devtools
+ provided
+ true
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ org.springframework.boot
+ spring-boot-starter-security
+
+
+
+ org.apache.poi
+ poi-ooxml
+ 3.14
+
+
+ org.apache.poi
+ poi-ooxml-schemas
+ 3.14
+
+
+ com.oracle.driver
+ odbc
+ 1.0.0
+ system
+ ${basedir}/attach/ojdbc8.jar
+
+
+
+
+
+ dbtool
+
+ ${basedir}/src/main/java
+
+
+ ${basedir}/src/main/resources
+
+
+ ${basedir}/src/main/java
+
+ **/mpr/*.xml
+
+
+
+ ${basedir}/src/main/resources
+
+ *.bat
+
+ ${project.basedir}/target
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+
+
+
+
diff --git a/src/main/java/xyz/wbsite/dbtool/Application.java b/src/main/java/xyz/wbsite/dbtool/Application.java
new file mode 100644
index 00000000..0e3c5100
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/Application.java
@@ -0,0 +1,30 @@
+package xyz.wbsite.dbtool;
+
+import xyz.wbsite.dbtool.javafx.JavaFxApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@SpringBootApplication
+@EnableAutoConfiguration
+public class Application extends SpringBootServletInitializer {
+ @Override
+ protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
+ return application.sources(Application.class);
+ }
+
+ public static void main(String[] args) {
+ ExecutorService executorService = Executors.newFixedThreadPool(2);
+ executorService.execute(new Runnable() {
+ @Override
+ public void run() {
+ JavaFxApplication.main(args);
+ }
+ });
+// SpringApplication.run(Application.class, args);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/JavaFxApplication.java b/src/main/java/xyz/wbsite/dbtool/javafx/JavaFxApplication.java
new file mode 100644
index 00000000..deff452d
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/JavaFxApplication.java
@@ -0,0 +1,1372 @@
+package xyz.wbsite.dbtool.javafx;
+
+import javafx.application.Application;
+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.event.ActionEvent;
+import javafx.event.Event;
+import javafx.event.EventHandler;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Scene;
+import javafx.scene.control.*;
+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.layout.BorderPane;
+import javafx.scene.layout.GridPane;
+import javafx.scene.layout.Pane;
+import javafx.scene.paint.Color;
+import javafx.stage.Stage;
+import javafx.stage.WindowEvent;
+import javafx.util.Callback;
+import javafx.util.converter.DefaultStringConverter;
+import javafx.util.converter.IntegerStringConverter;
+import xyz.wbsite.dbtool.javafx.ctrl.DbDetailController;
+import xyz.wbsite.dbtool.javafx.ctrl.MainController;
+import xyz.wbsite.dbtool.javafx.ctrl.ProjectDetailController;
+import xyz.wbsite.dbtool.javafx.ctrl.TableDetailController;
+import xyz.wbsite.dbtool.javafx.customview.DBCheckBoxTableCell;
+import xyz.wbsite.dbtool.javafx.enumeration.FieldType;
+import xyz.wbsite.dbtool.javafx.manger.ManagerFactory;
+import xyz.wbsite.dbtool.javafx.manger.ProjectManager;
+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.Tool;
+
+import java.net.URL;
+import java.util.Iterator;
+import java.util.List;
+
+public class JavaFxApplication extends Application {
+
+ private ProjectManager dBmanger = ManagerFactory.getdBManager();
+ 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;
+ private FXMLLoader tabledetailloader;
+ private MainController mainController;
+ private ProjectDetailController projectDetailController;
+ private DbDetailController mdDetailController;
+ private TableDetailController tableDetailController;
+ private Project currentProject;
+ private Module currentMD;
+ private Table currentTable;
+ private ContextMenu project_menu;
+ private ContextMenu md_right_menu;
+ private ContextMenu table_right_menu;
+ private XEventHandler xEventHandler = new XEventHandler();
+ private boolean dragMD = false;
+
+ @Override
+ public void start(Stage primaryStage) throws Exception {
+
+ BorderPane root = mainloader.getRoot();
+
+ primaryStage.setTitle("DBtool");
+ primaryStage.setScene(new Scene(root, 700, 500));
+ primaryStage.show();
+
+ primaryStage.setOnCloseRequest(new EventHandler() {
+ @Override
+ public void handle(WindowEvent event) {
+ primaryStage.close();
+ System.exit(0);
+ }
+ });
+
+ }
+
+ @Override
+ public void init() throws Exception {
+ URL main = JavaFxApplication.class.getClassLoader().getResource("fxml/main.fxml");
+ if (main == null) {
+ main = getClass().getResource("../../../fxml/main.fxml");
+ }
+ mainloader = new FXMLLoader(main);
+ mainloader.load();
+ mainController = mainloader.getController();
+ mainController.setMain(this);
+ mdtree = mainController.getDbtree();
+ detail = mainController.getDetail();
+ feilds = mainController.getFeilds();
+ feilds.setEditable(true);
+ feilds.setSortPolicy(new Callback() {
+ @Override
+ public Boolean call(TableView param) {
+ //禁止点击列头排序
+ return false;
+ }
+ });
+ add = mainController.getAdd();
+ add.setOnMouseClicked(new EventHandler() {
+ @Override
+ public void handle(MouseEvent event) {
+ addField();
+ }
+ });
+ sub = mainController.getSub();
+ sub.setOnMouseClicked(new EventHandler() {
+ @Override
+ public void handle(MouseEvent event) {
+ subField();
+ }
+ });
+
+ 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
+ public void handle(ActionEvent event) {
+ MenuItem target = (MenuItem) event.getTarget();
+ int index = feilds.getSelectionModel().getSelectedIndex();
+ List fields = currentTable.getFields();
+
+ if ("新增".equals(target.getText())) {
+ addField();
+ }
+
+ if (index != -1) {
+ switch (target.getText()) {
+ case "删除":
+ subField();
+ break;
+ case "向上调整":
+ if (index > 0) {
+ fields.add(index - 1, fields.get(index));
+ fields.add(index + 1, fields.get(index));
+ fields.remove(index);
+ fields.remove(index + 1);
+ }
+ break;
+ case "向下调整":
+ if (index < fields.size() - 1) {
+ fields.add(index, fields.get(index + 1));
+ fields.add(index + 2, fields.get(index + 1));
+ fields.remove(index + 1);
+ fields.remove(index + 2);
+ }
+ break;
+ }
+ loadingTable();
+ feilds.getSelectionModel().clearSelection();
+ }
+ }
+ });
+ feilds.setContextMenu(con);
+
+ project_menu = new ContextMenu(new MenuItem("新增模块"));
+ md_right_menu = new ContextMenu(new MenuItem("新增对象"), new MenuItem("删除模块"), new MenuItem("向上调整"), new MenuItem("向下调整"));
+ table_right_menu = new ContextMenu(new MenuItem("删除对象"));
+ project_menu.setOnAction(xEventHandler);
+ md_right_menu.setOnAction(xEventHandler);
+ table_right_menu.setOnAction(xEventHandler);
+
+ URL projectdetail = JavaFxApplication.class.getClassLoader().getResource("fxml/projectdetail.fxml");
+ if (projectdetail == null) {
+ projectdetail = getClass().getResource("../../../fxml/projectdetail.fxml");
+ }
+ projectdetailloader = new FXMLLoader(projectdetail);
+ projectdetailloader.load();
+ projectDetailController = projectdetailloader.getController();
+
+ URL mddetail = JavaFxApplication.class.getClassLoader().getResource("fxml/moduledetail.fxml");
+ if (mddetail == null) {
+ mddetail = getClass().getResource("../../../fxml/moduledetail.fxml");
+ }
+ mddetailloader = new FXMLLoader(mddetail);
+ mddetailloader.load();
+ mdDetailController = mddetailloader.getController();
+
+
+ URL tabledetail = JavaFxApplication.class.getClassLoader().getResource("fxml/tabledetail.fxml");
+ if (tabledetail == null) {
+ tabledetail = getClass().getResource("../../../fxml/tabledetail.fxml");
+ }
+ tabledetailloader = new FXMLLoader(tabledetail);
+ tabledetailloader.load();
+ tableDetailController = tabledetailloader.getController();
+
+ mdtree.setShowRoot(true);
+ mdtree.setEditable(true);
+ mdtree.setDisable(false);
+ mdtree.setCellFactory(new Callback() {
+ @Override
+ public TreeCell call(TreeView param) {
+ TextFieldTreeCell textFieldTreeCell = new TextFieldTreeCell(new DefaultStringConverter());
+ textFieldTreeCell.setEditable(false);
+ // creating cell from deafult factory
+ TreeCell treeCell = textFieldTreeCell.forTreeView().call(param);
+ // setting handlers
+ textFieldTreeCell.setOnDragDetected(new EventHandler() {
+ @Override
+ public void handle(MouseEvent event) {
+ TextFieldTreeCell source = (TextFieldTreeCell) event.getSource();
+ String text = source.getText();
+ Module dbByDBName = dBmanger.findDBByDBName(text);
+ if (dbByDBName != null) {
+ dragMD = true;
+ } else {
+ dragMD = false;
+ }
+ if (dragMD) {
+ System.out.println("拖拽模块:" + text);
+ } else {
+ System.out.println("拖拽对象:" + text);
+ }
+ Dragboard md = source.startDragAndDrop(TransferMode.ANY);
+ ClipboardContent content = new ClipboardContent();
+ content.putString((String) source.getText());
+ md.setContent(content);
+ event.consume();
+ }
+ });
+ textFieldTreeCell.setOnDragOver(new EventHandler() {
+ @Override
+ public void handle(DragEvent event) {
+ Dragboard md = event.getDragboard();
+ TextFieldTreeCell source = (TextFieldTreeCell) event.getSource();
+
+ Module dbByDBName = dBmanger.findDBByDBName(source.getText());
+
+ if (dragMD && dbByDBName != null) {
+ double y = event.getY();
+ double height = textFieldTreeCell.getHeight();
+
+ if (source.getText().equals(md.getString())) {
+ event.acceptTransferModes(TransferMode.MOVE);
+ } else if (y >= height / 4 && y < height * 3 / 4) {
+ event.acceptTransferModes(TransferMode.MOVE);
+ }
+ }
+
+ if (!dragMD && dbByDBName == null) {
+ double y = event.getY();
+ double height = textFieldTreeCell.getHeight();
+
+ if (y >= height / 4 && y < height * 3 / 4) {
+ event.acceptTransferModes(TransferMode.MOVE);
+ } else {
+ event.acceptTransferModes(TransferMode.COPY);
+ }
+ }
+ event.consume();
+ }
+ });
+ textFieldTreeCell.setOnDragDropped(new EventHandler() {
+ @Override
+ public void handle(DragEvent event) {
+ Dragboard md = event.getDragboard();
+ String m1 = md.getString();
+
+ TreeCell source = (TreeCell) event.getSource();
+ String m2 = ((TreeCell) event.getGestureTarget()).getItem();
+
+ if (dragMD) {
+ List mds = dBmanger.getMds();
+
+ int i1 = 0, i2 = 0;
+ for (int i = 0; i < mds.size(); i++) {
+ if (mds.get(i).getModuleName().equals(m1)) {
+ i1 = i;
+ }
+ if (mds.get(i).getModuleName().equals(m2)) {
+ i2 = i;
+ }
+ }
+
+ if (event.getTransferMode().equals(TransferMode.COPY)) {//插入
+
+ } else if (event.getTransferMode().equals(TransferMode.MOVE)) {//交换
+ Tool.exchange(mds, i1, i2);
+ Tool.exchange(currentProject.getChildren(), i1, i2);
+ }
+ } else {
+ if (currentMD != null) {
+ int i1 = 0, i2 = 0;
+ Table t1 = null, t2 = null;
+ for (int i = 0; i < currentMD.getTables().size(); i++) {
+ if (currentMD.getTables().get(i).getTableName().equals(m1)) {
+ i1 = i;
+ t1 = currentMD.getTables().get(i);
+ }
+ if (currentMD.getTables().get(i).getTableName().equals(m2)) {
+ i2 = i;
+ t2 = currentMD.getTables().get(i);
+ }
+ }
+ if (t1 == null || t2 == null) {
+ return;
+ }
+
+ if (event.getTransferMode().equals(TransferMode.COPY)) {//插入
+ double y = event.getY();
+ double height = textFieldTreeCell.getHeight();
+ if (y < height / 2) {
+ currentMD.getTables().add(i2, t1);
+ currentMD.getChildren().add(i2, t1);
+ } else {
+ currentMD.getTables().add(i2 + 1, t1);
+ currentMD.getChildren().add(i2 + 1, t1);
+ }
+ if (i1 < i2) {
+ currentMD.getTables().remove(i1);
+ currentMD.getChildren().remove(i1);
+ } else {
+ currentMD.getTables().remove(i1 + 1);
+ currentMD.getChildren().remove(i1 + 1);
+ }
+
+ } else if (event.getTransferMode().equals(TransferMode.MOVE)) {//交换
+ Tool.exchange(currentMD.getTables(), i1, i2);
+ Tool.exchange(currentMD.getChildren(), i1, i2);
+ }
+ }
+ }
+ event.setDropCompleted(true);
+ event.consume();
+ mdtree.getSelectionModel().clearSelection();
+ int focusedIndex = mdtree.getFocusModel().getFocusedIndex();
+ System.out.println(focusedIndex);
+ }
+ });
+ return textFieldTreeCell;
+ }
+ });
+ mdtree.setOnEditCommit(new YEventHandler());
+ mdtree.setOnMouseClicked(new EventHandler() {
+ @Override
+ public void handle(MouseEvent event) {
+ TreeItem targetItem = (TreeItem) mdtree.getSelectionModel().getSelectedItem();
+
+ if (targetItem == null)
+ return;
+
+ int level = getLevel(targetItem);
+
+ switch (level) {
+ case 0: {//查看模块
+ mdtree.setContextMenu(project_menu);
+ loadingProject();
+ }
+ break;
+ case 1: {//查看模块
+
+ mdtree.setContextMenu(md_right_menu);
+ currentMD = dBmanger.findDBByDBName((String) targetItem.getValue());
+ currentTable = null;
+ loadingModule();
+ }
+ break;
+ case 2: {//查看对象
+ mdtree.setContextMenu(table_right_menu);
+ TreeItem parent = targetItem.getParent();
+ currentMD = dBmanger.findDBByDBName((String) parent.getValue());
+ if (currentMD != null) {
+ currentTable = dBmanger.findTableByTableName(currentMD, (String) targetItem.getValue());
+ }
+ loadingTable();
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ });
+
+
+ {//初始化模块面板
+ mdDetailController.getModuleComment().textProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends String> observable, String oldValue, String newValue) {
+ if (currentMD != null) {
+ currentMD.setModuleComment(newValue);
+ }
+ }
+ });
+
+ mdDetailController.getModulePrefix().textProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends String> observable, String oldValue, String newValue) {
+ if (currentMD != null) {
+ currentMD.setModulePrefix(newValue);
+ }
+ }
+ });
+
+ mdDetailController.getModuleName().textProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends String> observable, String oldValue, String newValue) {
+ if (currentMD != null) {
+ currentMD.setModuleName(newValue);
+ }
+ }
+ });
+ }
+
+ {// 初始化项目面板
+ projectDetailController.getProjectName().textProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends String> observable, String oldValue, String newValue) {
+ currentProject.setProjectName(newValue);
+ }
+ });
+ projectDetailController.getProjectBasePackage().textProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends String> observable, String oldValue, String newValue) {
+ currentProject.setProjectBasePackage(newValue);
+ }
+ });
+ projectDetailController.getProjectAuthor().textProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends String> observable, String oldValue, String newValue) {
+ currentProject.setProjectAuthor(newValue);
+ }
+ });
+ }
+
+ {//初始化表面板
+ tableDetailController.getTablename().textProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends String> observable, String oldValue, String newValue) {
+ if (currentTable != null) {
+ currentTable.setTableName(newValue);
+// invalidateLeft();
+ }
+ }
+ });
+ tableDetailController.getTablecomment().textProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends String> observable, String oldValue, String newValue) {
+ if (currentTable != null) {
+ currentTable.setTableComment(newValue);
+ }
+ }
+ });
+ tableDetailController.getCreate().selectedProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends Boolean> observable, Boolean oldValue, Boolean newValue) {
+ currentTable.setCreate(newValue);
+ }
+ });
+ tableDetailController.getDelete().selectedProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends Boolean> observable, Boolean oldValue, Boolean newValue) {
+ currentTable.setDelete(newValue);
+ }
+ });
+ tableDetailController.getUpdate().selectedProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends Boolean> observable, Boolean oldValue, Boolean newValue) {
+ currentTable.setUpdate(newValue);
+ }
+ });
+ tableDetailController.getFind().selectedProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends Boolean> observable, Boolean oldValue, Boolean newValue) {
+ currentTable.setFind(newValue);
+ }
+ });
+ tableDetailController.getGet().selectedProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends Boolean> observable, Boolean oldValue, Boolean newValue) {
+ currentTable.setGet(newValue);
+ }
+ });
+ tableDetailController.getSearch().selectedProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends Boolean> observable, Boolean oldValue, Boolean newValue) {
+ currentTable.setSearch(newValue);
+ }
+ });
+ tableDetailController.getGetAll().selectedProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends Boolean> observable, Boolean oldValue, Boolean newValue) {
+ currentTable.setGetAll(newValue);
+ }
+ });
+ }
+ 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();
+ String fieldName = dBmanger.getNewFieldName(fields);
+ System.out.println("新增字段-" + fieldName + "成功!");
+ feilds.getSelectionModel().select(fields.size() - 1);
+ loadingTable();
+ }
+ }
+
+ private void subField() {
+ if (currentTable != null) {
+ int selectedIndex = feilds.getSelectionModel().getSelectedIndex();
+ if (selectedIndex > -1 && !currentTable.getFields().get(selectedIndex).getIsSystem()) {
+ currentTable.getFields().remove(selectedIndex);
+ feilds.getSelectionModel().clearSelection();
+ loadingTable();
+ }
+
+ }
+ }
+
+ public void loadingProjectTree() {
+ currentProject = dBmanger.getProject();
+ currentProject.setValue(currentProject.getProjectName());
+ currentProject.setExpanded(true);
+
+ mdtree.setRoot(currentProject);
+
+ for (int i = 0; i < currentProject.getModules().size(); i++) {
+ Module module = currentProject.getModules().get(i);
+ module.setExpanded(true);
+
+ for (Table table : module.getTables()) {
+ table.setExpanded(true);
+ module.getChildren().add(table);
+ }
+ }
+
+ }
+
+ private int getLevel(TreeItem treeItem) {
+ TreeItem root = mdtree.getRoot();
+ int level = 0;
+ if (treeItem == root) {
+ level = 0;
+ } else if (treeItem.getParent() == root) {
+ level = 1;
+ } else if (treeItem.getParent().getParent() == root) {
+ level = 2;
+ }
+ return level;
+ }
+
+ private void loadingModule() {
+ if (currentMD != null) {
+ addSysFields.setSelected(currentMD.isHasSysFields());
+ }
+
+ if (currentMD == null) {
+ return;
+ }
+
+ GridPane gridPane = mddetailloader.getRoot();
+ mdDetailController.getModuleComment().setText(currentMD.getModuleComment());
+ mdDetailController.getModulePrefix().setText(currentMD.getModulePrefix());
+ mdDetailController.getModuleName().setText(currentMD.getModuleName());
+
+ if (gridPane != null) {
+ detail.getChildren().clear();
+ detail.getChildren().add(gridPane);
+ }
+ if (feilds != null && feilds.getItems() != null) {
+ feilds.getItems().clear();
+ }
+ }
+
+ private void loadingProject() {
+ GridPane gridPane = projectdetailloader.getRoot();
+ projectDetailController.getProjectName().setText(currentProject.getProjectName());
+ projectDetailController.getProjectBasePackage().setText(currentProject.getProjectBasePackage());
+ projectDetailController.getProjectAuthor().setText(currentProject.getProjectAuthor());
+
+ if (gridPane != null) {
+ detail.getChildren().clear();
+ detail.getChildren().add(gridPane);
+ }
+ if (feilds != null && feilds.getItems() != null) {
+ feilds.getItems().clear();
+ }
+ }
+
+ /**
+ * 加载对象信息
+ */
+ 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) {
+ tableDetailController.getTablename().setText(currentTable.getTableName());
+ tableDetailController.getTablecomment().setText(currentTable.getTableComment());
+ tableDetailController.getCreate().setSelected(currentTable.getCreate());
+ tableDetailController.getDelete().setSelected(currentTable.getDelete());
+ tableDetailController.getUpdate().setSelected(currentTable.getUpdate());
+ tableDetailController.getFind().setSelected(currentTable.getFind());
+ tableDetailController.getGet().setSelected(currentTable.getGet());
+ tableDetailController.getSearch().setSelected(currentTable.getSearch());
+ tableDetailController.getGetAll().setSelected(currentTable.getGetAll());
+
+ }
+
+
+ if (gridPane != null) {
+ detail.getChildren().clear();
+ detail.getChildren().add(gridPane);
+ }
+ ObservableList columns = feilds.getColumns();
+ columns.get(0).setCellValueFactory(new PropertyValueFactory("fieldName"));
+ columns.get(0).setCellFactory(new Callback() {
+ @Override
+ public TableCell call(TableColumn param) {
+
+ param.setOnEditCommit(new EventHandler() {
+ @Override
+ public void handle(TableColumn.CellEditEvent event) {
+ int row = event.getTablePosition().getRow();
+ Field field = currentTable.getFields().get(row);
+
+ String newValue = (String) event.getNewValue();
+ field.setFieldName(newValue);
+ if (newValue.endsWith("_ID")) {
+ field.setFieldType(FieldType.Long);
+ loadingTable();
+ }
+ }
+ });
+
+ TextFieldTableCell textFieldTableCell = new TextFieldTableCell(new DefaultStringConverter()) {
+
+ @Override
+ public void updateItem(Object item, boolean empty) {
+ super.updateItem(item, empty);
+ if (currentTable != null) {
+ int index = this.getTableRow().getIndex();
+ if (index >= 0 && index <= currentTable.getFields().size() - 1) {
+ Field field = currentTable.getFields().get(index);
+ if (field.getIsSystem()) {
+ ignoreField(this);
+ this.setDisable(true);
+ } else {
+ recoveryField(this);
+ this.setDisable(false);
+ }
+ }
+ }
+ }
+ };
+
+ textFieldTableCell.setOnDragDetected(new EventHandler() {
+ @Override
+ public void handle(MouseEvent event) {
+ TableCell source = (TableCell) event.getSource();
+ Dragboard md = source.startDragAndDrop(TransferMode.ANY);
+ ClipboardContent content = new ClipboardContent();
+ content.putString((String) source.getItem());
+ md.setContent(content);
+// System.out.println("Dragging: " + db.getString());
+ event.consume();
+ }
+ });
+ textFieldTableCell.setOnDragOver(new EventHandler() {
+ @Override
+ public void handle(DragEvent event) {
+ Dragboard md = event.getDragboard();
+
+ if (md.hasString()) {
+ double y = event.getY();
+ double height = textFieldTableCell.getHeight();
+
+ if (y >= height / 4 && y < height * 3 / 4) {
+ event.acceptTransferModes(TransferMode.MOVE);
+ } else {
+ event.acceptTransferModes(TransferMode.COPY);
+ }
+ }
+
+// System.out.println("DragOver: " + db.getString());
+ event.consume();
+ }
+ });
+ textFieldTableCell.setOnDragDropped(new EventHandler() {
+ @Override
+ public void handle(DragEvent event) {
+ Dragboard md = event.getDragboard();
+ String f1 = md.getString();
+
+ TableCell source = (TableCell) event.getSource();
+ String f2 = ((TableCell) event.getGestureTarget()).getText();
+
+ if (currentTable != null) {
+ int i1 = 0, i2 = 0;
+ Field t1 = null, t2 = null;
+ for (int i = 0; i < currentTable.getFields().size(); i++) {
+ if (currentTable.getFields().get(i).getFieldName().equals(f1)) {
+ i1 = i;
+ t1 = currentTable.getFields().get(i);
+ }
+ if (currentTable.getFields().get(i).getFieldName().equals(f2)) {
+ i2 = i;
+ t2 = currentTable.getFields().get(i);
+ }
+ }
+
+ if (event.getTransferMode().equals(TransferMode.COPY)) {//插入
+ double y = event.getY();
+ double height = textFieldTableCell.getHeight();
+
+ if (y < height / 2) {
+ currentTable.getFields().add(i2, t1);
+ } else {
+ currentTable.getFields().add(i2 + 1, t1);
+ }
+ if (i1 < i2) {
+ currentTable.getFields().remove(i1);
+ } else {
+ currentTable.getFields().remove(i1 + 1);
+ }
+
+ } else if (event.getTransferMode().equals(TransferMode.MOVE)) {//交换
+ currentTable.getFields().add(i1, t2);
+ currentTable.getFields().remove(i1 + 1);
+ currentTable.getFields().add(i2, t1);
+ currentTable.getFields().remove(i2 + 1);
+ }
+ loadingTable();
+ }
+ event.setDropCompleted(true);
+ event.consume();
+ }
+ });
+ return textFieldTableCell;
+ }
+ });
+ columns.get(1).setCellValueFactory(new PropertyValueFactory("fieldType"));
+ columns.get(1).setCellFactory(new Callback() {
+ @Override
+ public TableCell call(TableColumn param) {
+ ObservableList objects = FXCollections.observableArrayList();
+
+ Class clz = FieldType.class;
+ for (Object obj : clz.getEnumConstants()) {
+ if (obj instanceof FieldType) {
+ objects.add((FieldType) obj);
+ }
+ }
+ ChoiceBoxTableCell choiceBoxTableCell = new ChoiceBoxTableCell(objects) {
+ @Override
+ public void updateItem(Object item, boolean empty) {
+ super.updateItem(item, empty);
+ if (currentTable != null) {
+ int index = this.getTableRow().getIndex();
+ if (index >= 0 && index <= currentTable.getFields().size() - 1) {
+ Field field = currentTable.getFields().get(index);
+ FieldType fieldType = field.getFieldType();
+ if (fieldType.isFix() && fieldType.getDefaultLength() != field.getFieldLength()) {
+ field.setFieldLength(fieldType.getDefaultLength());
+ feilds.refresh();
+ }
+ if (field.getIsSystem()) {
+ ignoreField(this);
+ this.setDisable(true);
+ } else {
+ recoveryField(this);
+ this.setDisable(false);
+ }
+ }
+ }
+ }
+ };
+
+ param.setOnEditCommit(new EventHandler() {
+ @Override
+ public void handle(TableColumn.CellEditEvent event) {
+ int row = event.getTablePosition().getRow();
+ Field field = currentTable.getFields().get(row);
+ field.setFieldType((FieldType) event.getNewValue());
+ }
+ });
+ return choiceBoxTableCell;
+ }
+ });
+ columns.get(2).setCellValueFactory(new PropertyValueFactory("fieldLength"));
+ columns.get(2).setCellFactory(new Callback() {
+ @Override
+ public TableCell call(TableColumn param) {
+ param.setOnEditCommit(new EventHandler() {
+ @Override
+ public void handle(TableColumn.CellEditEvent event) {
+ int row = event.getTablePosition().getRow();
+ Field field = currentTable.getFields().get(row);
+ if ("String_var".equals(field.getFieldType().toString()) || "String_super".equals(field.getFieldType().toString())) {
+ try {
+ field.setFieldLength((Integer) event.getNewValue());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ feilds.refresh();
+ }
+ });
+ TextFieldTableCell textFieldTableCell = new TextFieldTableCell(new IntegerStringConverter()) {
+ @Override
+ public void updateItem(Object item, boolean empty) {
+ super.updateItem(item, empty);
+ if (currentTable != null) {
+ int index = this.getTableRow().getIndex();
+ if (index >= 0 && index <= currentTable.getFields().size() - 1) {
+ Field field = currentTable.getFields().get(index);
+ if (field.getIsSystem()) {
+ ignoreField(this);
+ this.setDisable(true);
+ } else {
+ recoveryField(this);
+ this.setDisable(false);
+ }
+ }
+ }
+ }
+ };
+ return textFieldTableCell;
+ }
+ });
+ columns.get(3).setCellValueFactory(new PropertyValueFactory("defaultValue"));
+ columns.get(3).setCellFactory(new Callback() {
+ @Override
+ public TableCell call(TableColumn param) {
+ param.setOnEditCommit(new EventHandler() {
+ @Override
+ public void handle(TableColumn.CellEditEvent event) {
+ int row = event.getTablePosition().getRow();
+ Field field = currentTable.getFields().get(row);
+ field.setDefaultValue((String) event.getNewValue());
+ }
+ });
+ return new TextFieldTableCell(new DefaultStringConverter()) {
+ @Override
+ public void updateItem(Object item, boolean empty) {
+ super.updateItem(item, empty);
+ if (currentTable != null) {
+ int index = this.getTableRow().getIndex();
+ if (index >= 0 && index <= currentTable.getFields().size() - 1) {
+ Field field = currentTable.getFields().get(index);
+ if (field.getIsSystem()) {
+ ignoreField(this);
+ this.setDisable(true);
+ } else {
+ recoveryField(this);
+ this.setDisable(false);
+ }
+ }
+ }
+ }
+ };
+ }
+ });
+ columns.get(4).setCellValueFactory(new PropertyValueFactory("isPrimaryKey"));
+ columns.get(4).setCellFactory(new Callback() {
+ @Override
+ public TableCell call(TableColumn param) {
+ DBCheckBoxTableCell checkBoxTableCell = new DBCheckBoxTableCell();
+
+ DBCheckBoxTableCell.sCallback sCallback = checkBoxTableCell.new sCallback() {
+ @Override
+ public ObservableValue call(Integer param) {
+ super.call(param);
+ List fields = currentTable.getFields();
+
+ if (fields.get(param).getIsSystem()) {
+ checkBoxTableCell.setInvalid(true);
+ } else {
+ checkBoxTableCell.setInvalid(false);
+ }
+ if (fields.get(param).getIsPrimaryKey()) {
+ return new SimpleBooleanProperty(true);
+ } else {
+ return new SimpleBooleanProperty(false);
+ }
+ }
+ };
+ checkBoxTableCell.setSelectedStateCallback(sCallback);
+ checkBoxTableCell.setOnChangeListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends Boolean> observable, Boolean oldValue, Boolean newValue) {
+ int param1 = checkBoxTableCell.getParam();
+ Field field = currentTable.getFields().get(param1);
+ field.setIsPrimaryKey(newValue);
+ }
+ });
+ return checkBoxTableCell;
+ }
+ });
+ columns.get(5).setCellValueFactory(new PropertyValueFactory("isMust"));
+ columns.get(5).setCellFactory(new Callback() {
+ @Override
+ public TableCell call(TableColumn param) {
+ final DBCheckBoxTableCell checkBoxTableCell = new DBCheckBoxTableCell();
+ DBCheckBoxTableCell.sCallback sCallback = checkBoxTableCell.new sCallback() {
+ @Override
+ public ObservableValue call(Integer param) {
+ super.call(param);
+ List fields = currentTable.getFields();
+ if (fields.get(param).getIsSystem()) {
+ checkBoxTableCell.setInvalid(true);
+ } else {
+ checkBoxTableCell.setInvalid(false);
+ }
+ if (fields.get(param).getIsMust()) {
+ return new SimpleBooleanProperty(true);
+ } else {
+ return new SimpleBooleanProperty(false);
+ }
+ }
+ };
+ checkBoxTableCell.setSelectedStateCallback(sCallback);
+ checkBoxTableCell.setOnChangeListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends Boolean> observable, Boolean oldValue, Boolean newValue) {
+ int param1 = checkBoxTableCell.getParam();
+ Field field = currentTable.getFields().get(param1);
+ field.setIsMust(newValue);
+ }
+ });
+ return checkBoxTableCell;
+ }
+ });
+ columns.get(6).setCellValueFactory(new PropertyValueFactory("isQuery"));
+ columns.get(6).setCellFactory(new Callback() {
+ @Override
+ public TableCell call(TableColumn param) {
+ final DBCheckBoxTableCell checkBoxTableCell = new DBCheckBoxTableCell();
+ DBCheckBoxTableCell.sCallback sCallback = checkBoxTableCell.new sCallback() {
+ @Override
+ public ObservableValue call(Integer param) {
+ super.call(param);
+ List fields = currentTable.getFields();
+ if (fields.get(param).getIsSystem()) {
+ checkBoxTableCell.setInvalid(true);
+ } else {
+ checkBoxTableCell.setInvalid(false);
+ }
+ if (fields.get(param).getIsQuery()) {
+ return new SimpleBooleanProperty(true);
+ } else {
+ return new SimpleBooleanProperty(false);
+ }
+ }
+ };
+ checkBoxTableCell.setSelectedStateCallback(sCallback);
+ checkBoxTableCell.setOnChangeListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends Boolean> observable, Boolean oldValue, Boolean newValue) {
+ int param1 = checkBoxTableCell.getParam();
+ Field field = currentTable.getFields().get(param1);
+ field.setIsQuery(newValue);
+ }
+ });
+ return checkBoxTableCell;
+ }
+ });
+ columns.get(7).setCellValueFactory(new PropertyValueFactory("isSearch"));
+ columns.get(7).setCellFactory(new Callback() {
+ @Override
+ public TableCell call(TableColumn param) {
+ final DBCheckBoxTableCell checkBoxTableCell = new DBCheckBoxTableCell();
+ DBCheckBoxTableCell.sCallback sCallback = checkBoxTableCell.new sCallback() {
+ @Override
+ public ObservableValue call(Integer param) {
+ super.call(param);
+ List fields = currentTable.getFields();
+ if (fields.get(param).getIsSystem()) {
+ checkBoxTableCell.setInvalid(true);
+ } else {
+ checkBoxTableCell.setInvalid(false);
+ }
+ if (fields.get(param).getIsSearch()) {
+ return new SimpleBooleanProperty(true);
+ } else {
+ return new SimpleBooleanProperty(false);
+ }
+ }
+ };
+ checkBoxTableCell.setSelectedStateCallback(sCallback);
+ checkBoxTableCell.setOnChangeListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends Boolean> observable, Boolean oldValue, Boolean newValue) {
+ int param1 = checkBoxTableCell.getParam();
+ Field field = currentTable.getFields().get(param1);
+ field.setIsSearch(newValue);
+ }
+ });
+ return checkBoxTableCell;
+ }
+ });
+ columns.get(8).setCellValueFactory(new PropertyValueFactory("fieldComment"));
+ columns.get(8).setCellFactory(new Callback() {
+ @Override
+ public TableCell call(TableColumn param) {
+
+ param.setOnEditCommit(new EventHandler() {
+ @Override
+ public void handle(TableColumn.CellEditEvent event) {
+ int row = event.getTablePosition().getRow();
+ Field field = currentTable.getFields().get(row);
+ field.setFieldComment((String) event.getNewValue());
+ }
+ });
+ return new TextFieldTableCell(new DefaultStringConverter()) {
+ @Override
+ public void updateItem(Object item, boolean empty) {
+ super.updateItem(item, empty);
+ if (currentTable != null) {
+ int index = this.getTableRow().getIndex();
+ if (index >= 0 && index <= currentTable.getFields().size() - 1) {
+ Field field = currentTable.getFields().get(index);
+ if (field.getIsSystem()) {
+ ignoreField(this);
+ this.setDisable(true);
+ } else {
+ recoveryField(this);
+ this.setDisable(false);
+ }
+ }
+ }
+ }
+ };
+ }
+ });
+
+ ObservableList data = null;
+ if (currentTable != null) {
+ List fields = currentTable.getFields();
+ data = FXCollections.observableArrayList();
+ data.addAll(fields);
+ }
+
+ feilds.setItems(data);
+ }
+
+ void ignoreField(TableCell tableCell) {
+ tableCell.setTextFill(Color.gray(0.8));
+ }
+
+ void recoveryField(TableCell tableCell) {
+ tableCell.setTextFill(Color.BLACK);
+ }
+
+
+ /**
+ * 双击目录树编辑处理器
+ */
+ private class YEventHandler implements EventHandler {
+
+ @Override
+ public void handle(TreeView.EditEvent event) {
+ TreeItem treeItem = event.getTreeItem();
+ int level = getLevel(treeItem);
+ System.out.println("原值:" + event.getOldValue());
+ System.out.println("现值:" + event.getNewValue());
+
+ switch (level) {
+ case 0: {//编辑项目名称
+ dBmanger.getProject().setProjectName((String) event.getNewValue());
+ loadingProject();
+ }
+ break;
+ case 1: {//编辑模块
+ Module md = dBmanger.findDBByDBName((String) event.getOldValue());
+ md.setModuleName((String) event.getNewValue());
+ loadingModule();
+ }
+ break;
+ case 2: {//编辑对象
+ TreeItem parent = treeItem.getParent();
+ Module md = dBmanger.findDBByDBName((String) parent.getValue());
+ Table table = dBmanger.findTableByTableName(md, (String) event.getOldValue());
+ if (table != null) {
+ table.setTableName((String) event.getNewValue());
+ loadingTable();
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
+ /**
+ * 目录树右击菜单处理器
+ */
+ private class XEventHandler implements EventHandler {
+
+ @Override
+ public void handle(Event event) {
+ MenuItem target = (MenuItem) event.getTarget();
+
+ String text = target.getText();
+ Project project =(Project) mdtree.getRoot();
+
+ TreeItem targetItem = (TreeItem) mdtree.getFocusModel().getFocusedItem();
+ int index = -1;
+ index = mdtree.getFocusModel().getFocusedIndex();
+ if (targetItem == null) {
+ targetItem = (TreeItem) mdtree.getSelectionModel().getSelectedItem();
+ }
+ if (index == -1) {
+ index = mdtree.getSelectionModel().getSelectedIndex();
+ }
+ if (text != null && targetItem != null) {
+ switch (text) {
+
+ case "向上调整":
+ if (index > 0) {
+ Tool.exchange(dBmanger.getProject().getModules(), index - 1, index);
+ Tool.exchange(dBmanger.getProject().getChildren(), index - 1, index);
+ }
+ break;
+ case "向下调整":
+ List mds = dBmanger.getMds();
+ if (index < mds.size() - 1) {
+ Tool.exchange(dBmanger.getProject().getModules(), index, index + 1);
+ Tool.exchange(dBmanger.getProject().getChildren(), index, index + 1);
+ }
+ break;
+ case "新增模块":
+ dBmanger.getNewModuleName();
+ break;
+ case "删除模块":
+ if (targetItem != null && targetItem.getParent() == project) {
+ currentProject.getChildren().remove(targetItem);
+ boolean b = dBmanger.removeDBByDBName((String) targetItem.getValue());
+ if (b) {
+ System.out.println("删除模块" + targetItem.getValue() + "成功!");
+ }
+ }
+ break;
+ case "新增对象":
+ int level = getLevel(targetItem);
+
+ switch (level) {
+ case 1: {//对模块右击
+ System.out.println("模块:" + targetItem.getValue());
+ Module md = dBmanger.findDBByDBName((String) targetItem.getValue());
+ if (md != null) {
+ Table newTableName = dBmanger.getNewTableName(md);
+ if (addSysFields.isSelected()) {
+ insertSysFields(newTableName);
+ }
+ targetItem.getChildren().add(newTableName);
+ }
+ }
+ break;
+ case 2: {//对对象右击
+ TreeItem parent = targetItem.getParent();
+ 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;
+ }
+ default:
+ break;
+ }
+ break;
+ case "删除对象":
+ level = 0;
+ if (targetItem != null && targetItem.getParent() == project) {
+ level = 0;
+ } else if (targetItem != null && targetItem.getParent().getParent() == project) {
+ level = 1;
+ }
+ switch (level) {
+ case 0: {//对模块右击
+ 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;
+ case 1: {//对对象右击
+ TreeItem parent = targetItem.getParent();
+ System.out.println("对象:" + parent.getValue());
+ Module md = dBmanger.findDBByDBName((String) parent.getValue());
+
+ for (Table table : md.getTables()) {
+ if (table.getTableName().equals(targetItem.getValue())) {
+ md.getTables().remove(table);
+ md.getChildren().remove(targetItem);
+ System.out.println("移除'" + targetItem.getValue() + "'对象成功!");
+ break;
+ }
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ default:
+ }
+ } else if (text != null && targetItem == null) {
+ switch (text) {
+ case "新增模块":
+ dBmanger.getNewModuleName();
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+
+ private void updateDbTree(List mds) {
+ TreeItem root = mdtree.getRoot();
+ for (Module md : mds) {
+ TreeItem treeItem = new TreeItem<>(md.getModuleName());
+ treeItem.setExpanded(true);
+ for (Table table : md.getTables()) {
+ TreeItem tree = new TreeItem<>(table.getTableName());
+ treeItem.getChildren().add(tree);
+ }
+ root.getChildren().add(treeItem);
+ }
+ }
+
+ public static void main(String[] args) {
+ launch(args);
+ }
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/ConnectInfoController.java b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/ConnectInfoController.java
new file mode 100644
index 00000000..a87d0e55
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/ConnectInfoController.java
@@ -0,0 +1,91 @@
+package xyz.wbsite.dbtool.javafx.ctrl;
+
+import javafx.fxml.FXML;
+import javafx.scene.control.Button;
+import javafx.scene.control.ChoiceBox;
+import javafx.scene.control.TextField;
+
+public class ConnectInfoController {
+
+ @FXML
+ private ChoiceBox databaseType;
+ @FXML
+ private TextField driver;
+ @FXML
+ private TextField url;
+ @FXML
+ private TextField userName;
+ @FXML
+ private TextField password;
+
+ @FXML
+ private Button test;
+ @FXML
+ private Button load;
+ @FXML
+ private Button cancel;
+
+ public ChoiceBox getDatabaseType() {
+ return databaseType;
+ }
+
+ public void setDatabaseType(ChoiceBox databaseType) {
+ this.databaseType = databaseType;
+ }
+
+ public TextField getUrl() {
+ return url;
+ }
+
+ public void setUrl(TextField url) {
+ this.url = url;
+ }
+
+ public TextField getUserName() {
+ return userName;
+ }
+
+ public TextField getDriver() {
+ return driver;
+ }
+
+ public void setDriver(TextField driver) {
+ this.driver = driver;
+ }
+
+ public void setUserName(TextField userName) {
+ this.userName = userName;
+ }
+
+ public TextField getPassword() {
+ return password;
+ }
+
+ public void setPassword(TextField password) {
+ this.password = password;
+ }
+
+ public Button getTest() {
+ return test;
+ }
+
+ public void setTest(Button test) {
+ this.test = test;
+ }
+
+ public Button getLoad() {
+ return load;
+ }
+
+ public void setLoad(Button load) {
+ this.load = load;
+ }
+
+ public Button getCancel() {
+ return cancel;
+ }
+
+ public void setCancel(Button cancel) {
+ this.cancel = cancel;
+ }
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/DbDetailController.java b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/DbDetailController.java
new file mode 100644
index 00000000..5e76b5c8
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/DbDetailController.java
@@ -0,0 +1,38 @@
+package xyz.wbsite.dbtool.javafx.ctrl;
+
+import javafx.fxml.FXML;
+import javafx.scene.control.TextField;
+
+public class DbDetailController {
+
+ @FXML
+ private TextField moduleComment;
+ @FXML
+ private TextField modulePrefix;
+ @FXML
+ private TextField moduleName;
+
+ public TextField getModuleName() {
+ return moduleName;
+ }
+
+ public void setModuleName(TextField moduleName) {
+ this.moduleName = moduleName;
+ }
+
+ public TextField getModuleComment() {
+ return moduleComment;
+ }
+
+ public void setModuleComment(TextField moduleComment) {
+ this.moduleComment = moduleComment;
+ }
+
+ public TextField getModulePrefix() {
+ return modulePrefix;
+ }
+
+ public void setModulePrefix(TextField modulePrefix) {
+ this.modulePrefix = modulePrefix;
+ }
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/GenerateOptionController.java b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/GenerateOptionController.java
new file mode 100644
index 00000000..c4f0eec5
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/GenerateOptionController.java
@@ -0,0 +1,79 @@
+package xyz.wbsite.dbtool.javafx.ctrl;
+
+import xyz.wbsite.dbtool.javafx.listener.GenerateOptionListener;
+import javafx.fxml.FXML;
+import javafx.scene.control.Button;
+import javafx.scene.control.CheckBox;
+import javafx.scene.control.RadioButton;
+import javafx.scene.control.ToggleGroup;
+
+public class GenerateOptionController {
+
+ private GenerateOptionListener listener;
+
+ @FXML
+ private CheckBox springmvc;
+ @FXML
+ private CheckBox mybatis;
+ @FXML
+ private ToggleGroup type;
+ @FXML
+ private ToggleGroup db;
+ @FXML
+ private Button ok;
+ @FXML
+ private Button cancel;
+
+ public String getDataBase() {
+ RadioButton value = (RadioButton) db.selectedToggleProperty().getValue();
+ String name = value.textProperty().getValue();
+ return name.toUpperCase();
+ }
+
+ public GenerateOptionListener getListener() {
+ return listener;
+ }
+
+ public void setListener(GenerateOptionListener listener) {
+ this.listener = listener;
+ }
+
+ public CheckBox getSpringmvc() {
+ return springmvc;
+ }
+
+ public void setSpringmvc(CheckBox springmvc) {
+ this.springmvc = springmvc;
+ }
+
+ public CheckBox getMybatis() {
+ return mybatis;
+ }
+
+ public void setMybatis(CheckBox mybatis) {
+ this.mybatis = mybatis;
+ }
+
+ public String getType() {
+ RadioButton value = (RadioButton) type.selectedToggleProperty().getValue();
+ String name = value.textProperty().getValue();
+ System.out.println(name);
+ return name;
+ }
+
+ public Button getOk() {
+ return ok;
+ }
+
+ public void setOk(Button ok) {
+ this.ok = ok;
+ }
+
+ public Button getCancel() {
+ return cancel;
+ }
+
+ public void setCancel(Button cancel) {
+ this.cancel = cancel;
+ }
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/MainController.java b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/MainController.java
new file mode 100644
index 00000000..613b2f6b
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/MainController.java
@@ -0,0 +1,193 @@
+package xyz.wbsite.dbtool.javafx.ctrl;
+
+import javafx.event.ActionEvent;
+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;
+import javafx.stage.DirectoryChooser;
+import javafx.stage.Stage;
+import xyz.wbsite.dbtool.javafx.JavaFxApplication;
+import xyz.wbsite.dbtool.javafx.enumeration.DataBase;
+import xyz.wbsite.dbtool.javafx.listener.GenerateOptionListener;
+import xyz.wbsite.dbtool.javafx.manger.ManagerFactory;
+import xyz.wbsite.dbtool.javafx.manger.ProjectManager;
+import xyz.wbsite.dbtool.javafx.po.Project;
+import xyz.wbsite.dbtool.javafx.tool.Dialog;
+
+import java.io.File;
+
+public class MainController {
+ private ProjectManager dBmanger = ManagerFactory.getdBManager();
+
+ @FXML
+ private TreeView dbtree;
+ @FXML
+ private Pane detail;
+ @FXML
+ private TableView feilds;
+ @FXML
+ private Button add;
+ @FXML
+ private Button sub;
+ @FXML
+ private CheckBox addSysFields;
+
+ private JavaFxApplication main;
+
+ public ProjectManager getdBmanger() {
+ return dBmanger;
+ }
+
+ public void setdBmanger(ProjectManager dBmanger) {
+ this.dBmanger = dBmanger;
+ }
+
+ public JavaFxApplication getMain() {
+ return main;
+ }
+
+ public void setMain(JavaFxApplication main) {
+ this.main = main;
+ }
+
+ public Button getAdd() {
+ return add;
+ }
+
+ public void setAdd(Button add) {
+ this.add = add;
+ }
+
+ public Button getSub() {
+ return sub;
+ }
+
+ public CheckBox getAddSysFields() {
+ return addSysFields;
+ }
+
+ public void setAddSysFields(CheckBox addSysFields) {
+ this.addSysFields = addSysFields;
+ }
+
+ public void setSub(Button sub) {
+ this.sub = sub;
+ }
+
+ public TableView getFeilds() {
+ return feilds;
+ }
+
+ public void setFeilds(TableView feilds) {
+ this.feilds = feilds;
+ }
+
+ public TreeView getDbtree() {
+ return dbtree;
+ }
+
+ public void setDbtree(TreeView dbtree) {
+ this.dbtree = dbtree;
+ }
+
+ public Pane getDetail() {
+ return detail;
+ }
+
+ public void setDetail(Pane detail) {
+ this.detail = detail;
+ }
+
+ @FXML
+ public void showFileChooser(ActionEvent actionEvent) {
+ DirectoryChooser directoryChooser = new DirectoryChooser();
+ Stage stage = new Stage();
+ File file = directoryChooser.showDialog(stage);
+
+ if (file != null && file.exists()) {
+ dBmanger.setPath(file.getAbsolutePath());
+ dBmanger.invalidate();
+ main.loadingProjectTree();
+
+ System.out.println(file.getAbsolutePath());
+ }
+ }
+
+ public boolean doSave(ActionEvent actionEvent) {
+ if (dBmanger.getPath() == null || "".equals(dBmanger.getPath())) {
+ DirectoryChooser directoryChooser = new DirectoryChooser();
+ Stage stage = new Stage();
+ File file = directoryChooser.showDialog(stage);
+
+ if (file == null) {
+
+ return false;
+ }
+ dBmanger.setPath(file.getAbsolutePath());
+ System.out.println(file.getAbsolutePath());
+ }
+ dBmanger.save();
+ System.out.println("自动保存成功");
+ return true;
+ }
+
+ @FXML
+ public void save(ActionEvent actionEvent) {
+ doSave(actionEvent);
+ }
+
+ @FXML
+ public void saveAs(ActionEvent actionEvent) {
+ DirectoryChooser directoryChooser = new DirectoryChooser();
+ Stage stage = new Stage();
+ File file = directoryChooser.showDialog(stage);
+
+ if (file != null) {
+ dBmanger.setPath(file.getAbsolutePath());
+ dBmanger.save();
+ }
+ }
+
+ @FXML
+ public void clear(ActionEvent actionEvent) {
+ Project project = dBmanger.getProject();
+ project = new Project();
+ }
+
+ @FXML
+ public void showConnectInfo(ActionEvent actionEvent) {
+ Dialog.showDBConnectInput();
+ }
+
+ @FXML
+ public void generate(ActionEvent actionEvent) {
+ if (!this.doSave(null)) {
+ return;
+ }
+ if (dBmanger.doCheck()) {
+ DirectoryChooser directoryChooser = new DirectoryChooser();
+ directoryChooser.setInitialDirectory(new File(dBmanger.getPath()));
+ Stage stage = new Stage();
+ File file = directoryChooser.showDialog(stage);
+
+ if (file != null) {
+ //展示生成方式
+ Dialog.showGenerateOption(new GenerateOptionListener() {
+ @Override
+ public void onGenerate(String option, DataBase dataBase) {
+ System.out.println("生成目录:" + file.getAbsolutePath());
+ dBmanger.generate(file.getAbsolutePath(), option, dataBase);
+ }
+ });
+ }
+ }
+ }
+
+ @FXML
+ public void generateApi(ActionEvent actionEvent) {
+ Dialog.showApi();
+ }
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/ProjectDetailController.java b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/ProjectDetailController.java
new file mode 100644
index 00000000..6a0c1700
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/ProjectDetailController.java
@@ -0,0 +1,39 @@
+package xyz.wbsite.dbtool.javafx.ctrl;
+
+import javafx.fxml.FXML;
+import javafx.scene.control.TextField;
+
+public class ProjectDetailController {
+
+ @FXML
+ private TextField projectName;
+ @FXML
+ private TextField projectBasePackage;
+ @FXML
+ private TextField projectAuthor;
+
+
+ public TextField getProjectName() {
+ return projectName;
+ }
+
+ public void setProjectName(TextField projectName) {
+ this.projectName = projectName;
+ }
+
+ public TextField getProjectBasePackage() {
+ return projectBasePackage;
+ }
+
+ public void setProjectBasePackage(TextField projectBasePackage) {
+ this.projectBasePackage = projectBasePackage;
+ }
+
+ public TextField getProjectAuthor() {
+ return projectAuthor;
+ }
+
+ public void setProjectAuthor(TextField projectAuthor) {
+ this.projectAuthor = projectAuthor;
+ }
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/SdkInfoController.java b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/SdkInfoController.java
new file mode 100644
index 00000000..7b7a535c
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/SdkInfoController.java
@@ -0,0 +1,548 @@
+package xyz.wbsite.dbtool.javafx.ctrl;
+
+import xyz.wbsite.dbtool.javafx.customview.DBCheckBoxTableCell;
+import xyz.wbsite.dbtool.javafx.po.Api;
+import xyz.wbsite.dbtool.javafx.tool.Dialog;
+import xyz.wbsite.dbtool.javafx.tool.Tool;
+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.*;
+import javafx.scene.control.cell.PropertyValueFactory;
+import javafx.scene.control.cell.TextFieldTableCell;
+import javafx.util.Callback;
+import javafx.util.converter.DefaultStringConverter;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class SdkInfoController {
+
+ @FXML
+ private TextField modulePath;
+ @FXML
+ private TextField sdkPath;
+ @FXML
+ private Button selectModulePath;
+ @FXML
+ private Button selectSdkPath;
+ @FXML
+ private Button start;
+ @FXML
+ private Button cancel;
+ @FXML
+ private CheckBox All;
+ @FXML
+ private CheckBox api;
+ @FXML
+ private CheckBox create;
+ @FXML
+ private CheckBox delete;
+ @FXML
+ private CheckBox update;
+ @FXML
+ private CheckBox find;
+ @FXML
+ private CheckBox search;
+ @FXML
+ private CheckBox get;
+ @FXML
+ private CheckBox getAll;
+ @FXML
+ private TableView apis;
+ @FXML
+ private List data = new ArrayList<>();
+
+ public Button getSelectModulePath() {
+ return selectModulePath;
+ }
+
+ public void setSelectModulePath(Button selectModulePath) {
+ this.selectModulePath = selectModulePath;
+ }
+
+ public Button getSelectSdkPath() {
+ return selectSdkPath;
+ }
+
+ public void setSelectSdkPath(Button selectSdkPath) {
+ this.selectSdkPath = selectSdkPath;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public CheckBox getSearch() {
+ return search;
+ }
+
+ public CheckBox getAll() {
+ return All;
+ }
+
+ public void setAll(CheckBox all) {
+ All = all;
+ }
+
+ public void setSearch(CheckBox search) {
+ this.search = search;
+ }
+
+ public CheckBox getCreate() {
+ return create;
+ }
+
+ public CheckBox getApi() {
+ return api;
+ }
+
+ public void setApi(CheckBox api) {
+ this.api = api;
+ }
+
+ public void setCreate(CheckBox create) {
+ this.create = create;
+ }
+
+ public CheckBox getDelete() {
+ return delete;
+ }
+
+ public void setDelete(CheckBox delete) {
+ this.delete = delete;
+ }
+
+ public CheckBox getUpdate() {
+ return update;
+ }
+
+ public void setUpdate(CheckBox update) {
+ this.update = update;
+ }
+
+ public CheckBox getFind() {
+ return find;
+ }
+
+ public void setFind(CheckBox find) {
+ this.find = find;
+ }
+
+ public CheckBox getGet() {
+ return get;
+ }
+
+ public void setGet(CheckBox get) {
+ this.get = get;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ public TextField getModulePath() {
+ return modulePath;
+ }
+
+ public void setModulePath(TextField modulePath) {
+ this.modulePath = modulePath;
+ }
+
+ public TextField getSdkPath() {
+ return sdkPath;
+ }
+
+ public void setSdkPath(TextField sdkPath) {
+ this.sdkPath = sdkPath;
+ }
+
+ 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 CheckBox getGetAll() {
+ return getAll;
+ }
+
+ public void setGetAll(CheckBox getAll) {
+ this.getAll = getAll;
+ }
+
+ public void setApis(TableView apis) {
+ this.apis = apis;
+ }
+
+ public void load() {
+ File moduleFile = new File(modulePath.getText());
+ String module = moduleFile.getName();
+
+ if (moduleFile.exists()) {
+ data.clear();
+ File reqs = new File(moduleFile.getAbsolutePath() + File.separator + "req");
+
+ if (!reqs.exists()) {
+ return;
+ }
+
+ Dialog.showProgress("扫描API...");
+ for (File req : reqs.listFiles()) {
+ Api api = new Api();
+ api.setReq(req);
+ api.setTargetRequest(req.getName().replace(".java", ""));
+
+ //查找依赖ent
+ List entities = findEntities(req);
+ for (String entity : entities) {
+ api.getDepEnt().add(entity);
+ }
+ //查找依赖enums
+ List enums = findEnums(req);
+ for (String anEnum : enums) {
+ api.getDepEnum().add(anEnum);
+ }
+ //查找依赖req
+ List reqss = findReq(req);
+ for (String string : reqss) {
+ api.getDepReq().add(string);
+ }
+
+ //找response
+ File rsp = new File(moduleFile.getAbsolutePath() + File.separator + "rsp" + File.separator + req.getName().replace("Request", "Response"));
+ if (rsp.exists()) {
+ api.setRsp(rsp);
+ api.setTargetResponse(rsp.getName().replace(".java", ""));
+
+ //查找依赖ent
+ List entities_ = findEntities(rsp);
+ for (String entity : entities_) {
+ api.getDepEnt().add(entity);
+ }
+ //查找依赖enums
+ List enums_ = findEnums(rsp);
+ for (String anEnum : enums_) {
+ api.getDepEnum().add(anEnum);
+ }
+ //查找依赖req
+ List reqss_ = findReq(rsp);
+ for (String string : reqss_) {
+ api.getDepReq().add(string);
+ }
+ }
+
+ api.setMethod("api." + module + "." + Tool.camelToPoint(req.getName().replaceAll("Request\\.java", "")));
+
+
+ if (api.getTargetRequest().startsWith("Api")){
+ api.setCheck(true);
+ }else {
+ api.setCheck(false);
+ }
+
+ if (api.getRsp() == null || !api.getRsp().exists()) {
+ api.setError("响应不存在");
+ api.setCheck(false);
+ }
+ for (String s : api.getDepReq()) {
+ File en = new File(moduleFile.getAbsolutePath() + File.separator + "req" + File.separator + s + ".java");
+ if (!en.exists()) {
+ api.setError("依赖的" + s + "(Request)不存在、");
+ api.setCheck(false);
+ }
+ }
+ for (String s : api.getDepEnt()) {
+ File en = new File(moduleFile.getAbsolutePath() + File.separator + "ent" + File.separator + s + ".java");
+ if (!en.exists()) {
+ api.setError("依赖的" + s + "(Entity)不存在、");
+ api.setCheck(false);
+ }
+ }
+ for (String s : api.getDepEnum()) {
+ File en = new File(moduleFile.getAbsolutePath() + File.separator + "enums" + File.separator + s + ".java");
+ if (!en.exists()) {
+ api.setError("依赖的" + s + "(Enum)不存在、");
+ api.setCheck(false);
+ }
+ }
+
+ data.add(api);
+ initData();
+ }
+ Dialog.stopPopup();
+ }
+ }
+
+ public List findEntities(File file) {
+ ArrayList 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 findEnums(File file) {
+ ArrayList 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(".enums.")) {
+ Pattern compile = Pattern.compile(".*\\.enums\\.(.*);");
+
+ 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 findReq(File file) {
+ ArrayList 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() {
+ @Override
+ public Boolean call(TableView param) {
+ //禁止点击列头排序
+ return false;
+ }
+ });
+ ObservableList columns = apis.getColumns();
+ columns.get(0).setCellValueFactory(new PropertyValueFactory("check"));
+ columns.get(0).setCellFactory(new Callback() {
+ @Override
+ public TableCell call(TableColumn param) {
+ final DBCheckBoxTableCell checkBoxTableCell = new DBCheckBoxTableCell();
+ DBCheckBoxTableCell.sCallback sCallback = checkBoxTableCell.new sCallback() {
+ @Override
+ public ObservableValue call(Integer param) {
+ super.call(param);
+// if (data.get(param).isCheck()) {
+// checkBoxTableCell.setInvalid(true);
+// } else {
+// checkBoxTableCell.setInvalid(false);
+// }
+ if (data.get(param).isCheck()) {
+ return new SimpleBooleanProperty(true);
+ } else {
+ return new SimpleBooleanProperty(false);
+ }
+ }
+ };
+ checkBoxTableCell.setSelectedStateCallback(sCallback);
+ checkBoxTableCell.setOnChangeListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends Boolean> observable, Boolean oldValue, Boolean newValue) {
+ int param1 = checkBoxTableCell.getParam();
+ Api api = data.get(param1);
+ api.setCheck(newValue);
+ }
+ });
+ return checkBoxTableCell;
+ }
+ });
+ columns.get(1).setCellValueFactory(new PropertyValueFactory("error"));
+ columns.get(1).setCellFactory(new Callback() {
+ @Override
+ public TableCell call(TableColumn param) {
+// param.setOnEditCommit(new EventHandler() {
+// @Override
+// public void handle(TableColumn.CellEditEvent event) {
+// int row = event.getTablePosition().getRow();
+// Api api = data.get(row);
+// api.setReqName((String) event.getNewValue());
+// }
+// });
+
+ 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("targetRequest"));
+ columns.get(2).setCellFactory(new Callback() {
+ @Override
+ public TableCell call(TableColumn param) {
+// param.setOnEditCommit(new EventHandler() {
+// @Override
+// public void handle(TableColumn.CellEditEvent event) {
+// int row = event.getTablePosition().getRow();
+// Api api = data.get(row);
+// api.setTargetRequest((String) event.getNewValue());
+// }
+// });
+ 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("targetResponse"));
+ columns.get(3).setCellFactory(new Callback() {
+ @Override
+ public TableCell call(TableColumn param) {
+// param.setOnEditCommit(new EventHandler() {
+// @Override
+// public void handle(TableColumn.CellEditEvent event) {
+// int row = event.getTablePosition().getRow();
+// Api api = data.get(row);
+// api.setTargetResponse((String) event.getNewValue());
+// }
+// });
+ 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() {
+ @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 ObservableList = FXCollections.observableArrayList();
+ ObservableList.addAll(data);
+ apis.setItems(ObservableList);
+ }
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/TableDetailController.java b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/TableDetailController.java
new file mode 100644
index 00000000..1a65f197
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/TableDetailController.java
@@ -0,0 +1,100 @@
+package xyz.wbsite.dbtool.javafx.ctrl;
+
+import javafx.fxml.FXML;
+import javafx.scene.control.CheckBox;
+import javafx.scene.control.TextField;
+
+public class TableDetailController {
+
+ @FXML
+ private TextField tablename;
+ @FXML
+ private TextField tablecomment;
+
+ @FXML
+ private CheckBox create;
+ @FXML
+ private CheckBox delete;
+ @FXML
+ private CheckBox update;
+ @FXML
+ private CheckBox find;
+ @FXML
+ private CheckBox get;
+ @FXML
+ private CheckBox search;
+ @FXML
+ private CheckBox getAll;
+
+ public CheckBox getCreate() {
+ return create;
+ }
+
+ public void setCreate(CheckBox create) {
+ this.create = create;
+ }
+
+ public CheckBox getDelete() {
+ return delete;
+ }
+
+ public void setDelete(CheckBox delete) {
+ this.delete = delete;
+ }
+
+ public CheckBox getUpdate() {
+ return update;
+ }
+
+ public void setUpdate(CheckBox update) {
+ this.update = update;
+ }
+
+ public CheckBox getFind() {
+ return find;
+ }
+
+ public void setFind(CheckBox find) {
+ this.find = find;
+ }
+
+ public CheckBox getGet() {
+ return get;
+ }
+
+ public void setGet(CheckBox get) {
+ this.get = get;
+ }
+
+ public CheckBox getSearch() {
+ return search;
+ }
+
+ public void setSearch(CheckBox search) {
+ this.search = search;
+ }
+
+ public CheckBox getGetAll() {
+ return getAll;
+ }
+
+ public void setGetAll(CheckBox getAll) {
+ this.getAll = getAll;
+ }
+
+ public TextField getTablename() {
+ return tablename;
+ }
+
+ public void setTablename(TextField tablename) {
+ this.tablename = tablename;
+ }
+
+ public TextField getTablecomment() {
+ return tablecomment;
+ }
+
+ public void setTablecomment(TextField tablecomment) {
+ this.tablecomment = tablecomment;
+ }
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/customview/DBCheckBoxTableCell.java b/src/main/java/xyz/wbsite/dbtool/javafx/customview/DBCheckBoxTableCell.java
new file mode 100644
index 00000000..8aa6889b
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/customview/DBCheckBoxTableCell.java
@@ -0,0 +1,75 @@
+package xyz.wbsite.dbtool.javafx.customview;
+
+import javafx.beans.value.ChangeListener;
+import javafx.beans.value.ObservableValue;
+import javafx.scene.control.CheckBox;
+import javafx.scene.control.cell.CheckBoxTableCell;
+import javafx.util.Callback;
+import javafx.util.StringConverter;
+
+import java.lang.reflect.Field;
+
+public class DBCheckBoxTableCell extends CheckBoxTableCell {
+
+ private CheckBox checkBox = null;
+ private int param = 0;
+
+ public DBCheckBoxTableCell() {
+ init();
+ }
+
+ public DBCheckBoxTableCell(Callback getSelectedProperty) {
+ super(getSelectedProperty);
+ init();
+ }
+
+ public void setInvalid(boolean value) {
+ super.setDisable(value);
+ }
+
+ public DBCheckBoxTableCell(Callback getSelectedProperty, StringConverter converter) {
+ super(getSelectedProperty, converter);
+ init();
+ }
+
+ public class sCallback implements Callback> {
+
+ @Override
+ public ObservableValue call(Integer param) {
+ DBCheckBoxTableCell.this.param = param;
+ return null;
+ }
+ }
+
+ public int getParam() {
+ return param;
+ }
+
+ public void setParam(int param) {
+ this.param = param;
+ }
+
+ public void setOnChangeListener(ChangeListener changeListener) {
+ checkBox.selectedProperty().addListener(changeListener);
+ }
+
+ private void init() {
+ Class> superclass = this.getClass().getSuperclass();
+
+ try {
+ Field field = superclass.getDeclaredField("checkBox");
+ field.setAccessible(true);
+ checkBox = (CheckBox) field.get(this);
+ checkBox.setFocusTraversable(false);
+ } catch (NoSuchFieldException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void updateItem(Object item, boolean empty) {
+ super.updateItem(item, empty);
+ }
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/enumeration/DataBase.java b/src/main/java/xyz/wbsite/dbtool/javafx/enumeration/DataBase.java
new file mode 100644
index 00000000..23b168d1
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/enumeration/DataBase.java
@@ -0,0 +1,7 @@
+package xyz.wbsite.dbtool.javafx.enumeration;
+
+
+public enum DataBase {
+ ORACLE,
+ MYSQL
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/enumeration/FieldType.java b/src/main/java/xyz/wbsite/dbtool/javafx/enumeration/FieldType.java
new file mode 100644
index 00000000..a0b9cee1
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/enumeration/FieldType.java
@@ -0,0 +1,240 @@
+package xyz.wbsite.dbtool.javafx.enumeration;
+
+public enum FieldType {
+ Boolean(0),
+ Byte(0),
+ Bytes(0),
+ Short(0),
+ Integer(0),
+ Long(0),
+ Float(0),
+ Double(0),
+ Character(0),
+ String_1(1),
+ String_10(10),
+ String_var(20, false),
+ String_var50(50),
+ String_var100(100),
+ String_var255(255),
+ String_var500(500),
+ String_var2500(2500),
+ String_var4000(4000),
+ String_super(0),
+ Date(0),
+ BigDecimal(0);
+
+ private int defaultLength;
+ private boolean fix = true;
+
+ public boolean isFix() {
+ return fix;
+ }
+
+ public int getDefaultLength() {
+ return defaultLength;
+ }
+
+ public void setDefaultLength(int defaultLength) {
+ this.defaultLength = defaultLength;
+ }
+
+ FieldType(int defaultLength) {
+ this.defaultLength = defaultLength;
+ }
+
+ FieldType(int defaultLength, boolean fix) {
+ this.defaultLength = defaultLength;
+ this.fix = fix;
+ }
+
+ public static FieldType parse(String str) {
+ if (str == null) {
+ return null;
+ }
+ FieldType fieldType = null;
+ try {
+ fieldType = FieldType.valueOf(str);
+ } catch (IllegalArgumentException e) {
+ tryGetsimilar(str, 0);
+ }
+ if (fieldType == null) {
+ return FieldType.String_var50;
+ }
+ return fieldType;
+ }
+
+ public static FieldType parse(String str, int length) {
+ if (str == null) {
+ return null;
+ }
+ FieldType fieldType = null;
+ try {
+ fieldType = FieldType.valueOf(str);
+ } catch (IllegalArgumentException e) {
+ fieldType = tryGetsimilar(str, length);
+ }
+ if (fieldType == null) {
+ return FieldType.String_var50;
+ }
+ return fieldType;
+ }
+
+ public static FieldType tryGetsimilar(String str, int length) {
+ if (str.contains("CHAR")) {
+ return FieldType.String_var50;
+ } else if (str.contains("NUMBER")) {
+
+ } else if (str.contains("DATE")) {
+ return FieldType.Date;
+ } else if (str.contains("BLOB")) {
+ return FieldType.Bytes;
+ }
+ return null;
+ }
+
+ @Override
+ public String toString() {
+ if (Boolean.name().equals(this.name())) {
+ return "boolean";
+ } else if (Byte.name().equals(this.name())) {
+ return "byte";
+ } else if (Short.name().equals(this.name())) {
+ return "short";
+ } else if (Integer.name().equals(this.name())) {
+ return "int";
+ } else if (Long.name().equals(this.name())) {
+ return "long";
+ } else if (Float.name().equals(this.name())) {
+ return "float";
+ } else if (Double.name().equals(this.name())) {
+ return "double";
+ } else if (Character.name().equals(this.name())) {
+ return "char";
+ } else if (Date.name().equals(this.name())) {
+ return "Date";
+ } else if (Bytes.name().equals(this.name())) {
+ return "byte[]";
+ } else if (BigDecimal.name().equals(this.name())) {
+ return "BigDecimal";
+ } else if (String_1.name().equals(this.name())) {
+ return "String_1";
+ } else if (String_10.name().equals(this.name())) {
+ return "String_10";
+ } else if (String_var.name().equals(this.name())) {
+ return "String_var";
+ } else if (String_var50.name().equals(this.name())) {
+ return "String_var50";
+ } else if (String_var100.name().equals(this.name())) {
+ return "String_var100";
+ } else if (String_var255.name().equals(this.name())) {
+ return "String_var255";
+ } else if (String_var500.name().equals(this.name())) {
+ return "String_var500";
+ } else if (String_var2500.name().equals(this.name())) {
+ return "String_var2500";
+ } else if (String_var4000.name().equals(this.name())) {
+ return "String_var4000";
+ } else if (String_super.name().equals(this.name())) {
+ return "String_super";
+ } else {
+ return "";
+ }
+ }
+
+ public String javaType() {
+ if (Boolean.name().equals(this.name())) {
+ return "Boolean";
+ } else if (Byte.name().equals(this.name())) {
+ return "Byte";
+ } else if (Short.name().equals(this.name())) {
+ return "Short";
+ } else if (Integer.name().equals(this.name())) {
+ return "Integer";
+ } else if (Long.name().equals(this.name())) {
+ return "Long";
+ } else if (Float.name().equals(this.name())) {
+ return "Float";
+ } else if (Double.name().equals(this.name())) {
+ return "Double";
+ } else if (Character.name().equals(this.name())) {
+ return "Character";
+ } else if (Date.name().equals(this.name())) {
+ return "Date";
+ } else if (Bytes.name().equals(this.name())) {
+ return "Byte[]";
+ } else if (BigDecimal.name().equals(this.name())) {
+ return "BigDecimal";
+ } else if (String_1.name().equals(this.name())) {
+ return "String";
+ } else if (String_10.name().equals(this.name())) {
+ return "String";
+ } else if (String_var.name().equals(this.name())) {
+ return "String";
+ } else if (String_var50.name().equals(this.name())) {
+ return "String";
+ } else if (String_var100.name().equals(this.name())) {
+ return "String";
+ } else if (String_var255.name().equals(this.name())) {
+ return "String";
+ } else if (String_var500.name().equals(this.name())) {
+ return "String";
+ } else if (String_var2500.name().equals(this.name())) {
+ return "String";
+ } else if (String_var4000.name().equals(this.name())) {
+ return "String";
+ } else if (String_super.name().equals(this.name())) {
+ return "String";
+ } else {
+ return "";
+ }
+ }
+
+ public String jdbcType() {
+ if (Boolean.name().equals(this.name())) {
+ return "BIT";
+ } else if (Byte.name().equals(this.name())) {
+ return "TINYINT";
+ } else if (Short.name().equals(this.name())) {
+ return "SMALLINT";
+ } else if (Integer.name().equals(this.name())) {
+ return "INTEGER";
+ } else if (Long.name().equals(this.name())) {
+ return "BIGINT";
+ } else if (Float.name().equals(this.name())) {
+ return "FLOAT";
+ } else if (Double.name().equals(this.name())) {
+ return "DOUBLE";
+ } else if (Character.name().equals(this.name())) {
+ return "CHAR";
+ } else if (Date.name().equals(this.name())) {
+ return "TIMESTAMP";
+ } else if (Bytes.name().equals(this.name())) {
+ return "BINARY";
+ } else if (BigDecimal.name().equals(this.name())) {
+ return "DECIMAL";
+ } else if (String_1.name().equals(this.name())) {
+ return "CHAR";
+ } else if (String_10.name().equals(this.name())) {
+ return "CHAR";
+ } else if (String_var.name().equals(this.name())) {
+ return "VARCHAR";
+ } else if (String_var50.name().equals(this.name())) {
+ return "VARCHAR";
+ } else if (String_var100.name().equals(this.name())) {
+ return "VARCHAR";
+ } else if (String_var255.name().equals(this.name())) {
+ return "VARCHAR";
+ } else if (String_var500.name().equals(this.name())) {
+ return "VARCHAR";
+ } else if (String_var2500.name().equals(this.name())) {
+ return "VARCHAR";
+ } else if (String_var4000.name().equals(this.name())) {
+ return "VARCHAR";
+ } else if (String_super.name().equals(this.name())) {
+ return "VARCHAR";
+ } else {
+ return "";
+ }
+
+ }
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/listener/GenerateOptionListener.java b/src/main/java/xyz/wbsite/dbtool/javafx/listener/GenerateOptionListener.java
new file mode 100644
index 00000000..d3de38a9
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/listener/GenerateOptionListener.java
@@ -0,0 +1,7 @@
+package xyz.wbsite.dbtool.javafx.listener;
+
+import xyz.wbsite.dbtool.javafx.enumeration.DataBase;
+
+public interface GenerateOptionListener {
+ void onGenerate(String option,DataBase dataBase);
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/manger/FreeMarkerManager.java b/src/main/java/xyz/wbsite/dbtool/javafx/manger/FreeMarkerManager.java
new file mode 100644
index 00000000..57bba0e3
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/FreeMarkerManager.java
@@ -0,0 +1,61 @@
+package xyz.wbsite.dbtool.javafx.manger;
+
+import freemarker.cache.*;
+import freemarker.template.*;
+import org.springframework.core.io.DefaultResourceLoader;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.ResourceLoader;
+import org.springframework.lang.Nullable;
+import org.springframework.ui.freemarker.SpringTemplateLoader;
+import org.springframework.util.ClassUtils;
+import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
+import org.springframework.web.util.UriTemplate;
+
+import java.io.*;
+import java.net.URL;
+import java.util.Properties;
+
+public class FreeMarkerManager {
+ private FreeMarkerConfigurer freeMarkerConfigurer;
+
+ public FreeMarkerManager() {
+ freeMarkerConfigurer = new FreeMarkerConfigurer();
+ // 初始化一些配置
+ Configuration cfg = new Configuration(Configuration.VERSION_2_3_28);
+ cfg.setDefaultEncoding("UTF-8");
+ cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
+ cfg.setNumberFormat("0.##");
+
+ MultiTemplateLoader multiTemplateLoader = new MultiTemplateLoader(new TemplateLoader[]{
+ new ClassTemplateLoader(ClassUtils.getDefaultClassLoader(), "/modules"),
+ });
+
+ cfg.setTemplateLoader(multiTemplateLoader);
+ freeMarkerConfigurer.setConfiguration(cfg);
+ }
+
+ public void outputTemp(File outfile, String template, Object model) {
+ try {
+ if (!outfile.exists()) {
+ outfile.createNewFile();
+ }
+
+ //获取连接
+ Configuration configuration = freeMarkerConfigurer.getConfiguration();
+ //设置编码
+ configuration.setDefaultEncoding("UTF-8");
+ //获取ftl,由于已经在配置文件中配置了路径所以在这里直接写模板名称就可以
+ Template temp = configuration.getTemplate(template);
+ //输出文件路径
+ Writer wr = new OutputStreamWriter(new FileOutputStream(outfile),"UTF-8");
+ //写入
+ temp.process(model, wr);
+ //关闭流
+ wr.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (TemplateException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/manger/ManagerFactory.java b/src/main/java/xyz/wbsite/dbtool/javafx/manger/ManagerFactory.java
new file mode 100644
index 00000000..60c36c66
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/ManagerFactory.java
@@ -0,0 +1,36 @@
+package xyz.wbsite.dbtool.javafx.manger;
+
+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 FreeMarkerManager freeMarkerManager;
+
+ static {
+ xmlManager = new XmlManager();
+ dBManager = new ProjectManager();
+ freeMarkerManager = new FreeMarkerManager();
+ }
+
+ public static ProjectManager getdBManager() {
+ return dBManager;
+ }
+
+ public static FreeMarkerManager getFreeMarkerManager() {
+ return freeMarkerManager;
+ }
+
+
+ public static XmlManager getXmlManager() {
+ return xmlManager;
+ }
+
+ public static ReflashManager getReflashManager(JavaFxApplication main) {
+ if (reflashManager == null){
+ reflashManager = new ReflashManager(main);
+ }
+ return reflashManager;
+ }
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/manger/ProjectManager.java b/src/main/java/xyz/wbsite/dbtool/javafx/manger/ProjectManager.java
new file mode 100644
index 00000000..dc4e0a8a
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/ProjectManager.java
@@ -0,0 +1,476 @@
+package xyz.wbsite.dbtool.javafx.manger;
+
+import org.springframework.boot.system.ApplicationHome;
+import xyz.wbsite.dbtool.javafx.enumeration.DataBase;
+import xyz.wbsite.dbtool.javafx.enumeration.FieldType;
+import xyz.wbsite.dbtool.javafx.manger.callable.SDKCallable;
+import xyz.wbsite.dbtool.javafx.manger.callable.SpringBootCallable;
+import xyz.wbsite.dbtool.javafx.po.*;
+import xyz.wbsite.dbtool.javafx.tool.Dialog;
+
+import java.io.File;
+import java.sql.*;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.*;
+
+public class ProjectManager {
+
+ public static boolean isUpdate = false;
+ private XmlManager xmlService;
+ public static AbstractDBmapper dBmapper;
+ public static String path;
+ private Project project = new Project();
+
+ public ProjectManager() {
+ xmlService = ManagerFactory.getXmlManager();
+ try {
+ ApplicationHome home = new ApplicationHome(getClass());
+ File jarFile = home.getSource();
+ this.path = jarFile.getParent() + File.separator + "project";
+ } catch (Exception e) {
+ e.printStackTrace();
+ this.path = System.getProperty("user.home") + File.separator + "project";
+ }
+ invalidate();
+ }
+
+ public Module findDBByDBName(String name) {
+ for (Module md : project.getModules()) {
+ if (md.getModuleName().equals(name)) {
+ return md;
+ }
+ }
+ return null;
+ }
+
+ public boolean removeDBByDBName(String name) {
+ for (Module md : project.getModules()) {
+ if (md.getModuleName().equals(name)) {
+ project.getModules().remove(md);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public Table findTableByTableName(Module md, String name) {
+ for (Table t : md.getTables()) {
+ if (t.getTableName().equals(name)) {
+ return t;
+ }
+ }
+ return null;
+ }
+
+ public Table getNewTableName(Module md) {
+ String base = "NEW_TABLE";
+ String name = base;
+ int k = 0;
+ do {
+ int i;
+ for (i = 0; i < md.getTables().size(); i++) {
+ if (name.equals(md.getTables().get(i).getTableName())) {
+ break;
+ }
+ }
+ if (i < md.getTables().size()) {
+ k++;
+ name = base + "_" + k;
+ } else {
+ Table table = new Table(name);
+ table.setTableComment("注释");
+ table.setCreate(true);
+ table.setDelete(true);
+ table.setUpdate(true);
+ table.setFind(true);
+ table.setGet(true);
+ table.setSearch(false);
+ table.setGetAll(false);
+
+ md.putTable(table);
+ return table;
+ }
+ } while (true);
+ }
+
+ public String getNewModuleName() {
+ String base = "example";
+ String name = base;
+ int k = 0;
+ do {
+ int i;
+ for (i = 0; i < project.getModules().size(); i++) {
+ if (name.equals(project.getModules().get(i).getModuleName())) {
+ break;
+ }
+ }
+ if (i < project.getModules().size()) {
+ k++;
+ name = base + k;
+ } else {
+ Module md = new Module(name);
+ md.setModuleName(name);
+ md.setModuleComment("注释");
+ project.putModule(md);
+ return name;
+ }
+ } while (true);
+ }
+
+ public String getNewFieldName(List fields) {
+ String base = "NEW_FIELD";
+ String name = base;
+ int k = 0;
+ do {
+ int i;
+ for (i = 0; i < fields.size(); i++) {
+ if (name.equals(fields.get(i).getFieldName())) {
+ break;
+ }
+ }
+ if (i < fields.size()) {
+ k++;
+ name = base + "_" + k;
+ } else {
+ Field field = new Field(name);
+ field.setDefaultValue("NULL");
+ field.setIsQuery(false);
+ field.setIsMust(false);
+ field.setIsPrimaryKey(false);
+ field.setFieldType(FieldType.String_var50);
+ field.setFieldLength(FieldType.String_var50.getDefaultLength());
+ int j = 0;
+ for (; j < fields.size(); j++) {
+ if (fields.get(j).getFieldName().equals("ROW_VERSION")) {
+ break;
+ }
+ }
+ fields.add(j, field);
+ return name;
+ }
+ } while (true);
+ }
+
+ public List getMds() {
+ return project.getModules();
+ }
+
+ public Project getProject() {
+ return project;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ if (path != null && !path.equals(this.path)) {
+ this.path = path;
+ invalidate();
+ }
+ }
+
+ public boolean doCheck() {
+ if (project.getProjectName() == null || "".equals(project.getProjectName())) {
+ Dialog.showConfirmDialog("没有填写项目名!");
+ return false;
+ } else if (project.getProjectBasePackage() == null || "".equals(project.getProjectBasePackage())) {
+ Dialog.showConfirmDialog("没有填写基本域名!");
+ return false;
+ } else if (project.getProjectAuthor() == null || "".equals(project.getProjectAuthor())) {
+ Dialog.showConfirmDialog("没有填写作者!");
+ return false;
+ }
+ for (Module md : project.getModules()) {
+ if (md.getModuleName() == null || "".equals(md.getModuleName())) {
+ Dialog.showConfirmDialog("项目" + project.getProjectName() + "没有填写模块名!");
+ return false;
+ } else if (md.getModuleComment() == null || "".equals(md.getModuleComment())) {
+ Dialog.showConfirmDialog("项目" + project.getProjectName() + "没有模块注释!");
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * 保存配置文件
+ */
+ public void save() {
+ if (path != null) {
+ File file = new File(path);
+ if (!file.exists()) {
+ file.mkdirs();
+ }
+ xmlService.save(path, project);
+ }
+ }
+
+ private void clear(File f) {
+ if (f.isDirectory()) {
+ File[] files = f.listFiles();
+ for (File file : files) {
+ if (file.isDirectory()) {
+ clear(file);
+ boolean delete = file.delete();
+
+ System.out.println("删除" + file.getName() + (delete ? "成功" : "失败"));
+ } else {
+ boolean delete = file.delete();
+
+ System.out.println("删除" + file.getName() + (delete ? "成功" : "失败"));
+ }
+ }
+ }
+ }
+
+ private static ExecutorService service = Executors.newFixedThreadPool(1);
+
+ public void tryGetDBmapper(DataBase dataBase) {
+ if (dataBase.name().equals(DataBase.MYSQL.name())) {
+ dBmapper = new MySqlDBmapper(dataBase);
+ } else if (dataBase.name().equals(DataBase.ORACLE.name())) {
+ dBmapper = new OracleDBmapper(dataBase);
+ }
+ }
+
+ /**
+ * 生成模板 入口
+ *
+ * @param path
+ */
+ public void generate(final String path, final String option, final DataBase dataBase) {
+ tryGetDBmapper(dataBase);
+
+ File root = new File(path);
+ if (!root.exists()) {
+ Dialog.showTimedDialog(1000, "目录不存在!");
+ }
+ Dialog.showProgress("生成中...");
+ new Thread() {
+ @Override
+ public void run() {
+ Callable callback = null;
+ switch (option) {
+ case "SpringBoot":
+ callback = new SpringBootCallable(path, dataBase, project, option);
+ break;
+ case "SpringMVC_Mybatis":
+// callback = new SpringMVCMybatisCallable(path, dataBase, project, option);
+ break;
+ default:
+
+ }
+
+ Future submit = service.submit(callback);
+ try {
+ submit.get();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } catch (ExecutionException e) {
+ e.printStackTrace();
+ }
+ Dialog.stopPopup();
+ Dialog.showSuccess("生成完成.");
+ }
+ }.start();
+ }
+
+
+ public void generateSDK(File module, File sdk, List apis) {
+ if (module.exists()) {
+ boolean mkdirs = sdk.mkdirs();
+ File reqList = new File(module.getAbsolutePath() + File.separator + "req");
+ File rspList = new File(module.getAbsolutePath() + File.separator + "rsp");
+ File entList = new File(module.getAbsolutePath() + File.separator + "ent");
+ File enumsList = new File(module.getAbsolutePath() + File.separator + "enums");
+ SDKCallable sdkCallable = new SDKCallable(sdk, reqList, rspList, entList, enumsList, apis);
+ Future submit = service.submit(sdkCallable);
+ try {
+ Boolean b = (Boolean) submit.get();
+ if (!b) {
+ Dialog.showError("请确认目录结构是否存在或正确!");
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } catch (ExecutionException e) {
+ e.printStackTrace();
+ }
+
+ Dialog.showSuccess("Api生成完成.");
+ }
+ }
+
+ public void invalidate() {
+ project = xmlService.inflate(path);
+ }
+
+ public static boolean testConnect(Map properties) {
+
+ String url = properties.get("url");
+ String username = properties.get("username");
+ String password = properties.get("password");
+ String driverClassName = properties.get("driverClassName");
+
+ try {
+ //加载MySql的驱动类
+ Class.forName(driverClassName);
+
+ Connection cn = DriverManager.getConnection(url, username, password);
+ cn.close();
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ public static boolean loadMD(Map properties) {
+
+ String type = properties.get("type");
+ String url = properties.get("url");
+ String username = properties.get("username");
+ String password = properties.get("password");
+ String driverClassName = properties.get("driverClassName");
+ Connection cn = null;
+
+ if ("Orcale".equals(type)) {
+ try {
+ dBmapper = new OracleDBmapper(DataBase.ORACLE);
+
+ //加载驱动类
+ Class.forName(driverClassName);
+ cn = DriverManager.getConnection(url, username, password);
+
+ Module md = new Module(username);
+ //查询所有表
+ Statement statement = cn.createStatement();
+ ResultSet rs = statement.executeQuery("select t.table_name,c.comments from user_tables t LEFT JOIN user_tab_comments c ON t.table_name = c.table_name ORDER BY T .table_name");
+
+ while (rs.next()) {
+ Table table = new Table(rs.getString("table_name"), rs.getString("comments"));
+ md.putTable(table);
+ }
+
+ for (Table table : md.getTables()) {
+ String sql = "SELECT T.*,CASE WHEN C.POSITION='1' THEN '1' ELSE '0' END PrimaryKey FROM(select A.COLUMN_ID,A.COLUMN_NAME,A.DATA_TYPE,A.DATA_LENGTH,A .DATA_PRECISION,A .DATA_SCALE,A.NULLABLE,A.DATA_DEFAULT,B.comments from user_tab_columns A ,user_col_comments B where A.Table_Name='" + table.getTableName() + "' AND B.Table_Name='" + table.getTableName() + "' AND A.COLUMN_NAME=B.COLUMN_NAME) T LEFT JOIN user_cons_columns C ON T.COLUMN_NAME = C.COLUMN_NAME AND POSITION = '1' AND C.Table_Name='" + table.getTableName() + "' ORDER BY T .COLUMN_ID";
+ ResultSet set = statement.executeQuery(sql);
+
+ while (set.next()) {
+ Field field = new Field();
+
+ field.setFieldName(set.getString("COLUMN_NAME"));
+
+ String data_type = set.getString("DATA_TYPE");
+ int data_length = set.getInt("DATA_LENGTH");
+ int data_precision = set.getInt("DATA_PRECISION");
+ int data_scale = set.getInt("DATA_SCALE");
+ field.setFieldType(dBmapper.getType(data_type, data_length, data_precision, data_scale));
+ field.setFieldLength(set.getInt("DATA_LENGTH"));
+ String nullable = set.getString("NULLABLE");
+ field.setDefaultValue(set.getString("DATA_DEFAULT"));
+ field.setFieldComment(set.getString("COMMENTS"));
+ if ("N".equals(nullable)) {
+ field.setIsMust(true);
+ } else {
+ field.setIsMust(false);
+ }
+ String primarykey = set.getString("PRIMARYKEY");
+ if ("1".equals(primarykey)) {
+ field.setIsPrimaryKey(true);
+ } else {
+ field.setIsPrimaryKey(false);
+ }
+ field.setIsQuery(false);
+
+ table.putField(field);
+ }
+ }
+
+ ManagerFactory.getdBManager().project.putModule(md);
+ isUpdate = true;
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ cn.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ } else if ("Mysql".equals(type)) {
+ try {
+ dBmapper = new MySqlDBmapper(DataBase.MYSQL);
+
+ //加载驱动类
+ Class.forName(driverClassName);
+ cn = DriverManager.getConnection(url, username, password);
+
+ String[] split = url.split("/");
+ String dbName = split[split.length - 1];
+
+ Module md = new Module(dbName);
+ //查询所有表
+ Statement statement = cn.createStatement();
+ ResultSet rs = statement.executeQuery("SELECT TABLE_NAME,TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '" + dbName + "'");
+
+ while (rs.next()) {
+ Table table = new Table(rs.getString("TABLE_NAME"), rs.getString("TABLE_COMMENT"));
+ md.putTable(table);
+ }
+
+ for (Table table : md.getTables()) {
+ String sql = "select COLUMN_NAME,COLUMN_COMMENT,COLUMN_KEY,COLUMN_DEFAULT,IS_NULLABLE,DATA_TYPE, COLUMN_TYPE,CHARACTER_MAXIMUM_LENGTH from information_schema.COLUMNS where table_name = '" + table.getTableName() + "' and table_schema = '" + dbName + "' ORDER BY ORDINAL_POSITION ASC";
+ ResultSet set = statement.executeQuery(sql);
+
+ while (set.next()) {
+ Field field = new Field();
+
+ field.setFieldName(set.getString("COLUMN_NAME"));
+
+ if ("NO".equals(set.getString("IS_NULLABLE"))) {
+ field.setIsMust(true);
+ } else {
+ field.setIsMust(false);
+ }
+
+ if ("PRI".equals(set.getString("COLUMN_KEY"))) {
+ field.setIsPrimaryKey(true);
+ } else {
+ field.setIsPrimaryKey(false);
+ }
+
+ String data_type = set.getString("DATA_TYPE");
+ int data_length = set.getInt("CHARACTER_MAXIMUM_LENGTH");
+ field.setFieldType(dBmapper.getType(data_type, data_length, 0, 0));
+ field.setFieldLength(0);
+ if ("varchar".equals(data_type) || "char".equals(data_type)) {
+ int length = Integer.parseInt(set.getString("CHARACTER_MAXIMUM_LENGTH"));
+ field.setFieldLength(length);
+ }
+
+ field.setDefaultValue(set.getString("COLUMN_DEFAULT"));
+ field.setFieldComment(set.getString("COLUMN_COMMENT"));
+
+ field.setIsQuery(false);
+
+ table.putField(field);
+ }
+ }
+
+ ManagerFactory.getdBManager().project.putModule(md);
+ isUpdate = true;
+ return true;
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ return false;
+ }
+ return false;
+ }
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/manger/ReflashManager.java b/src/main/java/xyz/wbsite/dbtool/javafx/manger/ReflashManager.java
new file mode 100644
index 00000000..bbac4d1f
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/ReflashManager.java
@@ -0,0 +1,26 @@
+package xyz.wbsite.dbtool.javafx.manger;
+
+import xyz.wbsite.dbtool.javafx.JavaFxApplication;
+
+public class ReflashManager extends Thread{
+ private JavaFxApplication main;
+
+ public ReflashManager(JavaFxApplication main) {
+ this.main = main;
+ }
+
+ @Override
+ public void run() {
+ while (true){
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ if (ProjectManager.isUpdate){
+ main.loadingProjectTree();
+ ProjectManager.isUpdate = false;
+ }
+ }
+ }
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/manger/XmlManager.java b/src/main/java/xyz/wbsite/dbtool/javafx/manger/XmlManager.java
new file mode 100644
index 00000000..a0ed316d
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/XmlManager.java
@@ -0,0 +1,295 @@
+package xyz.wbsite.dbtool.javafx.manger;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import xyz.wbsite.dbtool.javafx.enumeration.FieldType;
+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 javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.*;
+
+public class XmlManager {
+
+ public Project inflate(String path) {
+ Project project = new Project();
+
+ if (path == null || "".equals(path)) {
+ return project;
+ }
+ File file = new File(path);
+ if (!file.exists()) {
+ System.err.println("目录不存在!");
+ } else {
+ File dbFile = new File(path);
+
+ if (!dbFile.exists()) {
+ dbFile.mkdir();
+ } else {
+ File[] files = dbFile.listFiles(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".xml") || name.endsWith(".XML");
+ }
+ });
+
+ //开始解析
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ for (File xml : files) {
+ FileInputStream inputStream = null;
+ try {
+ inputStream = new FileInputStream(xml);
+ Document document = documentBuilderFactory.newDocumentBuilder().parse(inputStream);
+
+ Element dbElement = document.getDocumentElement();
+
+ if ("project".endsWith(dbElement.getNodeName())) {
+ System.out.println("发现项目:" + xml.getName());
+
+ NodeList projectName = dbElement.getElementsByTagName("projectName");
+ if (projectName.getLength() == 1) {
+ project.setProjectName(projectName.item(0).getTextContent());
+ }
+
+ NodeList projectBasePackage = dbElement.getElementsByTagName("projectBasePackage");
+ if (projectBasePackage.getLength() == 1) {
+ project.setProjectBasePackage(projectBasePackage.item(0).getTextContent());
+ }
+
+ NodeList projectAuthor = dbElement.getElementsByTagName("projectAuthor");
+ if (projectAuthor.getLength() == 1) {
+ project.setProjectAuthor(projectAuthor.item(0).getTextContent());
+ }
+
+ NodeList modules = dbElement.getElementsByTagName("module");
+ if (modules.getLength() > 0) {
+
+ for (int i = 0; i < modules.getLength(); i++) {
+ Module module = new Module();
+ Element moduleElement = (Element) modules.item(i);
+
+ NodeList moduleName = moduleElement.getElementsByTagName("moduleName");
+ if (moduleName.getLength() == 1) {
+ module.setModuleName(moduleName.item(0).getTextContent());
+ }
+
+ NodeList moduleComment = moduleElement.getElementsByTagName("moduleComment");
+ if (moduleComment.getLength() == 1) {
+ module.setModuleComment(moduleComment.item(0).getTextContent());
+ }
+
+ NodeList modulePrefix = moduleElement.getElementsByTagName("modulePrefix");
+ if (modulePrefix.getLength() == 1) {
+ module.setModulePrefix(modulePrefix.item(0).getTextContent());
+ }
+
+ NodeList hasSysFields = moduleElement.getElementsByTagName("hasSysFields");
+ if (hasSysFields.getLength() == 1) {
+ module.setHasSysFields(Boolean.parseBoolean(hasSysFields.item(0).getTextContent()));
+ }
+
+ NodeList tables = moduleElement.getElementsByTagName("table");
+ if (tables.getLength() > 0) {
+ for (int j = 0; j < tables.getLength(); j++) {
+ Element tableElement = (Element) tables.item(j);
+ Table table = new Table();
+ 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")));
+
+ NodeList fields = tableElement.getElementsByTagName("field");
+
+ if (fields.getLength() > 0) {
+ for (int k = 0; k < fields.getLength(); k++) {
+ Element fieldElement = (Element) fields.item(k);
+ Field field = new Field();
+ field.setFieldName(fieldElement.getAttribute("fieldName"));
+ field.setFieldType(FieldType.parse(fieldElement.getAttribute("fieldType")));
+ 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")));
+ table.putField(field);
+ }
+ }
+ module.putTable(table);
+ }
+ }
+ project.putModule(module);
+ }
+ }
+ System.out.println("数据初始化成功...");
+ return project;
+ }
+ } catch (Exception e) {
+ System.out.println("文件:'" + xml.getName() + "'解析失败!请检查语法是否正确!");
+ e.printStackTrace();
+ } finally {
+ if (inputStream != null) {
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ }
+ }
+ return project;
+ }
+
+ public boolean saveAs(String path, Project project) {
+ DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder;
+ //生成DOM模型
+ try {
+ builder = dbFactory.newDocumentBuilder();
+ Document doc = builder.newDocument();
+
+ Element rootProject = doc.createElement("project");
+ doc.appendChild(rootProject);
+
+ Element projectName = doc.createElement("projectName");
+ projectName.setTextContent(project.getProjectName());
+ Element projectBasePackage = doc.createElement("projectBasePackage");
+ projectBasePackage.setTextContent(project.getProjectBasePackage());
+ Element projectAuthor = doc.createElement("projectAuthor");
+ projectAuthor.setTextContent(project.getProjectAuthor());
+ rootProject.appendChild(projectName);
+ rootProject.appendChild(projectBasePackage);
+ rootProject.appendChild(projectAuthor);
+
+ Element modules = doc.createElement("modules");
+ rootProject.appendChild(modules);
+
+ //region Description
+ for (Module md : project.getModules()) {
+ Element module = doc.createElement("module");
+
+ Element moduleName = doc.createElement("moduleName");
+ Element moduleComment = doc.createElement("moduleComment");
+ Element modulePrefix = doc.createElement("modulePrefix");
+ Element hasSysFields = doc.createElement("hasSysFields");
+ moduleName.setTextContent(md.getModuleName());
+ moduleComment.setTextContent(md.getModuleComment());
+ modulePrefix.setTextContent(md.getModulePrefix());
+ hasSysFields.setTextContent(String.valueOf(md.isHasSysFields()));
+ module.appendChild(moduleComment);
+ module.appendChild(modulePrefix);
+ module.appendChild(moduleName);
+ module.appendChild(hasSysFields);
+
+ Element tables = doc.createElement("tables");
+ module.appendChild(tables);
+ for (Table t : md.getTables()) {
+ Element table = doc.createElement("table");
+ table.setAttribute("tableName", t.getTableName());
+ table.setAttribute("tableComment", t.getTableComment());
+ table.setAttribute("create", t.getCreate().toString());
+ table.setAttribute("delete", t.getDelete().toString());
+ table.setAttribute("update", t.getUpdate().toString());
+ table.setAttribute("find", t.getFind().toString());
+ table.setAttribute("get", t.getGet().toString());
+ table.setAttribute("search", t.getSearch().toString());
+ table.setAttribute("getAll", t.getGetAll().toString());
+
+ Element fields = doc.createElement("fields");
+
+ table.appendChild(fields);
+
+ for (Field f : t.getFields()) {
+ Element field = doc.createElement("field");
+ field.setAttribute("fieldName", f.getFieldName());
+ if (f.getFieldType() != null) {
+ field.setAttribute("fieldType", f.getFieldType().name());
+ }
+ if (f.getFieldLength() != null) {
+ field.setAttribute("fieldLength", f.getFieldLength().toString());
+ }
+ field.setAttribute("fieldComment", f.getFieldComment());
+ field.setAttribute("defaultValue", f.getDefaultValue());
+ if (f.getIsMust() != null) {
+ field.setAttribute("isMust", f.getIsMust().toString());
+ }
+ field.setAttribute("isQuery", f.getIsQuery().toString());
+ field.setAttribute("isSearch", f.getIsSearch().toString());
+ if (f.getIsPrimaryKey() != null) {
+ field.setAttribute("isPrimaryKey", f.getIsPrimaryKey().toString());
+ }
+ if (f.getIsSystem() != null) {
+ field.setAttribute("IsSystem", f.getIsSystem().toString());
+ }
+ fields.appendChild(field);
+ }
+ tables.appendChild(table);
+ }
+ modules.appendChild(module);
+ }
+ //endregion
+
+ //输出文件
+ FileOutputStream stream = null;
+ try {
+ Transformer t = TransformerFactory.newInstance().newTransformer();
+
+ //设置换行和缩进
+ t.setOutputProperty(OutputKeys.INDENT, "yes");
+ t.setOutputProperty(OutputKeys.METHOD, "xml");
+
+ File dbFile = new File(path);
+ if (!dbFile.exists()) {
+ dbFile.mkdirs();
+ }
+ File file = new File(dbFile.getAbsolutePath() + File.separator + project.getProjectName() + ".xml");
+ if (!file.exists()) {
+ file.createNewFile();
+ }
+ stream = new FileOutputStream(file);
+ t.transform(new DOMSource(doc), new StreamResult(stream));
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ } finally {
+ if (stream != null) {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ } catch (ParserConfigurationException e) {
+ e.printStackTrace();
+ e.printStackTrace();
+ return false;
+ }
+ return true;
+ }
+
+ public boolean save(String path, Project project) {
+ File projectFile = new File(path);
+ saveAs(projectFile.getAbsolutePath(), project);
+ return true;
+ }
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SDKCallable.java b/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SDKCallable.java
new file mode 100644
index 00000000..d881eab6
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SDKCallable.java
@@ -0,0 +1,748 @@
+package xyz.wbsite.dbtool.javafx.manger.callable;
+
+import xyz.wbsite.dbtool.javafx.manger.ProjectManager;
+import xyz.wbsite.dbtool.javafx.manger.FreeMarkerManager;
+import xyz.wbsite.dbtool.javafx.manger.ManagerFactory;
+import xyz.wbsite.dbtool.javafx.po.AbstractDBmapper;
+import xyz.wbsite.dbtool.javafx.po.Api;
+import xyz.wbsite.dbtool.javafx.tool.JavaClassReader;
+import xyz.wbsite.dbtool.javafx.tool.JavaEnumReader;
+import xyz.wbsite.dbtool.javafx.tool.Tool;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+import java.util.concurrent.Callable;
+
+import static xyz.wbsite.dbtool.javafx.tool.Tool.clear;
+
+public class SDKCallable implements Callable {
+
+ private File sdk;
+ private File req;
+ private File rsp;
+ private File ent;
+ private File enums;
+ private List apis;
+ private Tool tool = new Tool();
+
+ private FreeMarkerManager freeMarkerManager;
+
+ public SDKCallable(File sdk, File req, File rsp, File ent, File enums, List apis) {
+ this.sdk = sdk;
+ this.req = req;
+ this.rsp = rsp;
+ this.ent = ent;
+ this.enums = enums;
+ this.apis = apis;
+ this.freeMarkerManager = ManagerFactory.getFreeMarkerManager();
+ }
+
+ private AbstractDBmapper dBmapper;
+
+ public Boolean call() throws Exception {
+ if (!sdk.exists()) {
+ sdk.mkdir();
+ } else {
+ clear(sdk);
+ }
+
+ dBmapper = ProjectManager.dBmapper;
+
+ {
+ System.out.println("生成模块:Pom");
+ HashMap ctx = new HashMap();
+ ctx.put("sdk", sdk.getName().toLowerCase());
+ File file = new File(sdk.getAbsolutePath() + File.separator + "pom.xml");
+ freeMarkerManager.outputTemp(file, "Java_api/pom.ftl", ctx);
+ }
+
+ File frameWork = null;
+ String domain = null;
+ String module = null;
+ Set managerList = new HashSet<>();
+ List methodList = new ArrayList<>();
+
+ for (Api api : apis) {
+ if (api.isCheck()) {
+
+ try {
+ //region 生成request
+ JavaClassReader javaClassReader = new JavaClassReader(api.getReq());
+
+ Method method = new Method();
+ method.setStringMethod(api.getMethod());
+ method.setRequest(javaClassReader.getClassName());
+ method.setTarget(Tool.getRequestTarget(javaClassReader.getClassName()));
+ method.setMethod(Tool.getRequestAction(javaClassReader.getClassName()));
+ method.setManager(Tool.getRequestTarget(javaClassReader.getClassName()) + "Manager");
+ methodList.add(method);
+ StringBuffer stringBuffer = new StringBuffer("");
+ stringBuffer.append(sdk.getPath() + File.separator);
+ stringBuffer.append("src" + File.separator);
+ stringBuffer.append("main" + File.separator);
+ stringBuffer.append("java" + File.separator);
+
+ String[] split = javaClassReader.getDomainName().split("\\.");
+
+ managerList.add(method.getManager());
+
+ for (String s1 : split) {
+ stringBuffer.append(s1 + File.separator);
+ }
+ if (frameWork == null) {
+ frameWork = new File(stringBuffer.toString());
+ frameWork.mkdirs();
+ }
+ if (domain == null) {
+ domain = javaClassReader.getDomainName();
+ }
+ if (module == null) {
+ module = javaClassReader.getModuleName();
+ }
+
+ stringBuffer.append(javaClassReader.getModuleName());
+
+ File request = new File(stringBuffer.toString() + File.separator + "request");
+ request.mkdirs();
+
+ {
+ HashMap ctx = new HashMap();
+ ctx.put("package", "package " + javaClassReader.getDomainName() + "." + javaClassReader.getModuleName() + "." + "request;");
+ ctx.put("domain", javaClassReader.getDomainName());
+ ctx.put("module", javaClassReader.getModuleName());
+ ctx.put("importList", javaClassReader.getImportList());
+ ctx.put("annotation", javaClassReader.getAnnotationList());
+ ctx.put("className", javaClassReader.getClassName().replaceAll("Request", ""));
+ ctx.put("body", javaClassReader.getBody());
+ ctx.put("tool", tool);
+ ctx.put("hasList", javaClassReader.isHasList());
+ ctx.put("findOrSearchflag", javaClassReader.getFindOrSearchflag());
+ File file = new File(request.getAbsolutePath() + File.separator + api.getReq().getName());
+
+ freeMarkerManager.outputTemp(file, "Java_api/module/request/request.ftl", ctx);
+ System.out.println("生成文件" + file.getName() + "成功");
+ }
+ //endregion
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+
+ try {
+ //region 生成response
+ JavaClassReader javaClassReader = new JavaClassReader(api.getRsp());
+
+ StringBuffer stringBuffer = new StringBuffer("");
+ stringBuffer.append(sdk.getPath() + File.separator);
+ stringBuffer.append("src" + File.separator);
+ stringBuffer.append("main" + File.separator);
+ stringBuffer.append("java" + File.separator);
+
+ String[] split = javaClassReader.getDomainName().split("\\.");
+
+
+ for (String s1 : split) {
+ stringBuffer.append(s1 + File.separator);
+ }
+
+ stringBuffer.append(javaClassReader.getModuleName());
+
+ File response = new File(stringBuffer.toString() + File.separator + "response");
+ response.mkdirs();
+
+ {
+ HashMap ctx = new HashMap();
+ ctx.put("package", "package " + javaClassReader.getDomainName() + "." + javaClassReader.getModuleName() + "." + "request;");
+ ctx.put("domain", javaClassReader.getDomainName());
+ ctx.put("module", javaClassReader.getModuleName());
+ ctx.put("importList", javaClassReader.getImportList());
+ ctx.put("annotation", javaClassReader.getAnnotationList());
+ ctx.put("className", javaClassReader.getClassName().replaceAll("Response", ""));
+ ctx.put("body", javaClassReader.getBody());
+ ctx.put("tool", tool);
+ ctx.put("hasList", javaClassReader.isHasList());
+ ctx.put("Tclass", javaClassReader.getTclass());
+ File file = new File(response.getAbsolutePath() + File.separator + api.getRsp().getName().replaceAll("Request", "Response"));
+
+ freeMarkerManager.outputTemp(file, "Java_api/module/response/response.ftl", ctx);
+ System.out.println("生成文件" + api.getRsp().getName() + "成功");
+ }
+ //endregion
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ for (String s : api.getDepReq()) {
+ try {
+ File f = new File(req.getAbsolutePath() + File.separator + s + ".java");
+ if (!f.exists()) {
+ System.err.println("文件" + f.getAbsolutePath() + "不存在");
+ continue;
+ }
+ JavaClassReader javaClassReader = new JavaClassReader(f);
+
+ Method method = new Method();
+ method.setStringMethod(api.getMethod());
+ method.setRequest(javaClassReader.getClassName());
+ method.setTarget(Tool.getRequestTarget(javaClassReader.getClassName()));
+ method.setMethod(Tool.getRequestAction(javaClassReader.getClassName()));
+ method.setManager(Tool.getRequestTarget(javaClassReader.getClassName()) + "Manager");
+
+ StringBuffer stringBuffer = new StringBuffer("");
+ stringBuffer.append(sdk.getPath() + File.separator);
+ stringBuffer.append("src" + File.separator);
+ stringBuffer.append("main" + File.separator);
+ stringBuffer.append("java" + File.separator);
+
+ String[] split = javaClassReader.getDomainName().split("\\.");
+
+ for (String s1 : split) {
+ stringBuffer.append(s1 + File.separator);
+ }
+ if (frameWork == null) {
+ frameWork = new File(stringBuffer.toString());
+ frameWork.mkdirs();
+ }
+ if (domain == null) {
+ domain = javaClassReader.getDomainName();
+ }
+ if (module == null) {
+ module = javaClassReader.getModuleName();
+ }
+
+ stringBuffer.append(javaClassReader.getModuleName());
+
+ File request = new File(stringBuffer.toString() + File.separator + "request");
+ request.mkdirs();
+
+ {
+ HashMap ctx = new HashMap();
+ ctx.put("package", "package " + javaClassReader.getDomainName() + "." + javaClassReader.getModuleName() + "." + "request;");
+ ctx.put("domain", javaClassReader.getDomainName());
+ ctx.put("module", javaClassReader.getModuleName());
+ ctx.put("importList", javaClassReader.getImportList());
+ ctx.put("annotation", javaClassReader.getAnnotationList());
+ ctx.put("className", javaClassReader.getClassName().replaceAll("Request", ""));
+ ctx.put("body", javaClassReader.getBody());
+ ctx.put("tool", tool);
+ ctx.put("hasList", javaClassReader.isHasList());
+ ctx.put("findOrSearchflag", javaClassReader.getFindOrSearchflag());
+ File file = new File(request.getAbsolutePath() + File.separator + f.getName());
+
+ freeMarkerManager.outputTemp(file, "Java_api/module/request/request.ftl", ctx);
+ System.out.println("生成文件" + file.getName() + "成功");
+ }
+ //endregion
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ try {
+ File f = new File(rsp.getAbsolutePath() + File.separator + s.replaceAll("Request", "Response.java"));
+ if (!f.exists()){
+ System.err.println("文件" + f.getAbsolutePath() + "不存在");
+ }
+ JavaClassReader javaClassReader = new JavaClassReader(f);
+
+ StringBuffer stringBuffer = new StringBuffer("");
+ stringBuffer.append(sdk.getPath() + File.separator);
+ stringBuffer.append("src" + File.separator);
+ stringBuffer.append("main" + File.separator);
+ stringBuffer.append("java" + File.separator);
+
+ String[] split = javaClassReader.getDomainName().split("\\.");
+
+
+ for (String s1 : split) {
+ stringBuffer.append(s1 + File.separator);
+ }
+
+ stringBuffer.append(javaClassReader.getModuleName());
+
+ File response = new File(stringBuffer.toString() + File.separator + "response");
+ response.mkdirs();
+
+ {
+ HashMap ctx = new HashMap();
+ ctx.put("package", "package " + javaClassReader.getDomainName() + "." + javaClassReader.getModuleName() + "." + "request;");
+ ctx.put("domain", javaClassReader.getDomainName());
+ ctx.put("module", javaClassReader.getModuleName());
+ ctx.put("importList", javaClassReader.getImportList());
+ ctx.put("annotation", javaClassReader.getAnnotationList());
+ ctx.put("className", javaClassReader.getClassName().replaceAll("Response", ""));
+ ctx.put("body", javaClassReader.getBody());
+ ctx.put("tool", tool);
+ ctx.put("hasList", javaClassReader.isHasList());
+ ctx.put("Tclass", javaClassReader.getTclass());
+ File file = new File(response.getAbsolutePath() + File.separator + f.getName());
+
+ freeMarkerManager.outputTemp(file, "Java_api/module/response/response.ftl", ctx);
+ System.out.println("生成文件" + api.getRsp().getName() + "成功");
+ }
+ //endregion
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ for (String s : api.getDepEnt()) {
+
+ try {
+ File f = new File(ent.getAbsolutePath() + File.separator + s + ".java");
+ if (!f.exists()) {
+ System.out.println("文件" + f.getAbsolutePath() + "不存在");
+ continue;
+ }
+ JavaClassReader javaClassReader = new JavaClassReader(f);
+
+ StringBuffer stringBuffer = new StringBuffer("");
+ stringBuffer.append(sdk.getPath() + File.separator);
+ stringBuffer.append("src" + File.separator);
+ stringBuffer.append("main" + File.separator);
+ stringBuffer.append("java" + File.separator);
+
+ String[] split = javaClassReader.getDomainName().split("\\.");
+
+
+ for (String s1 : split) {
+ stringBuffer.append(s1 + File.separator);
+ }
+
+ stringBuffer.append(javaClassReader.getModuleName());
+
+ File entity = new File(stringBuffer.toString() + File.separator + "entity");
+ entity.mkdirs();
+
+ {
+ HashMap ctx = new HashMap();
+ ctx.put("package", "package " + javaClassReader.getDomainName() + "." + javaClassReader.getModuleName() + "." + "request;");
+ ctx.put("domain", javaClassReader.getDomainName());
+ ctx.put("module", javaClassReader.getModuleName());
+ ctx.put("importList", javaClassReader.getImportList());
+ ctx.put("annotation", javaClassReader.getAnnotationList());
+ ctx.put("className", javaClassReader.getClassName().replaceAll("Entity", ""));
+ ctx.put("body", javaClassReader.getBody());
+ ctx.put("tool", tool);
+ File file = new File(entity.getAbsolutePath() + File.separator + f.getName());
+ freeMarkerManager.outputTemp(file, "Java_api/module/entity/entity.ftl", ctx);
+ System.out.println("生成文件" + file.getName() + "成功");
+ }
+ //endregion
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ for (String s : api.getDepEnum()) {
+ try {
+ File f = new File(enums.getAbsolutePath() + File.separator + s + ".java");
+ if (!f.exists()) {
+ System.err.println("文件" + f.getAbsolutePath() + "不存在");
+ continue;
+ }
+ JavaEnumReader javaEnumReader = new JavaEnumReader(f);
+
+ StringBuffer stringBuffer = new StringBuffer("");
+ stringBuffer.append(sdk.getPath() + File.separator);
+ stringBuffer.append("src" + File.separator);
+ stringBuffer.append("main" + File.separator);
+ stringBuffer.append("java" + File.separator);
+
+ String[] split = javaEnumReader.getDomainName().split("\\.");
+
+
+ for (String s1 : split) {
+ stringBuffer.append(s1 + File.separator);
+ }
+
+ stringBuffer.append(javaEnumReader.getModuleName());
+
+ File enums_ = new File(stringBuffer.toString() + File.separator + "enums");
+ enums_.mkdirs();
+
+ {
+ HashMap ctx = new HashMap();
+ ctx.put("package", "package " + javaEnumReader.getDomainName() + "." + javaEnumReader.getModuleName() + "." + "enums;");
+ ctx.put("domain", javaEnumReader.getDomainName());
+ ctx.put("module", javaEnumReader.getModuleName());
+ ctx.put("annotation", javaEnumReader.getAnnotationList());
+ ctx.put("className", javaEnumReader.getClassName());
+ ctx.put("body", javaEnumReader.getBody());
+ ctx.put("tool", tool);
+
+ File file = new File(enums_.getAbsolutePath() + File.separator + f.getName());
+ freeMarkerManager.outputTemp(file, "Java_api/module/enums/type.ftl", ctx);
+ System.out.println("生成文件" + file.getName() + "成功");
+ }
+ //endregion
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+
+// if (req.exists() && rsp.exists() && ent.exists()) {
+// File[] files = req.listFiles();
+// System.out.println("生成模块:Request,Response,Entity");
+// for (File f : files) {
+// try {
+// //region 生成request
+// JavaClassReader javaClassReader = new JavaClassReader(f);
+//
+// Method method = new Method();
+// method.setStringMethod("api." + javaClassReader.getModuleName() + "." + Tool.camelToPoint(javaClassReader.getClassName().replaceAll("Request", "")));
+// method.setRequest(javaClassReader.getClassName());
+// method.setTarget(Tool.getRequestTarget(javaClassReader.getClassName()));
+// method.setMethod(Tool.getRequestAction(javaClassReader.getClassName()));
+// method.setManager(Tool.getRequestTarget(javaClassReader.getClassName()) + "Manager");
+// methodList.add(method);
+// StringBuffer stringBuffer = new StringBuffer("");
+// stringBuffer.append(sdk.getPath() + File.separator);
+// stringBuffer.append("src" + File.separator);
+// stringBuffer.append("main" + File.separator);
+// stringBuffer.append("java" + File.separator);
+//
+// String[] split = javaClassReader.getDomainName().split("\\.");
+//
+//
+// for (String s1 : split) {
+// stringBuffer.append(s1 + File.separator);
+// }
+// if (frameWork == null) {
+// frameWork = new File(stringBuffer.toString());
+// frameWork.mkdirs();
+// }
+// if (domain == null) {
+// domain = javaClassReader.getDomainName();
+// }
+// if (module == null) {
+// module = javaClassReader.getModuleName();
+// }
+//
+// stringBuffer.append(javaClassReader.getModuleName());
+//
+// File request = new File(stringBuffer.toString() + File.separator + "request");
+// request.mkdirs();
+//
+// {
+// HashMap ctx = new HashMap();
+// ctx.put("package", "package " + javaClassReader.getDomainName() + "." + javaClassReader.getModuleName() + "." + "request;");
+// ctx.put("domain", javaClassReader.getDomainName());
+// ctx.put("module", javaClassReader.getModuleName());
+// ctx.put("importList", javaClassReader.getImportList());
+// ctx.put("annotation", javaClassReader.getAnnotationList());
+// ctx.put("className", javaClassReader.getClassName().replaceAll("Request", ""));
+// ctx.put("body", javaClassReader.getBody());
+// ctx.put("tool", tool);
+// ctx.put("hasList", javaClassReader.isHasList());
+// ctx.put("findOrSearchflag", javaClassReader.getFindOrSearchflag());
+// File file = new File(request.getAbsolutePath() + File.separator + f.getName());
+//
+// freeMarkerManager.outputTemp(file, "Java_api/module/request/request.ftl", ctx);
+// System.out.println("生成文件" + file.getName() + "成功");
+// }
+// //endregion
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
+//
+// try {
+// //region 生成response
+// File r = new File(f.getParent().replaceAll("req", "rsp") + File.separator + f.getName().replaceAll("Request", "Response"));
+// JavaClassReader javaClassReader = new JavaClassReader(r);
+//
+// StringBuffer stringBuffer = new StringBuffer("");
+// stringBuffer.append(sdk.getPath() + File.separator);
+// stringBuffer.append("src" + File.separator);
+// stringBuffer.append("main" + File.separator);
+// stringBuffer.append("java" + File.separator);
+//
+// String[] split = javaClassReader.getDomainName().split("\\.");
+//
+//
+// for (String s1 : split) {
+// stringBuffer.append(s1 + File.separator);
+// }
+//
+// stringBuffer.append(javaClassReader.getModuleName());
+//
+// File response = new File(stringBuffer.toString() + File.separator + "response");
+// response.mkdirs();
+//
+// {
+// HashMap ctx = new HashMap();
+// ctx.put("package", "package " + javaClassReader.getDomainName() + "." + javaClassReader.getModuleName() + "." + "request;");
+// ctx.put("domain", javaClassReader.getDomainName());
+// ctx.put("module", javaClassReader.getModuleName());
+// ctx.put("importList", javaClassReader.getImportList());
+// ctx.put("annotation", javaClassReader.getAnnotationList());
+// ctx.put("className", javaClassReader.getClassName().replaceAll("Response", ""));
+// ctx.put("body", javaClassReader.getBody());
+// ctx.put("tool", tool);
+// ctx.put("hasList", javaClassReader.isHasList());
+// ctx.put("Tclass", javaClassReader.getTclass());
+// File file = new File(response.getAbsolutePath() + File.separator + f.getName().replaceAll("Request", "Response"));
+//
+// freeMarkerManager.outputTemp(file, "Java_api/module/response/response.ftl", ctx);
+// System.out.println("生成文件" + r.getName() + "成功");
+// }
+// //endregion
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
+// }
+//
+// for (File f : ent.listFiles()) {
+// try {
+// //region 生成entity
+// JavaClassReader javaClassReader = new JavaClassReader(f);
+// managerList.add(javaClassReader.getClassName() + "Manager");
+//
+// StringBuffer stringBuffer = new StringBuffer("");
+// stringBuffer.append(sdk.getPath() + File.separator);
+// stringBuffer.append("src" + File.separator);
+// stringBuffer.append("main" + File.separator);
+// stringBuffer.append("java" + File.separator);
+//
+// String[] split = javaClassReader.getDomainName().split("\\.");
+//
+//
+// for (String s1 : split) {
+// stringBuffer.append(s1 + File.separator);
+// }
+//
+// stringBuffer.append(javaClassReader.getModuleName());
+//
+// File entity = new File(stringBuffer.toString() + File.separator + "entity");
+// entity.mkdirs();
+//
+// {
+// HashMap ctx = new HashMap();
+// ctx.put("package", "package " + javaClassReader.getDomainName() + "." + javaClassReader.getModuleName() + "." + "request;");
+// ctx.put("domain", javaClassReader.getDomainName());
+// ctx.put("module", javaClassReader.getModuleName());
+// ctx.put("importList", javaClassReader.getImportList());
+// ctx.put("annotation", javaClassReader.getAnnotationList());
+// ctx.put("className", javaClassReader.getClassName().replaceAll("Entity", ""));
+// ctx.put("body", javaClassReader.getBody());
+// ctx.put("tool", tool);
+// File file = new File(entity.getAbsolutePath() + File.separator + f.getName());
+// freeMarkerManager.outputTemp(file, "Java_api/module/entity/entity.ftl", ctx);
+// System.out.println("生成文件" + file.getName() + "成功");
+// }
+// //endregion
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
+// }
+// } else {
+// return false;
+// }
+//
+// if (enums.exists()) {
+// System.out.println("生成模块:Enums");
+// for (File f : enums.listFiles()) {
+// try {
+// //region 生成enums
+// JavaEnumReader javaEnumReader = new JavaEnumReader(f);
+//
+// StringBuffer stringBuffer = new StringBuffer("");
+// stringBuffer.append(sdk.getPath() + File.separator);
+// stringBuffer.append("src" + File.separator);
+// stringBuffer.append("main" + File.separator);
+// stringBuffer.append("java" + File.separator);
+//
+// String[] split = javaEnumReader.getDomainName().split("\\.");
+//
+//
+// for (String s1 : split) {
+// stringBuffer.append(s1 + File.separator);
+// }
+//
+// stringBuffer.append(javaEnumReader.getModuleName());
+//
+// File enums_ = new File(stringBuffer.toString() + File.separator + "enums");
+// enums_.mkdirs();
+//
+// {
+// HashMap ctx = new HashMap();
+// ctx.put("package", "package " + javaEnumReader.getDomainName() + "." + javaEnumReader.getModuleName() + "." + "enums;");
+// ctx.put("domain", javaEnumReader.getDomainName());
+// ctx.put("module", javaEnumReader.getModuleName());
+// ctx.put("annotation", javaEnumReader.getAnnotationList());
+// ctx.put("className", javaEnumReader.getClassName());
+// ctx.put("body", javaEnumReader.getBody());
+// ctx.put("tool", tool);
+//
+// File file = new File(enums_.getAbsolutePath() + File.separator + f.getName());
+// freeMarkerManager.outputTemp(file, "Java_api/module/enums/type.ftl", ctx);
+// System.out.println("生成文件" + file.getName() + "成功");
+// }
+// //endregion
+//
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
+// }
+// }
+
+ {
+ System.out.println("生成模块:ApiController");
+ HashMap ctx = new HashMap();
+ ctx.put("tool", tool);
+ ctx.put("domain", domain);
+ ctx.put("module", module);
+ ctx.put("managerList", managerList);
+ ctx.put("methodList", methodList);
+ File file = new File(frameWork.getAbsolutePath() + File.separator + module + File.separator + "ApiController.java");
+ freeMarkerManager.outputTemp(file, "Java_api/module/controller/ApiController.ftl", ctx);
+ }
+
+ System.out.println("生成基础类");
+ HashMap ctx = new HashMap();
+ ctx.put("domain", domain);
+ ctx.put("module", module);
+ {
+ File file = new File(frameWork.getAbsolutePath() + File.separator + "ApiEntity.java");
+ freeMarkerManager.outputTemp(file, "/Java_api/ApiEntity.ftl", ctx);
+ }
+ {
+ File file = new File(frameWork.getAbsolutePath() + File.separator + "AESUtil.java");
+ freeMarkerManager.outputTemp(file, "/Java_api/AESUtil.ftl", ctx);
+ }
+ {
+ File file = new File(frameWork.getAbsolutePath() + File.separator + "ApiClient.java");
+ freeMarkerManager.outputTemp(file, "/Java_api/ApiClient.ftl", ctx);
+ }
+ {
+ File file = new File(frameWork.getAbsolutePath() + File.separator + "ApiRequest.java");
+ freeMarkerManager.outputTemp(file, "/Java_api/ApiRequest.ftl", ctx);
+ }
+ {
+ File file = new File(frameWork.getAbsolutePath() + File.separator + "ApiFindRequest.java");
+ freeMarkerManager.outputTemp(file, "/Java_api/ApiFindRequest.ftl", ctx);
+ }
+ {
+ File file = new File(frameWork.getAbsolutePath() + File.separator + "ApiSearchRequest.java");
+ freeMarkerManager.outputTemp(file, "/Java_api/ApiSearchRequest.ftl", ctx);
+ }
+ {
+ File file = new File(frameWork.getAbsolutePath() + File.separator + "ApiResponse.java");
+ freeMarkerManager.outputTemp(file, "/Java_api/ApiResponse.ftl", ctx);
+ }
+ {
+ File file = new File(frameWork.getAbsolutePath() + File.separator + "ApiFindResponse.java");
+ freeMarkerManager.outputTemp(file, "/Java_api/ApiFindResponse.ftl", ctx);
+ }
+ {
+ File file = new File(frameWork.getAbsolutePath() + File.separator + "Base64Util.java");
+ freeMarkerManager.outputTemp(file, "/Java_api/Base64Util.ftl", ctx);
+ }
+ {
+ File file = new File(frameWork.getAbsolutePath() + File.separator + "DownloadUtil.java");
+ freeMarkerManager.outputTemp(file, "/Java_api/DownloadUtil.ftl", ctx);
+ }
+ {
+ File file = new File(frameWork.getAbsolutePath() + File.separator + "Error.java");
+ freeMarkerManager.outputTemp(file, "/Java_api/Error.ftl", ctx);
+ }
+ {
+ File file = new File(frameWork.getAbsolutePath() + File.separator + "ErrorType.java");
+ freeMarkerManager.outputTemp(file, "/Java_api/ErrorType.ftl", ctx);
+ }
+ {
+ File file = new File(frameWork.getAbsolutePath() + File.separator + "FileUploadRequest.java");
+ freeMarkerManager.outputTemp(file, "/Java_api/FileUploadRequest.ftl", ctx);
+ }
+ {
+ File file = new File(frameWork.getAbsolutePath() + File.separator + "FileUploadResponse.java");
+ freeMarkerManager.outputTemp(file, "/Java_api/FileUploadResponse.ftl", ctx);
+ }
+ {
+ File file = new File(frameWork.getAbsolutePath() + File.separator + "MapperUtil.java");
+ freeMarkerManager.outputTemp(file, "/Java_api/MapperUtil.ftl", ctx);
+ }
+ {
+ File file = new File(frameWork.getAbsolutePath() + File.separator + "MD5Util.java");
+ freeMarkerManager.outputTemp(file, "/Java_api/MD5Util.ftl", ctx);
+ }
+ {
+ File file = new File(frameWork.getAbsolutePath() + File.separator + "RSAUtil.java");
+ freeMarkerManager.outputTemp(file, "/Java_api/RSAUtil.ftl", ctx);
+ }
+ {
+ File file = new File(frameWork.getAbsolutePath() + File.separator + "ProgressRequestBody.java");
+ freeMarkerManager.outputTemp(file, "/Java_api/ProgressRequestBody.ftl", ctx);
+ }
+
+ {
+ File file = new File(frameWork.getAbsolutePath() + File.separator + "SortType.java");
+ freeMarkerManager.outputTemp(file, "/Java_api/SortType.ftl", ctx);
+ }
+
+ {
+ File file = new File(frameWork.getAbsolutePath() + File.separator + "StringUtils.java");
+ freeMarkerManager.outputTemp(file, "/Java_api/StringUtils.ftl", ctx);
+ }
+ //4.0.1 去掉验证 减少体积
+// {
+// File file = new File(frameWork.getAbsolutePath() + File.separator + "ValidationUtil.java");
+// freeMarkerManager.outputTemp(file, "/Java_api/ValidationUtil.ftl", ctx);
+// }
+ System.out.println("finish");
+ return true;
+ }
+
+
+ public class Method {
+ private String request;
+ private String stringMethod;
+ private String manager;
+ private String method;
+ private String target;
+
+ public String getRequest() {
+ return request;
+ }
+
+ public void setRequest(String request) {
+ this.request = request;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ public String getStringMethod() {
+ return stringMethod;
+ }
+
+ public void setStringMethod(String stringMethod) {
+ this.stringMethod = stringMethod;
+ }
+
+ public String getManager() {
+ return manager;
+ }
+
+ public void setManager(String manager) {
+ this.manager = manager;
+ }
+
+ public String getMethod() {
+ return method;
+ }
+
+ public void setMethod(String method) {
+ this.method = method;
+ }
+ }
+}
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
new file mode 100644
index 00000000..1685a1f8
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java
@@ -0,0 +1,705 @@
+package xyz.wbsite.dbtool.javafx.manger.callable;
+
+import xyz.wbsite.dbtool.javafx.enumeration.DataBase;
+import xyz.wbsite.dbtool.javafx.manger.FreeMarkerManager;
+import xyz.wbsite.dbtool.javafx.manger.ManagerFactory;
+import xyz.wbsite.dbtool.javafx.manger.ProjectManager;
+import xyz.wbsite.dbtool.javafx.manger.XmlManager;
+import xyz.wbsite.dbtool.javafx.po.AbstractDBmapper;
+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.Tool;
+
+import java.io.File;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.concurrent.Callable;
+
+import static xyz.wbsite.dbtool.javafx.tool.Tool.clear;
+
+public class SpringBootCallable implements Callable {
+
+ private String root;
+ private DataBase dataBase;
+ private Project project;
+ private String option;
+
+ private FreeMarkerManager freeMarkerManager;
+
+ public SpringBootCallable(String root, DataBase dataBase, Project project, String option) {
+ this.root = root;
+ this.dataBase = dataBase;
+ this.project = project;
+ this.option = option;
+ this.freeMarkerManager = ManagerFactory.getFreeMarkerManager();
+ }
+
+ private AbstractDBmapper dBmapper;
+
+ public Boolean call() throws Exception {
+ dBmapper = ProjectManager.dBmapper;
+
+ // 创建项目文件夹
+ File projectDir = new File(root + File.separator + project.getProjectName());
+ if (!projectDir.exists()) {
+ projectDir.mkdir();
+ } else {
+ clear(projectDir);
+ }
+
+ // 生成POM
+ generatePom(projectDir, project, dataBase, option);
+
+ // 生成Maven-java及域名目录
+ String basePackage = project.getProjectBasePackage();
+ String[] split = basePackage.split("\\.");
+ StringBuffer stringBuffer = new StringBuffer(projectDir.getAbsolutePath() + File.separator + "src" + File.separator + "main");
+ stringBuffer.append(File.separator).append("java");
+ for (String s : split) {
+ stringBuffer.append(File.separator).append(s);
+ }
+ File src = new File(stringBuffer.toString());
+ if (!src.exists()) {
+ src.mkdirs();
+ }
+
+ // 生成资源目录
+ stringBuffer = new StringBuffer(projectDir.getAbsolutePath() + File.separator + "src" + File.separator + "main");
+ stringBuffer.append(File.separator).append("resources");
+ File resources = new File(stringBuffer.toString());
+ if (!resources.exists()) {
+ resources.mkdirs();
+ }
+
+ // 生成单元测试java目录
+ stringBuffer = new StringBuffer(projectDir.getAbsolutePath());
+ stringBuffer.append(File.separator).append("src").append(File.separator).append("test").append(File.separator).append("java");
+ for (String s : split) {
+ stringBuffer.append(File.separator).append(s);
+ }
+ File testSrc = new File(stringBuffer.toString());
+ if (!testSrc.exists()) {
+ testSrc.mkdirs();
+ }
+
+ // 生成单元测试resources目录
+ stringBuffer = new StringBuffer(projectDir.getAbsolutePath());
+ stringBuffer.append(File.separator).append("src").append(File.separator).append("test").append(File.separator).append("resources");
+ File testResources = new File(stringBuffer.toString());
+ if (!testResources.exists()) {
+ testResources.mkdirs();
+ }
+
+ {//生成java文件
+ //生成Controller
+ System.out.println("生成模块:action");
+ generateController(new File(src.getAbsolutePath(), "action"), project, dataBase, option);
+
+ //module
+ {
+ for (Module module : project.getModules()) {
+ module.setProjectAuthor(project.getProjectAuthor());
+ module.setProjectBasePackage(project.getProjectBasePackage());
+ module.setProjectName(project.getProjectName());
+
+ File modulePath = new File(src.getAbsolutePath(), module.getModuleName());
+ modulePath.mkdirs();
+
+ System.out.println("生成模块:Entity");
+ generateEntity(new File(modulePath.getAbsolutePath(), "ent"), module, dataBase, option);
+ System.out.println("生成模块:Enums");
+ generateEnums(new File(modulePath.getAbsolutePath(), "enums"), module, dataBase, option);
+ System.out.println("生成模块:Mapper");
+ generateMapper(new File(modulePath.getAbsolutePath(), "mpr"), module, dataBase, option);
+ System.out.println("生成模块:Manager");
+ generateManager(new File(modulePath.getAbsolutePath(), "mgr"), module, dataBase, option);
+ System.out.println("生成模块:Requset");
+ generateRequset(new File(modulePath.getAbsolutePath(), "req"), module, dataBase, option);
+ System.out.println("生成模块:Response");
+ generateResponse(new File(modulePath.getAbsolutePath(), "rsp"), module, dataBase, option);
+ }
+ }
+
+ //framework
+ System.out.println("生成模块:framework");
+ generateFramework(new File(src.getAbsolutePath(), "framework"), project, dataBase, option);
+
+ System.out.println("生成模块:Application");
+ generateApplication(new File(src.getAbsolutePath()), project, dataBase, option);
+ }
+
+ {//生成resources文件
+ System.out.println("生成模块:Resources");
+ generateResources(resources, project, dataBase, option);
+ for (Module module : project.getModules()) {
+ generateResourcesSQL(resources, module, dataBase, option);
+ }
+ System.out.println("生成模块:Static");
+ generateStatic(resources, project, dataBase, option);
+ System.out.println("生成模块:Templates");
+ generateTemplates(resources, project, dataBase, option);
+ }
+
+ {//生成test
+ System.out.println("生成模块:Test");
+ generateTest(testSrc, project, dataBase, option);
+ generateTestResources(testResources, project, dataBase, option);
+ }
+ System.out.println("finish");
+ return true;
+ }
+
+
+ /**
+ * 生成POM.xml
+ *
+ * @param root
+ * @param project
+ */
+ public void generatePom(File root, Project project, DataBase dataBase, String option) {
+ HashMap ctx = new HashMap();
+ ctx.put("projectName", project.getProjectName());
+ ctx.put("basePackage", project.getProjectBasePackage());
+ ctx.put("dataBase", dataBase.toString());
+
+ File file = new File(root.getAbsolutePath(), "pom.xml");
+
+ freeMarkerManager.outputTemp(file, option + "/pom.ftl", ctx);
+ }
+
+
+ /**
+ * 生成Controller类
+ *
+ * @param root
+ * @param project
+ */
+ public void generateController(File root, Project project, DataBase dataBase, String option) {
+ if (!root.exists()) {
+ root.mkdirs();
+ } else {
+ clear(root);
+ }
+ HashMap ctx = new HashMap();
+ ctx.put("basePackage", project.getProjectBasePackage());
+ ctx.put("author", project.getProjectAuthor());
+ ctx.put("date", new Date());
+ ctx.put("modules", project.getModules());
+
+ File control = new File(root.getAbsolutePath(), "control");
+ control.mkdirs();
+ freeMarkerManager.outputTemp(new File(control.getAbsolutePath(), "Footer.java"), option + "/java/action/control/Footer.java", ctx);
+ freeMarkerManager.outputTemp(new File(control.getAbsolutePath(), "Header.java"), option + "/java/action/control/Header.java", ctx);
+
+ File screen = new File(root.getAbsolutePath(), "screen");
+ screen.mkdirs();
+ freeMarkerManager.outputTemp(new File(screen.getAbsolutePath(), "Index.java"), option + "/java/action/screen/Index.java", ctx);
+
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), "GlobalController.java"), option + "/java/action/GlobalController.ftl", ctx);
+
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), "AjaxController.java"), option + "/java/action/AjaxController.ftl", ctx);
+ }
+
+ /**
+ * 生成entity
+ *
+ * @param root
+ * @param md
+ */
+ public void generateEntity(File root, Module md, DataBase dataBase, String option) {
+ if (!root.exists()) {
+ root.mkdirs();
+ } else {
+ clear(root);
+ }
+
+ for (Table table : md.getTables()) {
+ HashMap ctx = new HashMap();
+ ctx.put("tool", Tool.class);
+ ctx.put("basePackage", md.getProjectBasePackage());
+ ctx.put("moduleName", md.getModuleName());
+ ctx.put("table", table);
+ ctx.put("author", md.getProjectAuthor());
+ ctx.put("date", new Date());
+
+ File file = new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + ".java");
+
+ freeMarkerManager.outputTemp(file, option + "/java/ent/entity.ftl", ctx);
+ }
+ }
+
+ /**
+ * 生成Enums
+ *
+ * @param root
+ * @param md
+ */
+ public void generateEnums(File root, Module md, DataBase dataBase, String option) {
+ if (!root.exists()) {
+ root.mkdirs();
+ } else {
+ clear(root);
+ }
+
+ HashMap ctx = new HashMap();
+ ctx.put("tool", Tool.class);
+ ctx.put("basePackage", md.getProjectBasePackage());
+ ctx.put("moduleName", md.getModuleName());
+ ctx.put("author", md.getProjectAuthor());
+ ctx.put("date", new Date());
+
+ File file = new File(root.getAbsolutePath(), "Type.java");
+
+ freeMarkerManager.outputTemp(file, option + "/java/enums/Type.ftl", ctx);
+ }
+
+ /**
+ * 生成Mapper
+ *
+ * @param root
+ * @param md
+ */
+ public void generateMapper(File root, Module md, DataBase dataBase, String option) {
+ if (!root.exists()) {
+ root.mkdirs();
+ } else {
+ clear(root);
+ }
+ HashMap ctx = new HashMap();
+
+ ctx.put("tool", Tool.class);
+ ctx.put("module", md);
+ ctx.put("dataBase", dataBase.toString());
+ ctx.put("basePackage", md.getProjectBasePackage());
+ ctx.put("moduleName", md.getModuleName());
+ ctx.put("author", md.getProjectAuthor());
+ ctx.put("date", new Date());
+
+ for (Table table : md.getTables()) {
+ ctx.put("table", table);
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "Mapper" + ".java"), option + "/java/mpr/mapperJava.ftl", ctx);
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "Mapper" + ".xml"), option + "/java/mpr/mapper.ftl", ctx);
+ }
+ }
+
+ public void generateManager(File root, Module md, DataBase dataBase, String option) {
+ if (!root.exists()) {
+ root.mkdirs();
+ } else {
+ clear(root);
+ }
+ HashMap ctx = new HashMap();
+
+ ctx.put("tool", Tool.class);
+ ctx.put("basePackage", md.getProjectBasePackage());
+ ctx.put("moduleName", md.getModuleName());
+ ctx.put("author", md.getProjectAuthor());
+ ctx.put("date", new Date());
+
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), "ApiManager" + ".java"), option + "/java/mgr/ApiManager.java", ctx);
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), "ApiManagerImpl" + ".java"), option + "/java/mgr/ApiManagerImpl.java", ctx);
+
+ for (Table table : md.getTables()) {
+ ctx.put("table", table);
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "Manager" + ".java"), option + "/java/mgr/manager.ftl", ctx);
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "ManagerImpl" + ".java"), option + "/java/mgr/managerImpl.ftl", ctx);
+ }
+
+ }
+
+ /**
+ * 生成Requset
+ *
+ * @param root
+ * @param md
+ */
+ public void generateRequset(File root, Module md, DataBase dataBase, String option) {
+ if (!root.exists()) {
+ root.mkdirs();
+ } else {
+ clear(root);
+ }
+
+ HashMap ctx = new HashMap();
+ ctx.put("tool", Tool.class);
+ ctx.put("basePackage", md.getProjectBasePackage());
+ ctx.put("moduleName", md.getModuleName());
+ ctx.put("author", md.getProjectAuthor());
+ ctx.put("date", new Date());
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), "ApiExampleRequest" + ".java"), option + "/java/req/ApiExampleRequest.java", ctx);
+
+ for (Table table : md.getTables()) {
+ ctx.put("table", table);
+
+ if (table.getCreate() != null && table.getCreate()) {
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "CreateRequest" + ".java"), option + "/java/req/createRequestClass.ftl", ctx);
+ }
+
+ if (table.getDelete() != null && table.getDelete()) {
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "DeleteRequest" + ".java"), option + "/java/req/deleteRequestClass.ftl", ctx);
+ }
+
+ if (table.getUpdate() != null && table.getUpdate()) {
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "UpdateRequest" + ".java"), option + "/java/req/updateRequestClass.ftl", ctx);
+ }
+
+ if (table.getFind() != null && table.getFind()) {
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "FindRequest" + ".java"), option + "/java/req/findRequestClass.ftl", ctx);
+ }
+
+ if (table.getGet() != null && table.getGet()) {
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "GetRequest" + ".java"), option + "/java/req/getRequestClass.ftl", ctx);
+ }
+
+ if (table.getSearch() != null && table.getSearch()) {
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "SearchRequest" + ".java"), option + "/java/req/searchRequestClass.ftl", ctx);
+ }
+ if (table.getGetAll() != null && table.getGetAll()) {
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "GetAllRequest" + ".java"), option + "/java/req/getAllRequestClass.ftl", ctx);
+ }
+ }
+ }
+
+ /**
+ * 生成一般文件
+ *
+ * @param root
+ * @param md
+ */
+ public void generateResponse(File root, Module md, DataBase dataBase, String option) {
+ if (!root.exists()) {
+ root.mkdirs();
+ } else {
+ clear(root);
+ }
+
+ HashMap ctx = new HashMap();
+ ctx.put("tool", Tool.class);
+ ctx.put("basePackage", md.getProjectBasePackage());
+ ctx.put("moduleName", md.getModuleName());
+ ctx.put("author", md.getProjectAuthor());
+ ctx.put("date", new Date());
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), "ApiExampleResponse" + ".java"), option + "/java/rsp/ApiExampleResponse.java", ctx);
+
+ for (Table table : md.getTables()) {
+ ctx.put("table", table);
+
+ if (table.getCreate() != null && table.getCreate()) {
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "CreateResponse" + ".java"), option + "/java/rsp/createResponseClass.ftl", ctx);
+ }
+
+ if (table.getDelete() != null && table.getDelete()) {
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "DeleteResponse" + ".java"), option + "/java/rsp/deleteResponseClass.ftl", ctx);
+ }
+
+ if (table.getUpdate() != null && table.getUpdate()) {
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "UpdateResponse" + ".java"), option + "/java/rsp/updateResponseClass.ftl", ctx);
+ }
+
+ if (table.getFind() != null && table.getFind()) {
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "FindResponse" + ".java"), option + "/java/rsp/findResponseClass.ftl", ctx);
+ }
+
+ if (table.getGet() != null && table.getGet()) {
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "GetResponse" + ".java"), option + "/java/rsp/getResponseClass.ftl", ctx);
+ }
+
+ if (table.getSearch() != null && table.getSearch()) {
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "SearchResponse" + ".java"), option + "/java/rsp/searchResponseClass.ftl", ctx);
+ }
+ if (table.getGetAll() != null && table.getGetAll()) {
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "GetAllResponse" + ".java"), option + "/java/rsp/getAllResponseClass.ftl", ctx);
+ }
+ }
+ }
+
+ /**
+ * 生成framework类
+ *
+ * @param root
+ * @param project
+ */
+ public void generateFramework(File root, Project project, DataBase dataBase, String option) {
+ if (!root.exists()) {
+ root.mkdirs();
+ } else {
+ clear(root);
+ }
+ HashMap ctx = new HashMap();
+ ctx.put("basePackage", project.getProjectBasePackage());
+ ctx.put("moduleName", project.getProjectName());
+ ctx.put("timestamp", new Date().getTime());
+
+ File base = new File(root.getAbsolutePath(), "base");
+ base.mkdirs();
+ File config = new File(root.getAbsolutePath(), "config");
+ config.mkdirs();
+ File freemarker = new File(root.getAbsolutePath(), "freemarker");
+ freemarker.mkdirs();
+ File springmvc = new File(root.getAbsolutePath(), "springmvc");
+ springmvc.mkdirs();
+ File utils = new File(root.getAbsolutePath(), "utils");
+ utils.mkdirs();
+
+ //base
+ freeMarkerManager.outputTemp(new File(base.getAbsolutePath(), "BaseEntity.java"), option + "/java/framework/base/BaseEntity.java", ctx);
+ freeMarkerManager.outputTemp(new File(base.getAbsolutePath(), "BaseFindRequest.java"), option + "/java/framework/base/BaseFindRequest.java", ctx);
+ freeMarkerManager.outputTemp(new File(base.getAbsolutePath(), "BaseFindResponse.java"), option + "/java/framework/base/BaseFindResponse.java", ctx);
+ freeMarkerManager.outputTemp(new File(base.getAbsolutePath(), "BaseGetAllRequest.java"), option + "/java/framework/base/BaseGetAllRequest.java", ctx);
+ freeMarkerManager.outputTemp(new File(base.getAbsolutePath(), "BaseRequest.java"), option + "/java/framework/base/BaseRequest.java", ctx);
+ freeMarkerManager.outputTemp(new File(base.getAbsolutePath(), "BaseResponse.java"), option + "/java/framework/base/BaseResponse.java", ctx);
+ freeMarkerManager.outputTemp(new File(base.getAbsolutePath(), "BaseSearchRequest.java"), option + "/java/framework/base/BaseSearchRequest.java", ctx);
+ freeMarkerManager.outputTemp(new File(base.getAbsolutePath(), "BaseUpdateRequest.java"), option + "/java/framework/base/BaseUpdateRequest.java", ctx);
+ freeMarkerManager.outputTemp(new File(base.getAbsolutePath(), "Control.java"), option + "/java/framework/base/Control.java", ctx);
+ freeMarkerManager.outputTemp(new File(base.getAbsolutePath(), "Error.java"), option + "/java/framework/base/Error.java", ctx);
+ freeMarkerManager.outputTemp(new File(base.getAbsolutePath(), "ErrorType.java"), option + "/java/framework/base/ErrorType.java", ctx);
+ freeMarkerManager.outputTemp(new File(base.getAbsolutePath(), "FileUploadResponse.java"), option + "/java/framework/base/FileUploadResponse.java", ctx);
+ freeMarkerManager.outputTemp(new File(base.getAbsolutePath(), "Screen.java"), option + "/java/framework/base/Screen.java", ctx);
+ freeMarkerManager.outputTemp(new File(base.getAbsolutePath(), "SortType.java"), option + "/java/framework/base/SortType.java", ctx);
+ freeMarkerManager.outputTemp(new File(base.getAbsolutePath(), "Token.java"), option + "/java/framework/base/Token.java", ctx);
+
+ //config
+ freeMarkerManager.outputTemp(new File(config.getAbsolutePath(), "BeanDefinitionRegistryConfig.java"), option + "/java/framework/config/BeanDefinitionRegistryConfig.java", ctx);
+ freeMarkerManager.outputTemp(new File(config.getAbsolutePath(), "SecurityConfig.java"), option + "/java/framework/config/SecurityConfig.java", ctx);
+ freeMarkerManager.outputTemp(new File(config.getAbsolutePath(), "TaskConfig.java"), option + "/java/framework/config/TaskConfig.java", ctx);
+ freeMarkerManager.outputTemp(new File(config.getAbsolutePath(), "ThreadPoolConfig.java"), option + "/java/framework/config/ThreadPoolConfig.java", ctx);
+ freeMarkerManager.outputTemp(new File(config.getAbsolutePath(), "WebMvcConfig.java"), option + "/java/framework/config/WebMvcConfig.java", ctx);
+
+ //freemarker
+ freeMarkerManager.outputTemp(new File(freemarker.getAbsolutePath(), "ViewNameTranslator.java"), option + "/java/framework/freemarker/ViewNameTranslator.java", ctx);
+ freeMarkerManager.outputTemp(new File(freemarker.getAbsolutePath(), "Layout.java"), option + "/java/framework/freemarker/Layout.java", ctx);
+ freeMarkerManager.outputTemp(new File(freemarker.getAbsolutePath(), "Uri.java"), option + "/java/framework/freemarker/Uri.java", ctx);
+
+ //springmvc
+ freeMarkerManager.outputTemp(new File(springmvc.getAbsolutePath(), "GlobalHandlerInterceptor.java"), option + "/java/framework/springmvc/GlobalHandlerInterceptor.java", ctx);
+
+ //uitls
+ freeMarkerManager.outputTemp(new File(utils.getAbsolutePath(), "Base64Util.java"), option + "/java/framework/utils/Base64Util.java", ctx);
+ freeMarkerManager.outputTemp(new File(utils.getAbsolutePath(), "AESUtil.java"), option + "/java/framework/utils/AESUtil.java", ctx);
+ freeMarkerManager.outputTemp(new File(utils.getAbsolutePath(), "CookieUtil.java"), option + "/java/framework/utils/CookieUtil.java", ctx);
+ freeMarkerManager.outputTemp(new File(utils.getAbsolutePath(), "LogUtil.java"), option + "/java/framework/utils/LogUtil.java", ctx);
+ freeMarkerManager.outputTemp(new File(utils.getAbsolutePath(), "MapperUtil.java"), option + "/java/framework/utils/MapperUtil.java", ctx);
+ freeMarkerManager.outputTemp(new File(utils.getAbsolutePath(), "MD5Util.java"), option + "/java/framework/utils/MD5Util.java", ctx);
+ freeMarkerManager.outputTemp(new File(utils.getAbsolutePath(), "ProcessUtil.java"), option + "/java/framework/utils/ProcessUtil.java", ctx);
+ freeMarkerManager.outputTemp(new File(utils.getAbsolutePath(), "RSAUtil.java"), option + "/java/framework/utils/RSAUtil.java", ctx);
+ freeMarkerManager.outputTemp(new File(utils.getAbsolutePath(), "ValidationUtil.java"), option + "/java/framework/utils/ValidationUtil.java", ctx);
+ freeMarkerManager.outputTemp(new File(utils.getAbsolutePath(), "WebUtils.java"), option + "/java/framework/utils/WebUtils.java", ctx);
+ freeMarkerManager.outputTemp(new File(utils.getAbsolutePath(), "LocalData.java"), option + "/java/framework/utils/LocalData.java", ctx);
+ freeMarkerManager.outputTemp(new File(utils.getAbsolutePath(), "IDgenerator.java"), option + "/java/framework/utils/IDgenerator.java", ctx);
+ freeMarkerManager.outputTemp(new File(utils.getAbsolutePath(), "Message.java"), option + "/java/framework/utils/Message.java", ctx);
+ }
+
+ /**
+ * 生成base类
+ *
+ * @param root
+ * @param project
+ */
+ public void generateApplication(File root, Project project, DataBase dataBase, String option) {
+
+ HashMap ctx = new HashMap();
+ ctx.put("basePackage", project.getProjectBasePackage());
+ ctx.put("moduleName", project.getProjectName());
+ ctx.put("timestamp", new Date().getTime());
+
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), "Application.java"), option + "/java/Application.ftl", ctx);
+ }
+
+ /**
+ * 生成properties
+ *
+ * @param root
+ * @param project
+ */
+ public void generateResources(File root, Project project, DataBase dataBase, String option) {
+ HashMap ctx = new HashMap();
+
+ ctx.put("basePackage", project.getProjectBasePackage());
+ ctx.put("tool", Tool.class);
+ ctx.put("dataBase", dataBase.toString());
+ ctx.put("author", project.getProjectAuthor());
+ ctx.put("dBmapper", dBmapper);
+ ctx.put("date", new Date());
+ ctx.put("projectName", project.getProjectName());
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), "start-dev.bat"), option + "/resources/start-dev.bat", ctx);
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), "start-prod.bat"), option + "/resources/start-prod.bat", ctx);
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), "application-dev.properties"), option + "/resources/application-dev.ftl", ctx);
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), "application-prod.properties"), option + "/resources/application-prod.ftl", ctx);
+ Tool.outputResource(option + "/resources/banner.txt", new File(root.getAbsolutePath(), "banner.txt"));
+ Tool.outputResource(option + "/resources/logback-config.xml", new File(root.getAbsolutePath(), "logback-config.xml"));
+
+ File lib = new File(root.getAbsolutePath(), "lib");
+ lib.mkdirs();
+ Tool.outputResource(option + "/resources/lib/ojdbc7-12.1.0.2.jar", new File(lib.getAbsolutePath(), "ojdbc7-12.1.0.2.jar"));
+
+ File dbtool = new File(root.getAbsolutePath(), "dbtool");
+ dbtool.mkdirs();
+ {
+ XmlManager xmlManager = ManagerFactory.getXmlManager();
+ xmlManager.saveAs(dbtool.getAbsolutePath(), project);
+ }
+ }
+
+ /**
+ * 生成properties
+ *
+ * @param root
+ * @param md
+ */
+ public void generateResourcesSQL(File root, Module md, DataBase dataBase, String option) {
+ HashMap ctx = new HashMap();
+
+ ctx.put("basePackage", md.getProjectBasePackage());
+ ctx.put("moduleName", md.getModuleName());
+ ctx.put("tool", Tool.class);
+ ctx.put("dataBase", dataBase.toString());
+ ctx.put("module", md);
+ ctx.put("author", md.getProjectAuthor());
+ ctx.put("dBmapper", dBmapper);
+ ctx.put("date", new Date());
+
+ File tableDir = new File(root.getAbsolutePath(), md.getModuleName() + "_table");
+ tableDir.mkdirs();
+
+ for (Table table : md.getTables()) {
+ ctx.put("table", table);
+ freeMarkerManager.outputTemp(new File(tableDir.getAbsolutePath(), table.getTableName() + ".sql"), option + "/resources/table.ftl", ctx);
+ }
+ freeMarkerManager.outputTemp(new File(tableDir.getAbsolutePath(), "ALL_TABLE.sql"), option + "/resources/tableAll.ftl", ctx);
+ }
+
+ public void generateTestResources(File root, Project project, DataBase dataBase, String option) {
+ HashMap ctx = new HashMap();
+
+ ctx.put("basePackage", project.getProjectBasePackage());
+ ctx.put("moduleName", project.getProjectName());
+ ctx.put("tool", Tool.class);
+ ctx.put("dataBase", dataBase.toString());
+ ctx.put("author", project.getProjectAuthor());
+ ctx.put("dBmapper", dBmapper);
+ ctx.put("date", new Date());
+ freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), "application.properties"), option + "/test/application.properties", ctx);
+ Tool.outputResource(option + "/test/logback-config.xml", new File(root.getAbsolutePath(), "logback-config.xml"));
+ }
+
+ /**
+ * 生成static
+ *
+ * @param root
+ * @param project
+ */
+ public void generateStatic(File root, Project project, DataBase dataBase, String option) {
+
+ HashMap ctx = new HashMap();
+ ctx.put("basePackage", project.getProjectBasePackage());
+ ctx.put("tool", Tool.class);
+ ctx.put("author", project.getProjectAuthor());
+ ctx.put("date", new Date());
+ ctx.put("modules", project.getModules());
+
+ File static_ = new File(root.getAbsolutePath(), "static");
+ boolean mkdirs = static_.mkdirs();
+ File css = new File(static_.getAbsolutePath(), "css");
+ boolean mkdirs1 = css.mkdirs();
+ File js = new File(static_.getAbsolutePath(), "js");
+ boolean mkdirs2 = js.mkdirs();
+ File img = new File(static_.getAbsolutePath(), "img");
+ boolean mkdirs3 = img.mkdirs();
+
+ File dist = new File(static_.getAbsolutePath(), "dist");
+ boolean mkdirs4 = dist.mkdirs();
+
+ {//css文件
+ freeMarkerManager.outputTemp(new File(css.getAbsolutePath(), "base.css"), option + "/resources/static/css/base.css", ctx);
+ }
+
+ {//js文件
+ freeMarkerManager.outputTemp(new File(js.getAbsolutePath(), "ajax.js"), option + "/resources/static/js/ajax.ftl", ctx);
+ }
+ {//img
+ Tool.outputResource(option + "/resources/static/img/favicon.ico", new File(img.getAbsolutePath(), "favicon.ico"));
+ Tool.outputResource(option + "/resources/static/img/logo.png", new File(img.getAbsolutePath(), "logo.png"));
+ }
+
+ {//dist文件
+
+ Tool.outputResource(option + "/resources/static/dist/lib.min.css", new File(dist.getAbsolutePath(), "lib.min.css"));
+ Tool.outputResource(option + "/resources/static/dist/lib.min.js", new File(dist.getAbsolutePath(), "lib.min.js"));
+
+
+ File fonts = new File(dist.getAbsolutePath(), "fonts");
+ fonts.mkdirs();
+
+ Tool.outputResource(option + "/resources/static/dist/fonts/element-icons.woff", new File(fonts.getAbsolutePath(), "element-icons.woff"));
+ Tool.outputResource(option + "/resources/static/dist/fonts/w-e-icon.woff", new File(fonts.getAbsolutePath(), "w-e-icon.woff"));
+
+ }
+ }
+
+ /**
+ * 生成static
+ *
+ * @param root
+ * @param project
+ */
+ public void generateTemplates(File root, Project project, DataBase dataBase, String option) {
+ {//生成
+ File templates = new File(root.getAbsolutePath(), "templates");
+ templates.mkdirs();
+
+ File control = new File(templates.getAbsolutePath(), "control");
+ control.mkdirs();
+ File layout = new File(templates.getAbsolutePath(), "layout");
+ layout.mkdirs();
+ File screen = new File(templates.getAbsolutePath(), "screen");
+ screen.mkdirs();
+ Tool.outputResource(option + "/resources/templates/control/nav.ftl", new File(control.getAbsolutePath(), "nav.ftl"));
+ Tool.outputResource(option + "/resources/templates/control/header.ftl", new File(control.getAbsolutePath(), "header.ftl"));
+ Tool.outputResource(option + "/resources/templates/control/footer.ftl", new File(control.getAbsolutePath(), "footer.ftl"));
+ Tool.outputResource(option + "/resources/templates/control/macro.ftl", new File(control.getAbsolutePath(), "macro.ftl"));
+ Tool.outputResource(option + "/resources/templates/layout/default.ftl", new File(layout.getAbsolutePath(), "default.ftl"));
+ Tool.outputResource(option + "/resources/templates/layout/wap.ftl", new File(layout.getAbsolutePath(), "wap.ftl"));
+ Tool.outputResource(option + "/resources/templates/screen/demo.ftl", new File(screen.getAbsolutePath(), "demo.ftl"));
+ Tool.outputResource(option + "/resources/templates/screen/index.ftl", new File(screen.getAbsolutePath(), "index.ftl"));
+ Tool.outputResource(option + "/resources/templates/403.ftl", new File(templates.getAbsolutePath(), "403.ftl"));
+ Tool.outputResource(option + "/resources/templates/404.ftl", new File(templates.getAbsolutePath(), "404.ftl"));
+ Tool.outputResource(option + "/resources/templates/500.ftl", new File(templates.getAbsolutePath(), "500.ftl"));
+ }
+ }
+
+ public void generateTest(File root, Project project, DataBase dataBase, String option) {
+
+ File config = new File(root.getAbsolutePath(), "config");
+ config.mkdirs();
+
+ {
+ HashMap ctx = new HashMap();
+ ctx.put("tool", Tool.class);
+ ctx.put("basePackage", project.getProjectBasePackage());
+ ctx.put("moduleName", project.getProjectName());
+ ctx.put("author", project.getProjectAuthor());
+ ctx.put("date", new Date());
+ freeMarkerManager.outputTemp(new File(config.getAbsolutePath(), "TestConfig" + ".java"), option + "/test/TestConfig.ftl", ctx);
+ }
+
+ for (Module md : project.getModules()) {
+ File module = new File(root.getAbsolutePath(), md.getModuleName());
+ module.mkdirs();
+
+ for (Table table : md.getTables()) {
+ HashMap ctx = new HashMap();
+
+ ctx.put("tool", Tool.class);
+ ctx.put("basePackage", md.getProjectBasePackage());
+ ctx.put("moduleName", md.getModuleName());
+ ctx.put("table", table);
+ ctx.put("author", md.getProjectAuthor());
+ ctx.put("date", new Date());
+
+ freeMarkerManager.outputTemp(new File(module.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "Test" + ".java"), option + "/test/test.ftl", ctx);
+ }
+ }
+
+ }
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringMVCMybatisCallable.java b/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringMVCMybatisCallable.java
new file mode 100644
index 00000000..4d05f0df
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringMVCMybatisCallable.java
@@ -0,0 +1,666 @@
+//package xyz.wbsite.dbtool.javafx.manger.callable;
+//
+//import xyz.wbsite.dbtool.javafx.enumeration.DataBase;
+//import xyz.wbsite.dbtool.javafx.manger.ProjectManager;
+//import xyz.wbsite.dbtool.javafx.manger.FreeMarkerManager;
+//import xyz.wbsite.dbtool.javafx.manger.ManagerFactory;
+//import xyz.wbsite.dbtool.javafx.manger.XmlManager;
+//import xyz.wbsite.dbtool.javafx.po.AbstractDBmapper;
+//import xyz.wbsite.dbtool.javafx.po.Module;
+//import xyz.wbsite.dbtool.javafx.po.Table;
+//import xyz.wbsite.dbtool.javafx.tool.Tool;
+//
+//import java.io.*;
+//import java.util.ArrayList;
+//import java.util.Date;
+//import java.util.HashMap;
+//import java.util.concurrent.Callable;
+//
+//import static xyz.wbsite.dbtool.javafx.tool.Tool.clear;
+//
+//public class SpringMVCMybatisCallable implements Callable {
+//
+// private String root;
+// private DataBase dataBase;
+// private Module md;
+// private String option;
+// private Tool tool = new Tool();
+//
+// private FreeMarkerManager freeMarkerManager;
+//
+// public SpringMVCMybatisCallable(String root, DataBase dataBase, Module md, String option) {
+// this.root = root;
+// this.dataBase = dataBase;
+// this.md = md;
+// this.option = option;
+// this.freeMarkerManager = ManagerFactory.getFreeMarkerManager();
+// }
+//
+// private AbstractDBmapper dBmapper;
+//
+// public Boolean call() throws Exception {
+//
+// File module = new File(root + File.separator + md.getModuleName());
+// if (!module.exists()) {
+// module.mkdir();
+// } else {
+// clear(module);
+// }
+//
+// dBmapper = ProjectManager.dBmapper;
+//
+// String basePackage = md.getBasePackage();
+//
+// String[] split = basePackage.split("\\.");
+//
+// System.out.println("生成模块:Pom");
+// generatePom(module, md, dataBase, option);
+// StringBuffer stringBuffer = new StringBuffer(module.getAbsolutePath() + File.separator + "src" + File.separator + "main");
+// stringBuffer.append(File.separator).append("java");
+// for (String s : split) {
+// stringBuffer.append(File.separator).append(s);
+// }
+// stringBuffer.append(File.separator).append(md.getModuleName());
+//
+// File src = new File(stringBuffer.toString());
+// if (!src.exists()) {
+// src.mkdirs();
+// }
+//
+// stringBuffer = new StringBuffer(module.getAbsolutePath() + File.separator + "src" + File.separator + "main");
+// stringBuffer.append(File.separator).append("resources");
+// File resources = new File(stringBuffer.toString());
+// if (!resources.exists()) {
+// resources.mkdirs();
+// }
+//
+// stringBuffer = new StringBuffer(module.getAbsolutePath() + File.separator + "src" + File.separator + "main");
+// stringBuffer.append(File.separator).append("webapp");
+// File webapp = new File(stringBuffer.toString());
+// if (!webapp.exists()) {
+// webapp.mkdirs();
+// }
+//
+// stringBuffer = new StringBuffer(module.getAbsolutePath());
+// stringBuffer.append(File.separator).append("src").append(File.separator).append("test").append(File.separator).append("java");
+// for (String s : split) {
+// stringBuffer.append(File.separator).append(s);
+// }
+//
+// File testSrc = new File(stringBuffer.toString());
+// if (!testSrc.exists()) {
+// testSrc.mkdirs();
+// }
+//
+// stringBuffer = new StringBuffer(module.getAbsolutePath());
+// stringBuffer.append(File.separator).append("src").append(File.separator).append("test").append(File.separator).append("resources");
+// File testResources = new File(stringBuffer.toString());
+// if (!testResources.exists()) {
+// testResources.mkdirs();
+// }
+//
+// //生成java文件
+//
+// {
+// //生成Controller
+// System.out.println("生成模块:controller");
+// generateController(new File(src.getParentFile().getAbsolutePath() + File.separator + "controller"), md, dataBase, option);
+//
+// {
+// //module
+// System.out.println("生成模块:Entity");
+// generateEntity(new File(src.getAbsolutePath() + File.separator + "ent"), md, dataBase, option);
+// System.out.println("生成模块:Enums");
+// generateEnums(new File(src.getAbsolutePath() + File.separator + "enums"), md, dataBase, option);
+// System.out.println("生成模块:Filter");
+// generateFilter(new File(src.getAbsolutePath() + File.separator + "filter"), md, dataBase, option);
+// System.out.println("生成模块:Mapper");
+// generateMapper(new File(src.getAbsolutePath() + File.separator + "mpr"), md, dataBase, option);
+// System.out.println("生成模块:Manager");
+// generateManager(new File(src.getAbsolutePath() + File.separator + "mgr"), md, dataBase, option);
+// System.out.println("生成模块:Requset");
+// generateRequset(new File(src.getAbsolutePath() + File.separator + "req"), md, dataBase, option);
+// System.out.println("生成模块:Response");
+// generateResponse(new File(src.getAbsolutePath() + File.separator + "rsp"), md, dataBase, option);
+// System.out.println("生成模块:framework");
+//
+// }
+//
+// //framework
+// System.out.println("生成模块:framework");
+// generateBase(new File(src.getParentFile().getAbsolutePath() + File.separator + "framework"), md, dataBase, option);
+//
+// }
+//
+// {//生成resources文件
+// System.out.println("生成模块:Resources");
+// generateResources(resources, md, dataBase, option);
+// }
+//
+// {//生成webapp
+// System.out.println("生成模块:Webapp");
+// generateWebapp(webapp, md, dataBase, option);
+// }
+//
+// {//生成test 和 testResources
+// System.out.println("生成模块:Test 和 TestResources");
+// generateResources(testResources, md, dataBase, option);
+// generateTest(testSrc, md, dataBase, option);
+// }
+// System.out.println("finish");
+// return true;
+// }
+//
+// /**
+// * 生成POM.xml
+// *
+// * @param root
+// * @param db
+// */
+// public void generatePom(File root, Module db, DataBase dataBase, String option) {
+// try {
+// HashMap ctx = new HashMap();
+// ctx.put("basePackage", md.getBasePackage());
+// ctx.put("moduleName", md.getModuleName());
+//
+// freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + "pom.xml"), option + "/pom.ftl", ctx);
+// } catch (Exception e) {
+//
+// }
+// }
+//
+// /**
+// * 生成entity
+// *
+// * @param root
+// * @param db
+// */
+// public void generateEntity(File root, Module db, DataBase dataBase, String option) {
+// if (!root.exists()) {
+// root.mkdirs();
+// } else {
+// clear(root);
+// }
+//
+// for (Table table : md.getTables()) {
+// try {
+// HashMap ctx = new HashMap();
+// ctx.put("tool", Tool.class);
+// ctx.put("basePackage", md.getBasePackage());
+// ctx.put("moduleName", md.getModuleName());
+// ctx.put("table", table);
+// ctx.put("author", md.getAuthor());
+// ctx.put("date", new Date());
+//
+// freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + Tool.lineToClassName(table.getTableName()) + ".java"), option + "/java/ent/entity.ftl", ctx);
+//
+// } catch (Exception e) {
+//
+// }
+// }
+// }
+//
+// /**
+// * 生成Enums
+// *
+// * @param root
+// * @param db
+// */
+// public void generateEnums(File root, Module db, DataBase dataBase, String option) {
+// if (!root.exists()) {
+// root.mkdirs();
+// } else {
+// clear(root);
+// }
+//
+// try {
+// HashMap ctx = new HashMap();
+// ctx.put("tool", Tool.class);
+// ctx.put("basePackage", md.getBasePackage());
+// ctx.put("moduleName", md.getModuleName());
+// ctx.put("author", md.getAuthor());
+// ctx.put("date", new Date());
+//
+// freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + "Type.java"), option + "/java/enums/Type.ftl", ctx);
+//
+// } catch (Exception e) {
+//
+// }
+//
+// }
+//
+// /**
+// * 生成Filter
+// *
+// * @param root
+// * @param db
+// */
+// public void generateFilter(File root, Module db, DataBase dataBase, String option) {
+// if (!root.exists()) {
+// root.mkdirs();
+// } else {
+// clear(root);
+// }
+//
+// try {
+// HashMap ctx = new HashMap();
+//
+// ctx.put("tool", Tool.class);
+// ctx.put("basePackage", md.getBasePackage());
+// ctx.put("moduleName", md.getModuleName());
+//
+// freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + "Authorizations" + ".java"), option + "/java/filter/Authorizations.ftl", ctx);
+// } catch (Exception e) {
+// e.printStackTrace();
+// }
+//
+// }
+//
+// /**
+// * 生成Mapper
+// *
+// * @param root
+// * @param db
+// */
+// public void generateMapper(File root, Module db, DataBase dataBase, String option) {
+// if (!root.exists()) {
+// root.mkdirs();
+// } else {
+// clear(root);
+// }
+// HashMap ctx = new HashMap();
+//
+// ctx.put("tool", Tool.class);
+// ctx.put("db", db);
+// ctx.put("dataBase", dataBase.toString());
+// ctx.put("basePackage", md.getBasePackage());
+// ctx.put("moduleName", md.getModuleName());
+// ctx.put("author", md.getAuthor());
+// ctx.put("date", new Date());
+//
+// for (Table table : md.getTables()) {
+// try {
+// ctx.put("table", table);
+//
+// freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + Tool.lineToClassName(table.getTableName()) + "Mapper" + ".java"), option + "/java/mpr/mapperJava.ftl", ctx);
+// freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + Tool.lineToClassName(table.getTableName()) + "Mapper" + ".xml"), option + "/java/mpr/mapper.ftl", ctx);
+//
+// } catch (Exception e) {
+//
+// }
+// }
+// }
+//
+// public void generateManager(File root, Module db, DataBase dataBase, String option) {
+// if (!root.exists()) {
+// root.mkdirs();
+// } else {
+// clear(root);
+// }
+// try {
+// HashMap ctx = new HashMap();
+//
+// ctx.put("tool", Tool.class);
+// ctx.put("basePackage", md.getBasePackage());
+// ctx.put("moduleName", md.getModuleName());
+// ctx.put("author", md.getAuthor());
+// ctx.put("date", new Date());
+//
+// for (Table table : md.getTables()) {
+// ctx.put("table", table);
+//
+// freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + Tool.lineToClassName(table.getTableName()) + "Manager" + ".java"), option + "/java/mgr/manager.ftl", ctx);
+// freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + Tool.lineToClassName(table.getTableName()) + "ManagerImpl" + ".java"), option + "/java/mgr/managerImpl.ftl", ctx);
+// }
+//
+// } catch (Exception e) {
+// e.printStackTrace();
+// }
+// }
+//
+// /**
+// * 生成Requset
+// *
+// * @param root
+// * @param db
+// */
+// public void generateRequset(File root, Module db, DataBase dataBase, String option) {
+// if (!root.exists()) {
+// root.mkdirs();
+// } else {
+// clear(root);
+// }
+//
+// try {
+//
+// HashMap ctx = new HashMap();
+// ctx.put("tool", Tool.class);
+// ctx.put("basePackage", md.getBasePackage());
+// ctx.put("moduleName", md.getModuleName());
+// ctx.put("author", md.getAuthor());
+// ctx.put("date", new Date());
+//
+// for (Table table : md.getTables()) {
+// ctx.put("table", table);
+//
+// freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + Tool.lineToClassName(table.getTableName()) + "CreateRequest" + ".java"), option + "/java/req/createRequestClass.ftl", ctx);
+// freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + Tool.lineToClassName(table.getTableName()) + "DeleteRequest" + ".java"), option + "/java/req/deleteRequestClass.ftl", ctx);
+// 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) {
+// e.printStackTrace();
+// }
+// }
+//
+// /**
+// * 生成一般文件
+// *
+// * @param root
+// * @param db
+// */
+// public void generateResponse(File root, Module db, DataBase dataBase, String option) {
+// if (!root.exists()) {
+// root.mkdirs();
+// } else {
+// clear(root);
+// }
+//
+// try {
+// HashMap ctx = new HashMap();
+// ctx.put("tool", Tool.class);
+// ctx.put("basePackage", md.getBasePackage());
+// ctx.put("moduleName", md.getModuleName());
+// ctx.put("author", md.getAuthor());
+// ctx.put("date", new Date());
+//
+// for (Table table : md.getTables()) {
+// ctx.put("table", table);
+// freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + Tool.lineToClassName(table.getTableName()) + "CreateResponse" + ".java"), option + "/java/rsp/createResponseClass.ftl", ctx);
+// freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + Tool.lineToClassName(table.getTableName()) + "DeleteResponse" + ".java"), option + "/java/rsp/deleteResponseClass.ftl", ctx);
+// 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) {
+// e.printStackTrace();
+// }
+// }
+//
+// /**
+// * 生成base类
+// *
+// * @param root
+// * @param db
+// */
+// public void generateBase(File root, Module db, DataBase dataBase, String option) {
+// if (!root.exists()) {
+// root.mkdirs();
+// } else {
+// clear(root);
+// }
+// try {
+// HashMap ctx = new HashMap();
+// ctx.put("basePackage", md.getBasePackage());
+// ctx.put("moduleName", md.getModuleName());
+// ctx.put("timestamp", new Date().getTime());
+//
+// File base = new File(root.getAbsolutePath() + File.separator + "base");
+// base.mkdirs();
+// File freemarker = new File(root.getAbsolutePath() + File.separator + "freemarker");
+// freemarker.mkdirs();
+// File springmvc = new File(root.getAbsolutePath() + File.separator + "springmvc");
+// springmvc.mkdirs();
+// File utils = new File(root.getAbsolutePath() + File.separator + "utils");
+// utils.mkdirs();
+//
+// freeMarkerManager.outputTemp(new File(base.getAbsolutePath() + File.separator + "BaseEntity.java"), option + "/java/framework/base/BaseEntity.java", ctx);
+// freeMarkerManager.outputTemp(new File(base.getAbsolutePath() + File.separator + "BaseFindRequest.java"), option + "/java/framework/base/BaseFindRequest.java", ctx);
+// freeMarkerManager.outputTemp(new File(base.getAbsolutePath() + File.separator + "BaseFindResponse.java"), option + "/java/framework/base/BaseFindResponse.java", ctx);
+// freeMarkerManager.outputTemp(new File(base.getAbsolutePath() + File.separator + "BaseGetAllRequest.java"), option + "/java/framework/base/BaseGetAllRequest.java", ctx);
+// freeMarkerManager.outputTemp(new File(base.getAbsolutePath() + File.separator + "BaseRequest.java"), option + "/java/framework/base/BaseRequest.java", ctx);
+// freeMarkerManager.outputTemp(new File(base.getAbsolutePath() + File.separator + "BaseResponse.java"), option + "/java/framework/base/BaseResponse.java", ctx);
+// freeMarkerManager.outputTemp(new File(base.getAbsolutePath() + File.separator + "BaseSearchRequest.java"), option + "/java/framework/base/BaseSearchRequest.java", ctx);
+// freeMarkerManager.outputTemp(new File(base.getAbsolutePath() + File.separator + "BaseUpdateRequest.java"), option + "/java/framework/base/BaseUpdateRequest.java", ctx);
+// freeMarkerManager.outputTemp(new File(base.getAbsolutePath() + File.separator + "Error.java"), option + "/java/framework/base/Error.java", ctx);
+// freeMarkerManager.outputTemp(new File(base.getAbsolutePath() + File.separator + "ErrorType.java"), option + "/java/framework/base/ErrorType.java", ctx);
+// freeMarkerManager.outputTemp(new File(base.getAbsolutePath() + File.separator + "SortType.java"), option + "/java/framework/base/SortType.java", ctx);
+// freeMarkerManager.outputTemp(new File(base.getAbsolutePath() + File.separator + "Token.java"), option + "/java/framework/base/Token.java", ctx);
+//
+//
+// freeMarkerManager.outputTemp(new File(utils.getAbsolutePath() + File.separator + "AESUtil.java"), option + "/java/framework/utils/AESUtil.java", ctx);
+// freeMarkerManager.outputTemp(new File(utils.getAbsolutePath() + File.separator + "Base64Util.java"), option + "/java/framework/utils/Base64Util.java", ctx);
+// freeMarkerManager.outputTemp(new File(utils.getAbsolutePath() + File.separator + "CookieUtil.java"), option + "/java/framework/utils/CookieUtil.java", ctx);
+// freeMarkerManager.outputTemp(new File(utils.getAbsolutePath() + File.separator + "IDgenerator.java"), option + "/java/framework/utils/IDgenerator.java", ctx);
+// freeMarkerManager.outputTemp(new File(utils.getAbsolutePath() + File.separator + "LocalData.java"), option + "/java/framework/utils/LocalData.java", ctx);
+// freeMarkerManager.outputTemp(new File(utils.getAbsolutePath() + File.separator + "LogUtil.java"), option + "/java/framework/utils/LogUtil.java", ctx);
+// freeMarkerManager.outputTemp(new File(utils.getAbsolutePath() + File.separator + "MapperUtil.java"), option + "/java/framework/utils/MapperUtil.java", ctx);
+// freeMarkerManager.outputTemp(new File(utils.getAbsolutePath() + File.separator + "MD5Util.java"), option + "/java/framework/utils/MD5Util.java", ctx);
+// freeMarkerManager.outputTemp(new File(utils.getAbsolutePath() + File.separator + "Message.java"), option + "/java/framework/utils/Message.java", ctx);
+// freeMarkerManager.outputTemp(new File(utils.getAbsolutePath() + File.separator + "ProcessUtil.java"), option + "/java/framework/utils/ProcessUtil.java", ctx);
+// freeMarkerManager.outputTemp(new File(utils.getAbsolutePath() + File.separator + "RSAUtil.java"), option + "/java/framework/utils/RSAUtil.java", ctx);
+// freeMarkerManager.outputTemp(new File(utils.getAbsolutePath() + File.separator + "ValidationUtil.java"), option + "/java/framework/utils/ValidationUtil.java", ctx);
+// freeMarkerManager.outputTemp(new File(utils.getAbsolutePath() + File.separator + "WebUtils.java"), option + "/java/framework/utils/WebUtils.java", ctx);
+//
+//
+// freeMarkerManager.outputTemp(new File(freemarker.getAbsolutePath() + File.separator + "ViewNameTranslator.java"), option + "/java/framework/freemarker/ViewNameTranslator.java", ctx);
+// freeMarkerManager.outputTemp(new File(freemarker.getAbsolutePath() + File.separator + "Layout.java"), option + "/java/framework/freemarker/Layout.java", ctx);
+// freeMarkerManager.outputTemp(new File(freemarker.getAbsolutePath() + File.separator + "Url.java"), option + "/java/framework/freemarker/Url.java", ctx);
+//
+// freeMarkerManager.outputTemp(new File(springmvc.getAbsolutePath() + File.separator + "GlobalHandlerInterceptor.java"), option + "/java/framework/springmvc/GlobalHandlerInterceptor.java", ctx);
+// freeMarkerManager.outputTemp(new File(springmvc.getAbsolutePath() + File.separator + "GlobalObjectMapper.java"), option + "/java/framework/springmvc/GlobalObjectMapper.java", ctx);
+// } catch (Exception e) {
+// e.printStackTrace();
+// }
+// }
+//
+// /**
+// * 生成Controller类
+// *
+// * @param root
+// * @param db
+// */
+// public void generateController(File root, Module db, DataBase dataBase, String option) {
+// if (!root.exists()) {
+// root.mkdirs();
+// } else {
+// clear(root);
+// }
+// try {
+// HashMap ctx = new HashMap();
+// ctx.put("basePackage", md.getBasePackage());
+// ctx.put("moduleName", md.getModuleName());
+// ctx.put("db", db);
+// ctx.put("table", md.getTables());
+// ctx.put("author", md.getAuthor());
+// ctx.put("date", new Date());
+//
+// freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + "AjaxController.java"), option + "/java/controller/AjaxController.ftl", ctx);
+// freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + "GlobalController.java"), option + "/java/controller/GlobalController.ftl", ctx);
+//
+// } catch (Exception e) {
+// e.printStackTrace();
+// }
+// }
+//
+// /**
+// * 生成Resources spring,spring-mvc,mybatis,jdbc
+// *
+// * @param root
+// * @param db
+// */
+// public void generateResources(File root, Module db, DataBase dataBase, String option) {
+// try {
+// HashMap ctx = new HashMap();
+//
+// ctx.put("basePackage", md.getBasePackage());
+// ctx.put("moduleName", md.getModuleName());
+// if (root.getAbsolutePath().contains("test")) {
+// ctx.put("isTest", true);
+// } else {
+// ctx.put("isTest", false);
+// }
+// freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + "spring.xml"), option + "/resources/spring.ftl", ctx);
+// freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + "spring-mvc.xml"), option + "/resources/spring-mvc.ftl", ctx);
+// freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + "spring-mybatis.xml"), option + "/resources/spring-mybatis.ftl", ctx);
+// freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + "logback.xml"), option + "/resources/logback.ftl", ctx);
+// freeMarkerManager.outputTemp(new File(root.getAbsolutePath() + File.separator + "jdbc.properties"), option + "/resources/jdbc.properties.ftl", ctx);
+//
+// } catch (Exception e) {
+//
+// }
+//
+// if (!root.getAbsolutePath().contains("test")) {
+// File tableDir = new File(root.getAbsolutePath() + File.separator + md.getModuleName() + "_table");
+// tableDir.mkdirs();
+// File dbtool = new File(root.getAbsolutePath() + File.separator + "dbtool");
+// dbtool.mkdirs();
+// {
+// XmlManager xmlManager = ManagerFactory.getXmlManager();
+// ArrayList dbs = new ArrayList<>();
+// dbs.add(db);
+// xmlManager.saveAs(dbtool.getAbsolutePath(), dbs);
+// }
+//
+// try {
+// HashMap ctx = new HashMap();
+// ctx.put("tool", Tool.class);
+// ctx.put("dataBase", dataBase.toString());
+// ctx.put("db", db);
+// ctx.put("author", md.getAuthor());
+// ctx.put("basePackage", md.getBasePackage());
+// ctx.put("moduleName", md.getModuleName());
+// ctx.put("dBmapper", dBmapper);
+// ctx.put("date", new Date());
+//
+// for (Table table : md.getTables()) {
+// ctx.put("table", table);
+// freeMarkerManager.outputTemp(new File(tableDir.getAbsolutePath() + File.separator + table.getTableName() + ".sql"), option + "/resources/table.ftl", ctx);
+// }
+// } catch (Exception e) {
+//
+// }
+// HashMap ctx = new HashMap();
+// ctx.put("tool", Tool.class);
+// ctx.put("dataBase", dataBase.toString());
+// ctx.put("basePackage", md.getBasePackage());
+// ctx.put("moduleName", md.getModuleName());
+// ctx.put("db", db);
+// ctx.put("dBmapper", dBmapper);
+//
+// freeMarkerManager.outputTemp(new File(tableDir.getAbsolutePath() + File.separator + "ALL_TABLE.sql"), option + "/resources/tableAll.ftl", ctx);
+// }
+// }
+//
+// public void generateTest(File root, Module db, DataBase dataBase, String option) {
+// File module = new File(root.getAbsolutePath() + File.separator + md.getModuleName());
+// module.mkdirs();
+//
+// HashMap ctx = new HashMap();
+// ctx.put("tool", tool);
+// ctx.put("basePackage", md.getBasePackage());
+// ctx.put("moduleName", md.getModuleName());
+// ctx.put("date", new Date());
+// for (Table table : md.getTables()) {
+// ctx.put("table", table);
+// freeMarkerManager.outputTemp(new File(module.getAbsolutePath() + File.separator + Tool.lineToClassName(table.getTableName()) + "Test" + ".java"), option + "/test/test.ftl", ctx);
+// }
+// }
+//
+// /**
+// * webapp文件夹及文件生成
+// *
+// * @param root
+// * @param db
+// * @param option
+// */
+// public void generateWebapp(File root, Module db, DataBase dataBase, String option) {
+// HashMap ctx = new HashMap();
+// ctx.put("basePackage", md.getBasePackage());
+// ctx.put("moduleName", md.getModuleName());
+// ctx.put("tool", Tool.class);
+// ctx.put("db", db);
+// ctx.put("author", md.getAuthor());
+// ctx.put("date", new Date());
+// try {
+//
+// File static_ = new File(root.getAbsolutePath() + File.separator + "static");
+// boolean mkdirs = static_.mkdirs();
+// File css = new File(static_.getAbsolutePath() + File.separator + "css");
+// boolean mkdirs1 = css.mkdirs();
+// File dist = new File(static_.getAbsolutePath() + File.separator + "dist");
+// boolean mkdirs5 = dist.mkdirs();
+// File fonts = new File(static_.getAbsolutePath() + File.separator + "fonts");
+// boolean mkdirs6 = fonts.mkdirs();
+// File js = new File(static_.getAbsolutePath() + File.separator + "js");
+// boolean mkdirs2 = js.mkdirs();
+// File img = new File(static_.getAbsolutePath() + File.separator + "img");
+// boolean mkdirs3 = img.mkdirs();
+//
+// File lib = new File(static_.getAbsolutePath() + File.separator + "lib");
+// boolean mkdirs4 = lib.mkdirs();
+//
+// {//css文件
+// freeMarkerManager.outputTemp(new File(css.getAbsolutePath() + File.separator + "base.css"), option + "/webapp/static/css/base.css", ctx);
+// }
+// {//dist文件
+//
+// Tool.outputResource(option + "/webapp/static/dist/lib.min.css", new File(dist.getAbsolutePath() + File.separator + "lib.min.css"));
+// Tool.outputResource(option + "/webapp/static/dist/lib.min.js", new File(dist.getAbsolutePath() + File.separator + "lib.min.js"));
+//
+//
+// Tool.outputResource(option + "/webapp/static/dist/fonts/element-icons.woff", new File(fonts.getAbsolutePath() + File.separator + "element-icons.woff"));
+// Tool.outputResource(option + "/webapp/static/dist/fonts/w-e-icon.woff", new File(fonts.getAbsolutePath() + File.separator + "w-e-icon.woff"));
+//
+// }
+//
+// {//js文件
+// freeMarkerManager.outputTemp(new File(js.getAbsolutePath() + File.separator + "services.js"), option + "/webapp/static/js/services.ftl", ctx);
+// }
+// {//img
+// Tool.outputResource(option + "/webapp/static/img/favicon.ico", new File(img.getAbsolutePath() + File.separator + "favicon.ico"));
+// Tool.outputResource(option + "/webapp/static/img/logo.png", new File(img.getAbsolutePath() + File.separator + "logo.png"));
+// }
+//
+// File WEB_INF_DIR = new File(root.getAbsolutePath() + File.separator + "WEB-INF");
+// WEB_INF_DIR.mkdirs();
+//
+// {//生成WEB-INF下的web.xml等文件
+// freeMarkerManager.outputTemp(new File(WEB_INF_DIR.getAbsolutePath() + File.separator + "web.xml"), option + "/webapp/WEB-INF/web.ftl", ctx);
+// }
+//
+// {//生成WEB-INF下的文件夹
+// File views = new File(root.getAbsolutePath() + File.separator + "WEB-INF" + File.separator + "views");
+// views.mkdirs();
+// Tool.outputResource(option + "/webapp/WEB-INF/views/index.ftl", new File(views.getAbsolutePath() + File.separator + "index.jsp"));
+//
+// File include = new File(views.getAbsolutePath() + File.separator + "include");
+// include.mkdirs();
+// Tool.outputResource(option + "/webapp/WEB-INF/views/include/top.ftl", new File(include.getAbsolutePath() + File.separator + "top.jsp"));
+// Tool.outputResource(option + "/webapp/WEB-INF/views/include/foot.ftl", new File(include.getAbsolutePath() + File.separator + "foot.jsp"));
+//
+// File ftl = new File(root.getAbsolutePath() + File.separator + "WEB-INF" + File.separator + "ftl");
+// ftl.mkdirs();
+// File control = new File(ftl.getAbsolutePath() + File.separator + "control");
+// control.mkdirs();
+// File layout = new File(ftl.getAbsolutePath() + File.separator + "layout");
+// layout.mkdirs();
+// File screen = new File(ftl.getAbsolutePath() + File.separator + "screen");
+// screen.mkdirs();
+// Tool.outputResource(option + "/webapp/WEB-INF/ftl/control/header.ftl", new File(control.getAbsolutePath() + File.separator + "header.ftl"));
+// Tool.outputResource(option + "/webapp/WEB-INF/ftl/control/footer.ftl", new File(control.getAbsolutePath() + File.separator + "footer.ftl"));
+// Tool.outputResource(option + "/webapp/WEB-INF/ftl/control/macro.ftl", new File(control.getAbsolutePath() + File.separator + "macro.ftl"));
+// Tool.outputResource(option + "/webapp/WEB-INF/ftl/layout/default.ftl", new File(layout.getAbsolutePath() + File.separator + "default.ftl"));
+// Tool.outputResource(option + "/webapp/WEB-INF/ftl/screen/index.ftl", new File(screen.getAbsolutePath() + File.separator + "index.ftl"));
+// }
+//
+// } catch (Exception e) {
+// e.printStackTrace();
+// }
+// }
+//}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/po/AbstractDBmapper.java b/src/main/java/xyz/wbsite/dbtool/javafx/po/AbstractDBmapper.java
new file mode 100644
index 00000000..e32323e2
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/po/AbstractDBmapper.java
@@ -0,0 +1,25 @@
+package xyz.wbsite.dbtool.javafx.po;
+
+import xyz.wbsite.dbtool.javafx.enumeration.DataBase;
+import xyz.wbsite.dbtool.javafx.enumeration.FieldType;
+
+public abstract class AbstractDBmapper {
+ DataBase mDataBase = null;
+
+ private AbstractDBmapper(){
+
+ }
+
+ public AbstractDBmapper(DataBase mDataBase) {
+ this.mDataBase = mDataBase;
+ }
+
+ DataBase getDataBase(){
+ return mDataBase;
+ }
+
+ public abstract String getDataBaseType(FieldType type,int lenght);
+ public abstract String getDataBaseType(FieldType type);
+ abstract String getFieldSql(Field field);
+ public abstract FieldType getType(String type, int lenght, int precision, int scale);
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/po/Api.java b/src/main/java/xyz/wbsite/dbtool/javafx/po/Api.java
new file mode 100644
index 00000000..8a233b7b
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/po/Api.java
@@ -0,0 +1,107 @@
+package xyz.wbsite.dbtool.javafx.po;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+public class Api {
+ private boolean check;
+
+ //目标请求对象
+ private String targetRequest;
+ //目标请求响应
+ private String targetResponse;
+ //方法
+ private String method;
+
+ private File req;
+ private File rsp;
+
+ private Set depReq = new HashSet<>();
+ private Set depEnt = new HashSet<>();
+ private Set depEnum = new HashSet<>();
+
+ private String error;
+
+ public String getError() {
+ return error;
+ }
+
+ public void setError(String error) {
+ this.error = error;
+ }
+
+ public boolean isCheck() {
+ return check;
+ }
+
+ public void setCheck(boolean check) {
+ this.check = check;
+ }
+
+ public String getTargetRequest() {
+ return targetRequest;
+ }
+
+ public void setTargetRequest(String targetRequest) {
+ this.targetRequest = targetRequest;
+ }
+
+ public String getTargetResponse() {
+ return targetResponse;
+ }
+
+ public void setTargetResponse(String targetResponse) {
+ this.targetResponse = targetResponse;
+ }
+
+ public String getMethod() {
+ return method;
+ }
+
+ public void setMethod(String method) {
+ this.method = method;
+ }
+
+ public File getReq() {
+ return req;
+ }
+
+ public void setReq(File req) {
+ this.req = req;
+ }
+
+ public File getRsp() {
+ return rsp;
+ }
+
+ public void setRsp(File rsp) {
+ this.rsp = rsp;
+ }
+
+ public Set getDepReq() {
+ return depReq;
+ }
+
+ public void setDepReq(Set depReq) {
+ this.depReq = depReq;
+ }
+
+ public Set getDepEnt() {
+ return depEnt;
+ }
+
+ public void setDepEnt(Set depEnt) {
+ this.depEnt = depEnt;
+ }
+
+ public Set getDepEnum() {
+ return depEnum;
+ }
+
+ public void setDepEnum(Set depEnum) {
+ this.depEnum = depEnum;
+ }
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/po/DTreeItem.java b/src/main/java/xyz/wbsite/dbtool/javafx/po/DTreeItem.java
new file mode 100644
index 00000000..d80175b7
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/po/DTreeItem.java
@@ -0,0 +1,16 @@
+package xyz.wbsite.dbtool.javafx.po;
+
+import javafx.scene.control.TreeItem;
+
+
+public class DTreeItem extends TreeItem {
+ private String id;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/po/Field.java b/src/main/java/xyz/wbsite/dbtool/javafx/po/Field.java
new file mode 100644
index 00000000..07d1b3d6
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/po/Field.java
@@ -0,0 +1,229 @@
+package xyz.wbsite.dbtool.javafx.po;
+
+import org.springframework.util.StringUtils;
+import xyz.wbsite.dbtool.javafx.enumeration.FieldType;
+import xyz.wbsite.dbtool.javafx.tool.Tool;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class Field extends Table {
+
+ public Field() {
+ }
+
+ public Field(String fieldName) {
+ this.fieldName = fieldName;
+ }
+
+ /**
+ * 字段名
+ */
+ private String fieldName;
+
+ /**
+ * 字段类型
+ */
+ private FieldType fieldType = FieldType.String_var50;
+ /**
+ * 字段长度
+ */
+ private int fieldLength = 0;
+
+ /**
+ * 字段注释
+ */
+ private String fieldComment = null;
+
+ /**
+ * 默认值
+ */
+ private String defaultValue = null;
+
+ /**
+ * 是否可为NULL
+ */
+ private Boolean isMust = false;
+
+ /**
+ * 是否是主键
+ */
+ private Boolean isPrimaryKey = false;
+ /**
+ * 是否作为查询条件
+ */
+ private Boolean isQuery = false;
+
+
+ private Boolean isSearch = false;
+
+ private Boolean isSystem = false;
+
+ public String getTestValue() {
+ String value = "";
+ if (fieldType.name().matches("String_\\d+")) {
+ Pattern compile = Pattern.compile("String_(\\d+)");
+ Matcher matcher = compile.matcher(fieldType.name());
+
+ if (matcher.find()) {
+ int len = Integer.parseInt(matcher.group(1));
+
+ if (StringUtils.isEmpty(this.fieldComment)) {
+ StringBuilder sb = new StringBuilder("");
+ for (int i = 0; i < len; i++) {
+ sb.append("A");
+ }
+ value = sb.toString();
+ } else {
+ value = "\"" + this.fieldComment.substring(0, this.fieldComment.length() > this.fieldLength ? this.fieldLength : this.fieldComment.length()) + "\"";
+ }
+
+ }
+ } else if (fieldType.name().matches("String_var\\d+")) {
+ Pattern compile = Pattern.compile("String_var(\\d+)");
+ Matcher matcher = compile.matcher(fieldType.name());
+
+ if (matcher.find()) {
+ int len = Integer.parseInt(matcher.group(1));
+
+ if (StringUtils.isEmpty(this.fieldComment)) {
+ StringBuilder sb = new StringBuilder("");
+ sb.append("\"");
+ sb.append("A");
+ sb.append("\"");
+ value = sb.toString();
+ } else {
+ value = "\"" + this.fieldComment.substring(0, this.fieldComment.length() > this.fieldLength ? this.fieldLength : this.fieldComment.length()) + "\"";
+ }
+
+ }
+ } else if (fieldType.name().equals("String_var")) {
+ int len = fieldLength;
+ if (StringUtils.isEmpty(this.fieldComment)) {
+ StringBuilder sb = new StringBuilder("");
+ sb.append("\"");
+ sb.append("A");
+ sb.append("\"");
+ value = sb.toString();
+ } else {
+ value = "\"" + this.fieldComment.substring(0, this.fieldComment.length() > this.fieldLength ? this.fieldLength : this.fieldComment.length()) + "\"";
+ }
+
+ } else if (fieldType.name().matches("Boolean")) {
+ value = "true";
+ } else if (fieldType.name().matches("Byte|Short|Integer")) {
+ value = "1";
+ } else if (fieldType.name().matches("Bytes")) {
+ value = "null";
+ } else if (fieldType.name().matches("Long")) {
+ value = "1L";
+ } else if (fieldType.name().matches("Float")) {
+ value = "1.0f";
+ } else if (fieldType.name().matches("Double")) {
+ value = "1.0";
+ } else if (fieldType.name().matches("Character")) {
+ value = "'A'";
+ } else if (fieldType.name().matches("Date")) {
+ value = "new Date()";
+ } else if (fieldType.name().matches("Date")) {
+ value = "new Date()";
+ } else if (fieldType.name().matches("BigDecimal")) {
+ value = "new BigDecimal()";
+ } else if (fieldType.name().matches("String_super")) {
+ value = "\"content\"";
+ }
+ return value;
+ }
+
+ public Boolean getIsSearch() {
+ return isSearch;
+ }
+
+ public void setIsSearch(Boolean isSearch) {
+ this.isSearch = isSearch;
+ }
+
+ public Boolean getIsSystem() {
+ return isSystem;
+ }
+
+ public void setIsSystem(Boolean isSystem) {
+ this.isSystem = isSystem;
+ }
+
+ public String getterName() {
+ return "get" + Tool.lineToClassName(this.fieldName);
+ }
+
+ public String setterName() {
+ return "set" + Tool.lineToClassName(this.fieldName);
+ }
+
+ public Boolean getIsQuery() {
+ return isQuery;
+ }
+
+ public void setIsQuery(Boolean isQuery) {
+ this.isQuery = isQuery;
+ }
+
+ public String getFieldName() {
+ return fieldName;
+ }
+
+ public void setFieldName(String fieldName) {
+ this.fieldName = fieldName;
+ }
+
+ public FieldType getFieldType() {
+ return fieldType;
+ }
+
+ public void setFieldType(FieldType fieldType) {
+ this.fieldType = fieldType;
+ }
+
+ public Integer getFieldLength() {
+ return fieldLength;
+ }
+
+ public void setFieldLength(Integer fieldLength) {
+ this.fieldLength = fieldLength;
+ }
+
+ public String getFieldComment() {
+ return fieldComment;
+ }
+
+ public void setFieldComment(String fieldComment) {
+ this.fieldComment = fieldComment != null ? fieldComment : "";
+ }
+
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+
+ public void setDefaultValue(String defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ public Boolean getIsMust() {
+ return isMust;
+ }
+
+ public void setIsMust(Boolean isMust) {
+ this.isMust = isMust;
+ }
+
+ public Boolean getIsPrimaryKey() {
+ return isPrimaryKey;
+ }
+
+ public void setIsPrimaryKey(Boolean isPrimaryKey) {
+ this.isPrimaryKey = isPrimaryKey;
+ }
+
+ public String getFName() {
+ return Tool.lineToFieldName(this.fieldName);
+ }
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/po/Module.java b/src/main/java/xyz/wbsite/dbtool/javafx/po/Module.java
new file mode 100644
index 00000000..3f38c77d
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/po/Module.java
@@ -0,0 +1,111 @@
+package xyz.wbsite.dbtool.javafx.po;
+
+import javafx.scene.control.TreeItem;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Module extends TreeItem {
+ public Module() {
+ }
+
+ public Module(String moduleName) {
+ this.moduleName = moduleName;
+ this.setValue(moduleName);
+ setExpanded(true);
+ }
+
+ /**
+ * 模块注释
+ */
+ private String moduleComment;
+
+ /**
+ * 模块前缀
+ */
+ private String modulePrefix;
+
+ /**
+ * 对象
+ */
+ private List tables = new ArrayList();
+
+ private String moduleName;
+ private boolean hasSysFields;
+ private String projectName;
+ private String projectBasePackage;
+ private String projectAuthor;
+
+ public boolean isHasSysFields() {
+ return hasSysFields;
+ }
+
+ public void setHasSysFields(boolean hasSysFields) {
+ this.hasSysFields = hasSysFields;
+ }
+
+ public String getModuleName() {
+ return moduleName;
+ }
+
+ public void setModuleName(String moduleName) {
+ this.moduleName = moduleName;
+ this.setValue(moduleName);
+ }
+
+ public boolean putTable(Table table) {
+ if (tables == null) {
+ tables = new ArrayList();
+ }
+ tables.add(table);
+ return true;
+ }
+
+ public List getTables() {
+ return tables;
+ }
+
+ public void setTables(List tables) {
+ this.tables = tables;
+ }
+
+ public String getModuleComment() {
+ return moduleComment;
+ }
+
+ public void setModuleComment(String moduleComment) {
+ this.moduleComment = moduleComment;
+ }
+
+ public String getModulePrefix() {
+ return modulePrefix;
+ }
+
+ public void setModulePrefix(String modulePrefix) {
+ this.modulePrefix = modulePrefix!=null?modulePrefix:"";
+ }
+
+ public String getProjectName() {
+ return projectName;
+ }
+
+ public void setProjectName(String projectName) {
+ this.projectName = projectName;
+ }
+
+ public String getProjectBasePackage() {
+ return projectBasePackage;
+ }
+
+ public void setProjectBasePackage(String projectBasePackage) {
+ this.projectBasePackage = projectBasePackage;
+ }
+
+ public String getProjectAuthor() {
+ return projectAuthor;
+ }
+
+ public void setProjectAuthor(String projectAuthor) {
+ this.projectAuthor = projectAuthor;
+ }
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/po/MySqlDBmapper.java b/src/main/java/xyz/wbsite/dbtool/javafx/po/MySqlDBmapper.java
new file mode 100644
index 00000000..d384a7d1
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/po/MySqlDBmapper.java
@@ -0,0 +1,232 @@
+package xyz.wbsite.dbtool.javafx.po;
+
+import xyz.wbsite.dbtool.javafx.enumeration.DataBase;
+import xyz.wbsite.dbtool.javafx.enumeration.FieldType;
+
+public class MySqlDBmapper extends AbstractDBmapper {
+
+ public MySqlDBmapper(DataBase mDataBase) {
+ super(mDataBase);
+ }
+
+ @Override
+ public String getDataBaseType(FieldType type, int lenght) {
+ if (FieldType.Boolean.name().equals(type.name())) {
+ return "BIT";
+ } else if (FieldType.Byte.name().equals(type.name())) {
+ return "TINYINT";
+ } else if (FieldType.Short.name().equals(type.name())) {
+ return "SMALLINT";
+ } else if (FieldType.Integer.name().equals(type.name())) {
+ return "INTEGER";
+ } else if (FieldType.Long.name().equals(type.name())) {
+ return "NUMERIC";
+ } else if (FieldType.Float.name().equals(type.name())) {
+ return "REAL";
+ } else if (FieldType.Double.name().equals(type.name())) {
+ return "FLOAT";
+ } else if (FieldType.Character.name().equals(type.name())) {
+ return "VARCHAR";
+ } else if (FieldType.String_1.name().equals(type.name())) {
+ return "CAHR";
+ } else if (FieldType.String_10.name().equals(type.name())) {
+ return "CAHR";
+ } else if (FieldType.String_var.name().equals(type.name())) {
+ return "VARCHAR";
+ } else if (FieldType.String_var50.name().equals(type.name())) {
+ return "VARCHAR";
+ } else if (FieldType.String_var100.name().equals(type.name())) {
+ return "VARCHAR";
+ } else if (FieldType.String_var255.name().equals(type.name())) {
+ return "VARCHAR";
+ } else if (FieldType.String_var500.name().equals(type.name())) {
+ return "VARCHAR";
+ } else if (FieldType.String_var2500.name().equals(type.name())) {
+ return "VARCHAR";
+ } else if (FieldType.String_var4000.name().equals(type.name())) {
+ return "VARCHAR";
+ } else if (FieldType.Date.name().equals(type.name())) {
+ return "DATE";
+ } else if (FieldType.Bytes.name().equals(type.name())) {
+ return "BLOB";
+ } else {
+ return "";
+ }
+ }
+
+ @Override
+ public String getFieldSql(Field field) {
+ StringBuffer sb = new StringBuffer("");
+ sb.append("`").append(field.getFieldName()).append("` ");
+
+ FieldType type = field.getFieldType();
+
+ if (FieldType.Boolean.name().equals(type.name())) {
+ sb.append("TINYINT(1)");
+ } else if (FieldType.Byte.name().equals(type.name())) {
+ sb.append("TINYINT(3)");
+ } else if (FieldType.Short.name().equals(type.name())) {
+ sb.append("SMALLINT(5)");
+ } else if (FieldType.Integer.name().equals(type.name())) {
+ sb.append("INTEGER(10)");
+ } else if (FieldType.Long.name().equals(type.name())) {
+ sb.append("BIGINT(20)");
+ } else if (FieldType.Float.name().equals(type.name())) {
+ sb.append("FLOAT");
+ } else if (FieldType.Double.name().equals(type.name())) {
+ sb.append("DOUBLE");
+ } else if (FieldType.Date.name().equals(type.name())) {
+ sb.append("DATETIME");
+ } else if (FieldType.Bytes.name().equals(type.name())) {
+ sb.append("BLOB");
+ } else if (FieldType.String_1.name().equals(type.name())) {
+ sb.append("CHAR(1)");
+ } else if (FieldType.String_10.name().equals(type.name())) {
+ sb.append("CHAR(10)");
+ } else if (FieldType.String_var.name().equals(type.name())) {
+ Integer fieldLength = field.getFieldLength();
+ sb.append("VARCHAR(" + fieldLength + ")");
+ } else if (FieldType.String_var50.name().equals(type.name())) {
+ sb.append("VARCHAR(50)");
+ } else if (FieldType.String_var100.name().equals(type.name())) {
+ sb.append("VARCHAR(100)");
+ } else if (FieldType.String_var255.name().equals(type.name())) {
+ sb.append("VARCHAR(250)");
+ } else if (FieldType.String_var500.name().equals(type.name())) {
+ sb.append("VARCHAR(500)");
+ } else if (FieldType.String_var2500.name().equals(type.name())) {
+ sb.append("VARCHAR(2500)");
+ } else if (FieldType.String_var4000.name().equals(type.name())) {
+ sb.append("VARCHAR(4000)");
+ } else if (FieldType.String_super.name().equals(type.name())) {
+ sb.append("TEXT");
+ }
+
+ if (!field.getIsSystem() && field.getIsMust() && (field.getDefaultValue() == null || field.getDefaultValue().toUpperCase().equals("NULL"))) {
+ sb.append(" NOT NULL");
+ } else if (!field.getIsSystem() && field.getIsMust() && field.getDefaultValue() != null && !field.getDefaultValue().toUpperCase().equals("NULL")) {
+ if (field.getFieldType().name().contains("String")) {//默认字符
+ sb.append(" NOT NULL").append(" DEFAULT '" + field.getDefaultValue() + "'");
+ } else {//不是字符就是数字,目前只考虑两张情况
+ sb.append(" NOT NULL").append(" DEFAULT " + field.getDefaultValue() + "");
+ }
+ } else if (field.getIsSystem() && field.getFieldName().equals("ID")) {
+ sb.append(" NOT NULL");
+ } else if (field.getIsSystem() && field.getFieldName().equals("ROW_VERSION")) {
+ sb.append(" NOT NULL").append(" DEFAULT 0");
+ } else if (field.getIsSystem() && field.getFieldName().equals("IS_DELETED")) {
+ sb.append(" NOT NULL").append(" DEFAULT 0");
+ } else if (field.getIsSystem() && field.getFieldName().equals("CREATE_BY")) {
+ sb.append(" NOT NULL");
+ } else if (field.getIsSystem() && field.getFieldName().equals("CREATE_TIME")) {
+ sb.append(" NOT NULL");
+ } else if (field.getIsSystem() && field.getFieldName().equals("LAST_UPDATE_BY")) {
+ sb.append(" DEFAULT NULL");
+ } else if (field.getIsSystem() && field.getFieldName().equals("LAST_UPDATE_TIME")) {
+ sb.append(" DEFAULT NULL");
+ }
+
+ if (field.getFieldComment() != null) {
+ sb.append(" COMMENT '" + field.getFieldComment() + "'");
+ }
+ return sb.toString();
+ }
+
+ @Override
+ DataBase getDataBase() {
+ return super.getDataBase();
+ }
+
+ @Override
+ public String getDataBaseType(FieldType type) {
+ if (FieldType.Boolean.name().equals(type.name())) {
+ return "TINYINT";
+ } else if (FieldType.Byte.name().equals(type.name())) {
+ return "TINYINT";
+ } else if (FieldType.Short.name().equals(type.name())) {
+ return "SMALLINT";
+ } else if (FieldType.Integer.name().equals(type.name())) {
+ return "INTEGER";
+ } else if (FieldType.Long.name().equals(type.name())) {
+ return "NUMERIC";
+ } else if (FieldType.Float.name().equals(type.name())) {
+ return "REAL";
+ } else if (FieldType.Double.name().equals(type.name())) {
+ return "FLOAT";
+ } else if (FieldType.Character.name().equals(type.name())) {
+ return "VARCHAR";
+ } else if (FieldType.String_1.name().equals(type.name())) {
+ return "CHAR";
+ } else if (FieldType.String_10.name().equals(type.name())) {
+ return "CHAR";
+ } else if (FieldType.String_var.name().equals(type.name())) {
+ return "VARCHAR";
+ } else if (FieldType.String_var50.name().equals(type.name())) {
+ return "VARCHAR";
+ } else if (FieldType.String_var100.name().equals(type.name())) {
+ return "VARCHAR";
+ } else if (FieldType.String_var255.name().equals(type.name())) {
+ return "VARCHAR";
+ } else if (FieldType.String_var500.name().equals(type.name())) {
+ return "VARCHAR";
+ } else if (FieldType.String_var2500.name().equals(type.name())) {
+ return "VARCHAR";
+ } else if (FieldType.String_var4000.name().equals(type.name())) {
+ return "VARCHAR";
+ } else if (FieldType.Date.name().equals(type.name())) {
+ return "DATETIME";
+ } else if (FieldType.Bytes.name().equals(type.name())) {
+ return "BLOB";
+ } else {
+ return "";
+ }
+ }
+
+ @Override
+ public FieldType getType(String type, int lenght, int precision, int scale) {
+ if ("bigint".equals(type)) {
+ return FieldType.Long;
+ } else if ("varchar".equals(type) && lenght == 50) {
+ return FieldType.String_var50;
+ } else if ("varchar".equals(type) && lenght == 100) {
+ return FieldType.String_var100;
+ } else if ("varchar".equals(type) && lenght == 255) {
+ return FieldType.String_var255;
+ } else if ("varchar".equals(type) && lenght == 500) {
+ return FieldType.String_var500;
+ } else if ("varchar".equals(type) && lenght == 2500) {
+ return FieldType.String_var2500;
+ } else if ("varchar".equals(type) && lenght == 4000) {
+ return FieldType.String_var4000;
+ } else if ("varchar".equals(type)) {
+ return FieldType.String_var;
+ } else if ("date".equals(type)) {
+ return FieldType.Date;
+ } else if ("datetime".equals(type)) {
+ return FieldType.Date;
+ } else if ("timestamp".equals(type)) {
+ return FieldType.Date;
+ } else if ("char".equals(type) && lenght == 1) {
+ return FieldType.String_1;
+ } else if ("char".equals(type) && lenght == 10) {
+ return FieldType.String_10;
+ } else if ("char".equals(type)) {
+ return FieldType.String_var;
+ } else if ("tinyint".equals(type)) {
+ return FieldType.Integer;
+ } else if ("smallint".equals(type)) {
+ return FieldType.Integer;
+ } else if ("mediumint".equals(type)) {
+ return FieldType.Integer;
+ } else if ("int".equals(type)) {
+ return FieldType.Integer;
+ } else if ("bigint".equals(type)) {
+ return FieldType.Long;
+ } else if ("float".equals(type)) {
+ return FieldType.Float;
+ } else if ("double".equals(type)) {
+ return FieldType.Double;
+ }
+ return FieldType.String_var50;
+ }
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/po/OracleDBmapper.java b/src/main/java/xyz/wbsite/dbtool/javafx/po/OracleDBmapper.java
new file mode 100644
index 00000000..ef62e88b
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/po/OracleDBmapper.java
@@ -0,0 +1,209 @@
+package xyz.wbsite.dbtool.javafx.po;
+
+import xyz.wbsite.dbtool.javafx.enumeration.DataBase;
+import xyz.wbsite.dbtool.javafx.enumeration.FieldType;
+
+public class OracleDBmapper extends AbstractDBmapper {
+
+ @Override
+ public String getFieldSql(Field field) {
+ StringBuffer sb = new StringBuffer("");
+ sb.append("\"").append(field.getFieldName()).append("\" ");
+
+ FieldType type = field.getFieldType();
+
+ if (FieldType.Boolean.name().equals(type.name())) {
+ sb.append("CHAR(1)");
+ } else if (FieldType.Byte.name().equals(type.name())) {
+ sb.append("NUMBER(3)");
+ } else if (FieldType.Short.name().equals(type.name())) {
+ sb.append("NUMBER(5)");
+ } else if (FieldType.Integer.name().equals(type.name())) {
+ sb.append("NUMBER(10)");
+ } else if (FieldType.Long.name().equals(type.name())) {
+ sb.append("NUMBER(19)");
+ } else if (FieldType.Float.name().equals(type.name())) {
+ sb.append("NUMBER");
+ } else if (FieldType.Double.name().equals(type.name())) {
+ sb.append("NUMBER");
+ } else if (FieldType.Date.name().equals(type.name())) {
+ sb.append("DATE");
+ } else if (FieldType.Bytes.name().equals(type.name())) {
+ sb.append("BLOB");
+ } else if (FieldType.String_1.name().equals(type.name())) {
+ sb.append("CHAR(1)");
+ } else if (FieldType.String_10.name().equals(type.name())) {
+ sb.append("CHAR(10)");
+ } else if (FieldType.String_var.name().equals(type.name())) {
+ Integer fieldLength = field.getFieldLength();
+ sb.append("VARCHAR2(" + fieldLength + ")");
+ } else if (FieldType.String_var50.name().equals(type.name())) {
+ sb.append("VARCHAR2(50)");
+ } else if (FieldType.String_var100.name().equals(type.name())) {
+ sb.append("VARCHAR2(100)");
+ } else if (FieldType.String_var255.name().equals(type.name())) {
+ sb.append("VARCHAR2(250)");
+ } else if (FieldType.String_var500.name().equals(type.name())) {
+ sb.append("VARCHAR2(500)");
+ } else if (FieldType.String_var2500.name().equals(type.name())) {
+ sb.append("VARCHAR2(2500)");
+ } else if (FieldType.String_var4000.name().equals(type.name())) {
+ sb.append("VARCHAR2(4000)");
+ } else if (FieldType.String_super.name().equals(type.name())) {
+ //Oracle中LONG最大支持2G字节
+ sb.append("LONG");
+ }
+
+ if (field.getIsMust() && field.getIsSystem()) {
+ sb.append(" NOT NULL");
+ } else {
+ sb.append(" NULL");
+ }
+ return sb.toString();
+ }
+
+ public OracleDBmapper(DataBase mDataBase) {
+ super(mDataBase);
+ }
+
+ @Override
+ public String getDataBaseType(FieldType type, int lenght) {
+ if (FieldType.Boolean.name().equals(type.name())) {
+ return "CHAR";
+ } else if (FieldType.Byte.name().equals(type.name())) {
+ return "NUMBER";
+ } else if (FieldType.Short.name().equals(type.name())) {
+ return "NUMBER";
+ } else if (FieldType.Integer.name().equals(type.name())) {
+ return "NUMBER";
+ } else if (FieldType.Long.name().equals(type.name())) {
+ return "NUMBER";
+ } else if (FieldType.Float.name().equals(type.name())) {
+ return "NUMBER";
+ } else if (FieldType.Double.name().equals(type.name())) {
+ return "NUMBER";
+ } else if (FieldType.Date.name().equals(type.name())) {
+ return "TIMESTAMP";
+ } else if (FieldType.Bytes.name().equals(type.name())) {
+ return "BLOB";
+ } else if (FieldType.String_1.name().equals(type.name())) {
+ return "CHAR";
+ } else if (FieldType.String_10.name().equals(type.name())) {
+ return "CHAR";
+ } else if (FieldType.String_var.name().equals(type.name())) {
+ return "VARCHAR2";
+ } else if (FieldType.String_var50.name().equals(type.name())) {
+ return "VARCHAR2";
+ } else if (FieldType.String_var100.name().equals(type.name())) {
+ return "VARCHAR2";
+ } else if (FieldType.String_var255.name().equals(type.name())) {
+ return "VARCHAR2";
+ } else if (FieldType.String_var500.name().equals(type.name())) {
+ return "VARCHAR2";
+ } else if (FieldType.String_var2500.name().equals(type.name())) {
+ return "VARCHAR2";
+ } else if (FieldType.String_var4000.name().equals(type.name())) {
+ return "VARCHAR2";
+ } else if (FieldType.String_super.name().equals(type.name())) {
+ //Oracle中LONG最大支持2G字节
+ return "LONG";
+ }
+ return "";
+ }
+
+ @Override
+ public String getDataBaseType(FieldType type) {
+ if (FieldType.Boolean.name().equals(type.name())) {
+ return "CHAR";
+ } else if (FieldType.Byte.name().equals(type.name())) {
+ return "NUMBER";
+ } else if (FieldType.Short.name().equals(type.name())) {
+ return "NUMBER";
+ } else if (FieldType.Integer.name().equals(type.name())) {
+ return "NUMBER";
+ } else if (FieldType.Long.name().equals(type.name())) {
+ return "NUMBER";
+ } else if (FieldType.Float.name().equals(type.name())) {
+ return "NUMBER";
+ } else if (FieldType.Double.name().equals(type.name())) {
+ return "NUMBER";
+ } else if (FieldType.Date.name().equals(type.name())) {
+ return "TIMESTAMP";
+ } else if (FieldType.Bytes.name().equals(type.name())) {
+ return "BLOB";
+ } else if (FieldType.String_1.name().equals(type.name())) {
+ return "CHAR";
+ } else if (FieldType.String_10.name().equals(type.name())) {
+ return "CHAR";
+ } else if (FieldType.String_var.name().equals(type.name())) {
+ return "VARCHAR2";
+ } else if (FieldType.String_var50.name().equals(type.name())) {
+ return "VARCHAR2";
+ } else if (FieldType.String_var255.name().equals(type.name())) {
+ return "VARCHAR2";
+ } else if (FieldType.String_var500.name().equals(type.name())) {
+ return "VARCHAR2";
+ } else if (FieldType.String_var2500.name().equals(type.name())) {
+ return "VARCHAR2";
+ } else if (FieldType.String_var4000.name().equals(type.name())) {
+ return "VARCHAR2";
+ } else if (FieldType.String_super.name().equals(type.name())) {
+ //Oracle中LONG最大支持2G字节
+ return "LONG";
+ }
+ return "";
+ }
+
+ public FieldType getType(String type, int lenght, int precision, int scale) {
+ if ("CHAR".equals(type) && lenght == 1) {
+ return FieldType.String_1;
+ } else if ("CHAR".equals(type) && lenght == 10) {
+ return FieldType.String_10;
+ } else if ("CHAR".equals(type)) {
+ return FieldType.String_var;
+ } else if ("VARCHAR".equals(type) && lenght == 50) {
+ return FieldType.String_var50;
+ } else if ("NVARCHAR".equals(type)) {
+ return FieldType.String_var50;
+ } else if ("VARCHAR2".equals(type) && lenght == 50) {
+ return FieldType.String_var50;
+ } else if ("VARCHAR2".equals(type) && lenght == 100) {
+ return FieldType.String_var100;
+ } else if ("VARCHAR2".equals(type) && lenght == 255) {
+ return FieldType.String_var255;
+ } else if ("VARCHAR2".equals(type) && lenght == 500) {
+ return FieldType.String_var500;
+ } else if ("VARCHAR2".equals(type) && lenght == 2500) {
+ return FieldType.String_var2500;
+ } else if ("VARCHAR2".equals(type) && lenght == 4000) {
+ return FieldType.String_var4000;
+ } else if ("VARCHAR2".equals(type)) {
+ return FieldType.String_var;
+ } else if ("NVARCHAR2".equals(type)) {
+ return FieldType.String_var100;
+ } else if ("CLOB".equals(type)) {
+ return FieldType.String_var50;
+ } else if ("NCLOB".equals(type)) {
+ return FieldType.String_var50;
+ } else if ("LONG".equals(type)) {
+ return FieldType.String_super;
+ } else if ("NUMBER".equals(type)) {
+ if (precision > 18 && scale == 0) {
+ return FieldType.Long;
+ } else if (precision >= 10 && precision <= 18 && scale == 0) {
+ return FieldType.Long;
+ } else if (precision >= 1 && precision <= 9 && scale == 0) {
+ return FieldType.Integer;
+ } else if (scale > 0) {
+ return FieldType.Double;
+ } else {
+ return FieldType.Long;
+ }
+ } else if ("DATE".equals(type)) {
+ return FieldType.Date;
+ } else if ("TIMESTAMP".equals(type)) {
+ return FieldType.Date;
+ }
+ return FieldType.String_var50;
+ }
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/po/Project.java b/src/main/java/xyz/wbsite/dbtool/javafx/po/Project.java
new file mode 100644
index 00000000..632dd2bf
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/po/Project.java
@@ -0,0 +1,69 @@
+package xyz.wbsite.dbtool.javafx.po;
+
+import javafx.scene.control.TreeItem;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Project extends TreeItem{
+
+ public Project() {
+ this.projectName = "EXAMPLE-WEB";
+ this.projectBasePackage = "com.example";
+ this.projectAuthor = "author";
+ }
+
+ public Project(String projectName) {
+ this.projectName = projectName;
+ setValue(projectName);
+ setExpanded(true);
+ }
+
+ private String projectName;
+ private String projectBasePackage;
+ private String projectAuthor;
+
+ /**
+ * 对象
+ */
+ private List modules = new ArrayList();
+
+ public boolean putModule(Module module) {
+ modules.add(module);
+ this.getChildren().add(module);
+ return true;
+ }
+
+ public String getProjectName() {
+ return projectName;
+ }
+
+ public void setProjectName(String projectName) {
+ this.projectName = projectName;
+ this.setValue(projectName);
+ }
+
+ public String getProjectBasePackage() {
+ return projectBasePackage;
+ }
+
+ public void setProjectBasePackage(String projectBasePackage) {
+ this.projectBasePackage = projectBasePackage;
+ }
+
+ public String getProjectAuthor() {
+ return projectAuthor;
+ }
+
+ public void setProjectAuthor(String projectAuthor) {
+ this.projectAuthor = projectAuthor;
+ }
+
+ public List getModules() {
+ return modules;
+ }
+
+ public void setModules(List modules) {
+ this.modules = modules;
+ }
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/po/Table.java b/src/main/java/xyz/wbsite/dbtool/javafx/po/Table.java
new file mode 100644
index 00000000..542b1217
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/po/Table.java
@@ -0,0 +1,186 @@
+package xyz.wbsite.dbtool.javafx.po;
+
+import javafx.scene.control.TreeItem;
+import xyz.wbsite.dbtool.javafx.tool.Tool;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Table extends TreeItem {
+ private Module dBhandle;
+
+ public Table() {
+ }
+
+ public Table(String tableName) {
+ this.tableName = tableName;
+ setValue(tableName);
+ setExpanded(true);
+ }
+
+ public Table(String tableName, String tableComment) {
+ this.tableName = tableName;
+ this.tableComment = tableComment;
+ }
+
+ /**
+ * 对象名
+ */
+ private String tableName;
+
+ /**
+ * 对象注释
+ */
+ private String tableComment;
+
+ private Boolean create = true;
+ private Boolean delete = true;
+ private Boolean update = true;
+ private Boolean find = true;
+ private Boolean get = true;
+ private Boolean search = false;
+ private Boolean getAll = false;
+
+ /**
+ * 对象字段
+ */
+ private List fields = new ArrayList();
+
+ public boolean has(String type) {
+ for (Field field : fields) {
+ if (field.getFieldType().name().equals(type) && !field.getIsSystem()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public String getImport() {
+ StringBuilder sb = new StringBuilder("");
+ if (has("Date")) {
+ sb.append("import java.util.Date;\n");
+ }
+ if (has("BigDecimal")) {
+ sb.append("import java.math.BigDecimal;\n");
+ }
+
+ return sb.toString();
+ }
+
+ public boolean putField(Field field) {
+ if (fields == null) {
+ fields = new ArrayList();
+ }
+ fields.add(field);
+ return true;
+ }
+
+ public boolean putFirstField(Field field) {
+ if (fields == null) {
+ fields = new ArrayList();
+ }
+ fields.add(0, field);
+ return true;
+ }
+
+ public String getCName() {
+ return Tool.lineToClassName(this.tableName);
+ }
+
+ public String getFName() {
+ return Tool.lineToFieldName(this.tableName);
+ }
+
+ public String getLName() {
+ return Tool.lineToLPoint(this.tableName);
+ }
+
+ public String getTableName() {
+ return tableName;
+ }
+
+ public void setTableName(String tableName) {
+ this.tableName = tableName;
+ setValue(tableName);
+ }
+
+ public String getTableComment() {
+ return tableComment;
+ }
+
+ public void setTableComment(String tableComment) {
+ this.tableComment = tableComment!=null?tableComment:"";
+ }
+
+ public List getFields() {
+ return fields;
+ }
+
+ public void setFields(List fields) {
+ this.fields = fields;
+ }
+
+ public Module getdBhandle() {
+ return dBhandle;
+ }
+
+ public void setdBhandle(Module dBhandle) {
+ this.dBhandle = dBhandle;
+ }
+
+ public Boolean getCreate() {
+ return create;
+ }
+
+ public void setCreate(Boolean create) {
+ this.create = create;
+ }
+
+ public Boolean getDelete() {
+ return delete;
+ }
+
+ public void setDelete(Boolean delete) {
+ this.delete = delete;
+ }
+
+ public Boolean getUpdate() {
+ return update;
+ }
+
+ public void setUpdate(Boolean update) {
+ this.update = update;
+ }
+
+ public Boolean getFind() {
+ return find;
+ }
+
+ public void setFind(Boolean find) {
+ this.find = find;
+ }
+
+ public Boolean getGet() {
+ return get;
+ }
+
+ public void setGet(Boolean get) {
+ this.get = get;
+ }
+
+ public Boolean getSearch() {
+ return search;
+ }
+
+ public void setSearch(Boolean search) {
+ this.search = search;
+ }
+
+ public Boolean getGetAll() {
+ return getAll;
+ }
+
+ public void setGetAll(Boolean getAll) {
+ this.getAll = getAll;
+ }
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/tool/Dialog.java b/src/main/java/xyz/wbsite/dbtool/javafx/tool/Dialog.java
new file mode 100644
index 00000000..eab32e9e
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/tool/Dialog.java
@@ -0,0 +1,569 @@
+package xyz.wbsite.dbtool.javafx.tool;
+
+import xyz.wbsite.dbtool.Application;
+import xyz.wbsite.dbtool.javafx.ctrl.ConnectInfoController;
+import xyz.wbsite.dbtool.javafx.ctrl.GenerateOptionController;
+import xyz.wbsite.dbtool.javafx.ctrl.SdkInfoController;
+import xyz.wbsite.dbtool.javafx.enumeration.DataBase;
+import xyz.wbsite.dbtool.javafx.listener.GenerateOptionListener;
+import xyz.wbsite.dbtool.javafx.manger.ProjectManager;
+import xyz.wbsite.dbtool.javafx.manger.ManagerFactory;
+import xyz.wbsite.dbtool.javafx.po.Api;
+import xyz.wbsite.dbtool.javafx.po.Module;
+import javafx.application.Platform;
+import javafx.beans.value.ChangeListener;
+import javafx.beans.value.ObservableValue;
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+import javafx.event.ActionEvent;
+import javafx.event.EventHandler;
+import javafx.fxml.FXMLLoader;
+import javafx.geometry.Insets;
+import javafx.geometry.Pos;
+import javafx.scene.Parent;
+import javafx.scene.Scene;
+import javafx.scene.control.*;
+import javafx.scene.layout.VBox;
+import javafx.stage.DirectoryChooser;
+import javafx.stage.Modality;
+import javafx.stage.Stage;
+import javafx.stage.WindowEvent;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+public class Dialog {
+
+ private static Stage popup;
+
+ public static void showTimedDialog(final long time, String message) {
+ popup = new Stage();
+ popup.setAlwaysOnTop(true);
+ popup.initModality(Modality.APPLICATION_MODAL);
+ final Button closeBtn = new Button("知道了");
+ closeBtn.setOnAction(new EventHandler() {
+ @Override
+ public void handle(ActionEvent event) {
+ popup.close();
+ }
+ });
+
+ VBox root = new VBox();
+ root.setPadding(new Insets(20));
+ root.setAlignment(Pos.BASELINE_CENTER);
+ root.setSpacing(20);
+ root.getChildren().addAll(new Label(message), closeBtn);
+ Scene scene = new Scene(root);
+ popup.setScene(scene);
+ popup.setTitle("提示信息");
+ popup.show();
+
+ Thread thread = new Thread() {
+ @Override
+ public void run() {
+ try {
+ Thread.sleep(time);
+ if (popup.isShowing()) {
+ Platform.runLater(new Runnable() {
+ @Override
+ public void run() {
+ popup.close();
+ }
+ });
+ }
+ } catch (Exception exp) {
+ exp.printStackTrace();
+ }
+ }
+ };
+ thread.setDaemon(true);
+ thread.start();
+ }
+
+ public static void showConfirmDialog(String message) {
+ popup = new Stage();
+ popup.setAlwaysOnTop(true);
+ popup.initModality(Modality.APPLICATION_MODAL);
+ final Button closeBtn = new Button("确认");
+ closeBtn.setOnAction(new EventHandler() {
+ @Override
+ public void handle(ActionEvent event) {
+ popup.close();
+ }
+ });
+
+ VBox root = new VBox();
+ root.setPadding(new Insets(20));
+ root.setAlignment(Pos.BASELINE_CENTER);
+ root.setSpacing(20);
+ Label label = new Label(message);
+ root.getChildren().addAll(label, closeBtn);
+ Scene scene = new Scene(root);
+ popup.setScene(scene);
+ popup.setTitle("提示信息");
+ popup.show();
+ }
+
+ public static void showError(String message) {
+ Platform.runLater(new Runnable() {
+ public void run() {
+ Alert alert = new Alert(Alert.AlertType.ERROR);
+ alert.setTitle("错误");
+ alert.setHeaderText("");
+ alert.setContentText(message);
+ alert.showAndWait();
+ }
+ });
+ }
+
+ public static void showSuccess(String message) {
+ Platform.runLater(new Runnable() {
+ public void run() {
+ Alert alert = new Alert(Alert.AlertType.INFORMATION);
+ alert.setTitle("消息");
+ alert.setHeaderText("");
+ alert.setContentText(message);
+ alert.showAndWait();
+ }
+ });
+ }
+
+ public static void showProgress(String message) {
+ if (popup != null) {
+ popup.close();
+ }
+ popup = new Stage();
+ popup.setAlwaysOnTop(true);
+ popup.initModality(Modality.APPLICATION_MODAL);
+
+ ProgressIndicator indicator = new ProgressIndicator();
+ indicator.setPrefSize(30, 30);
+
+ VBox root = new VBox();
+ root.setPadding(new Insets(50, 80, 50, 80));
+ root.setAlignment(Pos.BASELINE_CENTER);
+ root.setSpacing(20);
+
+ Label label = new Label(message);
+ root.getChildren().addAll(indicator, label);
+ Scene scene = new Scene(root);
+
+ popup.setOnCloseRequest(new EventHandler() {
+ @Override
+ public void handle(WindowEvent event) {
+ event.consume();
+ }
+ });
+ popup.setScene(scene);
+ popup.setTitle("提示");
+ popup.show();
+ }
+
+ public static void stopPopup() {
+ if (popup != null) {
+ Platform.runLater(new Runnable() {
+ @Override
+ public void run() {
+ popup.close();
+ }
+ });
+ }
+ }
+
+ public static void showGenerateOption(GenerateOptionListener listener) {
+ FXMLLoader dbdetailloader = new FXMLLoader(Application.class.getResource("../../../fxml/generateOption.fxml"));
+ try {
+ dbdetailloader.load();
+ } catch (IOException e) {
+ return;
+ }
+ Parent root = dbdetailloader.getRoot();
+ GenerateOptionController controller = dbdetailloader.getController();
+ controller.setListener(listener);
+ controller.getCancel().setOnAction(new EventHandler() {
+ @Override
+ public void handle(ActionEvent event) {
+ stopPopup();
+ }
+ });
+ controller.getOk().setOnAction(new EventHandler() {
+ @Override
+ public void handle(ActionEvent event) {
+ listener.onGenerate(controller.getType(), DataBase.valueOf(controller.getDataBase().toUpperCase()));
+ }
+ });
+
+ popup = new Stage();
+ popup.setAlwaysOnTop(true);
+ popup.initModality(Modality.APPLICATION_MODAL);
+
+ Scene scene = new Scene(root);
+
+ popup.setOnCloseRequest(new EventHandler() {
+ @Override
+ public void handle(WindowEvent event) {
+ stopPopup();
+ }
+ });
+ popup.setScene(scene);
+ popup.setTitle("配置");
+ popup.show();
+ }
+
+ public static void showDBConnectInput() {
+ Stage stage = new Stage();
+ stage.setAlwaysOnTop(true);
+ stage.initModality(Modality.APPLICATION_MODAL);
+
+ FXMLLoader dbdetailloader = new FXMLLoader(Application.class.getResource("../../../fxml/connectInfo.fxml"));
+ try {
+ dbdetailloader.load();
+ Parent root = dbdetailloader.getRoot();
+ Scene scene = new Scene(root);
+ stage.setScene(scene);
+ stage.setTitle("连接信息");
+
+ ConnectInfoController controller = dbdetailloader.getController();
+
+ ChoiceBox databaseType = controller.getDatabaseType();
+ ObservableList data = FXCollections.observableArrayList();
+ data.add("Orcale");
+ data.add("Mysql");
+ databaseType.setItems(data);
+ databaseType.setValue("Orcale");
+ databaseType.setOnAction(new EventHandler() {
+ @Override
+ public void handle(ActionEvent event) {
+ String value = (String) databaseType.getValue();
+
+ if ("Orcale".equals(value)) {
+ controller.getDriver().setText("oracle.jdbc.OracleDriver");
+ controller.getUrl().setText("jdbc:oracle:thin:@127.0.0.1:1521:orcl");
+ } else if ("Mysql".equals(value)) {
+ controller.getDriver().setText("com.mysql.jdbc.Driver");
+ controller.getUrl().setText("jdbc:mysql://127.0.0.1:3306/tableName");
+ }
+ }
+ });
+
+ TextField driver = controller.getDriver();
+ driver.setText(Info.orcle.driver);
+ TextField url = controller.getUrl();
+ url.setText(Info.orcle.url);
+
+ Button test = controller.getTest();
+ test.setOnAction(new EventHandler() {
+ @Override
+ public void handle(ActionEvent event) {
+ String type = (String) controller.getDatabaseType().getValue();
+ String driver = controller.getDriver().getText();
+ String url = controller.getUrl().getText();
+ String userName = controller.getUserName().getText();
+ String password = controller.getPassword().getText();
+
+ Map map = new HashMap();
+ map.put("type", type);
+ map.put("url", url);
+ map.put("username", userName);
+ map.put("password", password);
+ map.put("driverClassName", driver);
+ boolean b = ProjectManager.testConnect(map);
+ if (b) {
+ Dialog.showConfirmDialog("连接成功!");
+ } else {
+ Dialog.showConfirmDialog("连接失败!");
+ }
+ }
+ });
+ Button load = controller.getLoad();
+ load.setOnAction(new EventHandler() {
+ @Override
+ public void handle(ActionEvent event) {
+ String type = (String) controller.getDatabaseType().getValue();
+ String driver = controller.getDriver().getText();
+ String url = controller.getUrl().getText();
+ String userName = controller.getUserName().getText();
+ String password = controller.getPassword().getText();
+
+ if (driver == null || driver.equals("")) {
+ Dialog.showConfirmDialog("驱动名称不能为空!");
+ return;
+ } else if (url == null || url.equals("")) {
+ Dialog.showConfirmDialog("连接不能为空!");
+ return;
+ } else if (userName == null || userName.equals("")) {
+ Dialog.showConfirmDialog("用户名不能为空!");
+ return;
+ } else if (password == null || password.equals("")) {
+ Dialog.showConfirmDialog("密码不能为空!");
+ return;
+ }
+
+ for (Module db : ManagerFactory.getdBManager().getMds()) {
+ if (db.getModuleName().equals(userName)) {
+ Dialog.showConfirmDialog("已经存的模块!");
+ return;
+ }
+ }
+
+ Map map = new HashMap();
+ map.put("type", type);
+ map.put("url", url);
+ map.put("username", userName);
+ map.put("password", password);
+ map.put("driverClassName", driver);
+
+ Dialog.showProgress("加载中,请稍等...");
+ new Thread() {
+ @Override
+ public void run() {
+ if (popup.isShowing() && ProjectManager.loadMD(map)) {
+ Platform.runLater(new Runnable() {
+ @Override
+ public void run() {
+ Dialog.stopPopup();
+ stage.close();
+ }
+ });
+ }
+ }
+ }.start();
+ }
+ });
+ Button cancel = controller.getCancel();
+ cancel.setOnAction(new EventHandler() {
+ @Override
+ public void handle(ActionEvent event) {
+ stage.close();
+ }
+ });
+
+ stage.show();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void showApi() {
+ Stage stage = new Stage();
+ stage.initModality(Modality.APPLICATION_MODAL);
+
+ FXMLLoader dbdetailloader = new FXMLLoader(Application.class.getResource("../../../fxml/api.fxml"));
+ try {
+ dbdetailloader.load();
+ Parent root = dbdetailloader.getRoot();
+ Scene scene = new Scene(root);
+
+ stage.setScene(scene);
+ stage.setTitle("API生成");
+
+ SdkInfoController controller = dbdetailloader.getController();
+ TextField modulePath = controller.getModulePath();
+ TextField sdkPath = controller.getSdkPath();
+ TableView apis = controller.getApis();
+
+ controller.getSelectModulePath().setOnAction(new EventHandler() {
+ @Override
+ public void handle(ActionEvent event) {
+ DirectoryChooser directoryChooser = new DirectoryChooser();
+ Stage stage = new Stage();
+ stage.setAlwaysOnTop(true);
+ File file = directoryChooser.showDialog(stage);
+
+ if (file == null) {
+ return;
+ }
+ modulePath.setText(file.getAbsolutePath());
+
+
+ File api = new File(sdkPath.getText());
+ sdkPath.setText(new File(api.getParentFile().getAbsolutePath(),file.getName()+"-api").getAbsolutePath());
+
+
+ System.out.println(file.getAbsolutePath());
+ }
+ });
+
+ controller.getSelectSdkPath().setOnAction(new EventHandler() {
+ @Override
+ public void handle(ActionEvent event) {
+ DirectoryChooser directoryChooser = new DirectoryChooser();
+ Stage stage = new Stage();
+ File file = directoryChooser.showDialog(stage);
+
+ if (file == null) {
+ return;
+ }
+ String text = modulePath.getText();
+ File moduleFile = new File(text);
+
+ sdkPath.setText(new File(file.getAbsolutePath(),moduleFile.getName()+"-api").getAbsolutePath());
+ System.out.println(file.getAbsolutePath());
+ }
+ });
+
+ controller.getAll().setOnAction(new EventHandler() {
+ @Override
+ public void handle(ActionEvent event) {
+ check(controller, controller.getAll().isSelected(), "");
+ }
+ });
+ controller.getApi().setOnAction(new EventHandler() {
+ @Override
+ public void handle(ActionEvent event) {
+ check(controller, controller.getApi().isSelected(), ".api.");
+ }
+ });
+ controller.getCreate().setOnAction(new EventHandler() {
+ @Override
+ public void handle(ActionEvent event) {
+ check(controller, controller.getCreate().isSelected(), ".create");
+ }
+ });
+ controller.getDelete().setOnAction(new EventHandler() {
+ @Override
+ public void handle(ActionEvent event) {
+ check(controller, controller.getDelete().isSelected(), ".delete");
+ }
+ });
+ controller.getUpdate().setOnAction(new EventHandler() {
+ @Override
+ public void handle(ActionEvent event) {
+ check(controller, controller.getUpdate().isSelected(), ".update");
+ }
+ });
+ controller.getFind().setOnAction(new EventHandler() {
+ @Override
+ public void handle(ActionEvent event) {
+ check(controller, controller.getFind().isSelected(), ".find");
+ }
+ });
+ controller.getSearch().setOnAction(new EventHandler() {
+ @Override
+ public void handle(ActionEvent event) {
+ check(controller, controller.getSearch().isSelected(), ".search");
+ }
+ });
+ controller.getGet().setOnAction(new EventHandler() {
+ @Override
+ public void handle(ActionEvent event) {
+ check(controller, controller.getGet().isSelected(), ".get");
+ }
+ });
+ controller.getGetAll().setOnAction(new EventHandler() {
+ @Override
+ public void handle(ActionEvent event) {
+ check(controller, controller.getGetAll().isSelected(), ".get.all");
+ }
+ });
+
+ sdkPath.requestFocus();
+ modulePath.textProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue extends String> observable, String oldValue, String newValue) {
+ controller.load();
+ }
+ });
+
+ ProjectManager dBmanger = ManagerFactory.getdBManager();
+ String path = dBmanger.getPath();
+
+ File file = new File(path);
+ File[] files = file.listFiles();
+ s:
+ for (File f : files) {
+ if (!f.getName().contains(".")) {
+ File modul = findModul(f);
+ if (modul == null) {
+ modulePath.setText("");
+ sdkPath.setText("");
+ } else {
+ modulePath.setText(modul.getAbsolutePath());
+ sdkPath.setText(new File(f.getParentFile().getAbsolutePath(),modul.getName() + "-api").getAbsolutePath());
+ break s;
+ }
+
+ }
+ }
+
+ Button start = controller.getStart();
+ start.setOnAction(new EventHandler() {
+ @Override
+ public void handle(ActionEvent event) {
+ String module = controller.getModulePath().getText();
+ String sdk = controller.getSdkPath().getText();
+
+ if (new File(module).exists()) {
+ Dialog.showProgress("生成中...");
+ dBmanger.generateSDK(new File(module), new File(sdk), controller.getData());
+ Dialog.stopPopup();
+ Platform.runLater(new Runnable() {
+ @Override
+ public void run() {
+ stage.close();
+ }
+ });
+ } else {
+ Dialog.showConfirmDialog("项目不存在!");
+ }
+ }
+ });
+
+ Button cancel = controller.getCancel();
+ cancel.setOnAction(new EventHandler() {
+ @Override
+ public void handle(ActionEvent event) {
+ stage.close();
+ }
+ });
+
+ stage.show();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static void check(SdkInfoController controller, boolean check, String key) {
+ for (Api api : controller.getData()) {
+ if (api.getMethod().endsWith(key) || (key.equals(".api.") && api.getMethod().contains(".api."))) {
+ api.setCheck(check);
+ }
+ }
+ controller.initData();
+ }
+
+ private static boolean hasChild(File file, String child) {
+ if (file == null || child == null || "".equals(child) || file.listFiles() == null) {
+ return false;
+ }
+
+ for (File f : file.listFiles()) {
+ if (f.getName().equals(child)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ private static File findModul(File file) {
+ if (file == null) {
+ return null;
+ } else if (hasChild(file, "ent") && hasChild(file, "req") && hasChild(file, "rsp")) {
+ return file;
+ }
+
+ if (file.listFiles() != null) {
+ for (File f : file.listFiles()) {
+ File modul = findModul(f);
+ if (modul != null) {
+ return modul;
+ }
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/tool/Info.java b/src/main/java/xyz/wbsite/dbtool/javafx/tool/Info.java
new file mode 100644
index 00000000..27b6a880
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/tool/Info.java
@@ -0,0 +1,24 @@
+package xyz.wbsite.dbtool.javafx.tool;
+
+public class Info {
+ static DBInfo orcle = new DBInfo();
+ static DBInfo mysql = new DBInfo();
+
+ static {
+ orcle.url = "jdbc:oracle:thin:@127.0.0.1:1521:orcl";
+ orcle.userName = "userName";
+ orcle.password = "";
+ orcle.driver = "oracle.jdbc.OracleDriver";
+ mysql.url = "jdbc:mysql://119.23.203.111:3306/test";
+ mysql.userName = "userName";
+ mysql.password = "";
+ mysql.driver = "com.mysql.jdbc.Driver";
+ }
+
+}
+class DBInfo{
+ String url;
+ String userName;
+ String password;
+ String driver;
+}
diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/tool/JavaClassReader.java b/src/main/java/xyz/wbsite/dbtool/javafx/tool/JavaClassReader.java
new file mode 100644
index 00000000..b84fc5dc
--- /dev/null
+++ b/src/main/java/xyz/wbsite/dbtool/javafx/tool/JavaClassReader.java
@@ -0,0 +1,236 @@
+package xyz.wbsite.dbtool.javafx.tool;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class JavaClassReader {
+ private File javaClass;
+
+ private String packageName;
+ private String domainName;
+ private String moduleName;
+ private List annotationList;
+ private List importList;
+ private String className;
+ private String fatherName;
+ private List body;
+ private boolean hasList = false;
+ private String findOrSearchflag = "0";
+ private String Tclass = null;
+
+ public JavaClassReader(File javaClass) throws IOException {
+ this.javaClass = javaClass;
+ importList = new ArrayList<>();
+ annotationList = new ArrayList<>();
+ domainName = "";
+ read();
+ }
+
+ private void read() throws IOException {
+ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(javaClass), "utf-8"));
+
+ int step = 1;//1-读取package,2-读取import,3-读取类注释,4-读取类名、父类,5-读取类体
+
+ String line = null;
+ StringBuffer zs = new StringBuffer();
+ StringBuffer sb = new StringBuffer();
+ while ((line = bufferedReader.readLine()) != null) {
+ if (line.startsWith("package")) {
+ packageName = line;
+
+ String s = line.replaceAll("package ", "");
+ s = s.replaceAll(";", "");
+ String[] split = s.split("\\.");
+
+ if ("req".equals(split[split.length - 1]) || "rsp".equals(split[split.length - 1])|| "ent".equals(split[split.length - 1])) {
+ moduleName = split[split.length - 2];
+ for (int i = 0; i < split.length - 2; i++) {
+ domainName += split[i] + ".";
+ }
+ domainName = domainName.substring(0, domainName.length() - 1);
+ }
+
+ continue;
+ }
+ if (line.startsWith("import")) {
+ if (!line.contains("framework")) {
+ if (line.contains(".ent.")){
+ line = line.replaceAll("\\.ent\\.",".entity.");
+ }
+ importList.add(line);
+ }
+
+ continue;
+ }
+ if (line.contains("/**") || line.contains("*") || line.contains("*/")) {
+ if (zs != null) {
+ zs.append(line + "\n");
+ annotationList.add(line);
+ if (line.contains("*/")) {
+ zs = null;
+ }
+ }
+ }
+ if (line.contains("class")) {
+ line = line.replaceAll("\\{", " { ");
+ line = line.replaceAll("}", " } ");
+ line = line.replaceAll("\\s+", " ");
+ String[] split = line.split("\\s");
+ for (int i = 0; i < split.length; i++) {
+ if ("class".equals(split[i])) {
+ className = split[i + 1];
+ }
+ if ("extends".equals(split[i])) {
+ fatherName = split[i + 1];
+
+ if (fatherName.contains("FindResponse") || fatherName.contains("GetAllResponse")){
+ hasList = true;
+
+ Pattern pattern = Pattern.compile("<(.*?)>");
+ Matcher matcher = pattern.matcher(fatherName);
+ if (matcher.find()){
+ String group = matcher.group(1);
+ Tclass = group;
+ }
+ }
+ if (fatherName.contains("FindRequest")){
+ findOrSearchflag = "1";
+ }else if( fatherName.contains("SearchRequest")){
+ findOrSearchflag = "2";
+ }else {
+ findOrSearchflag = "0";
+ }
+ }
+ }
+ }
+ sb.append(line + "\n");
+ }
+
+ body = new ArrayList<>(Arrays.asList(sb.substring(sb.indexOf("{")).split("\n")));
+
+ for (int i = 0; i < body.size(); i++) {
+ if (body.get(i).contains("{")) {
+ body.set(i, body.get(i).replaceAll("\\{", ""));
+ String s = body.get(i);
+ if (s.length() <= 1){
+ body.remove(i);
+ }
+ break;
+ }
+ }
+ for (int i = body.size() - 1; i >= 0; i--) {
+ if (body.get(i).contains("}")) {
+ body.set(i, body.get(i).replaceAll("}", ""));
+ break;
+ }
+ }
+
+ bufferedReader.close();
+ }
+
+ public String getPackageName() {
+ return packageName;
+ }
+
+ public void setPackageName(String packageName) {
+ this.packageName = packageName;
+ }
+
+ public String getDomainName() {
+ return domainName;
+ }
+
+ public void setDomainName(String domainName) {
+ this.domainName = domainName;
+ }
+
+ public String getModuleName() {
+ return moduleName;
+ }
+
+ public void setModuleName(String moduleName) {
+ this.moduleName = moduleName;
+ }
+
+ public List