diff --git a/src/main/java/xyz/wbsite/dbtool/Application.java b/src/main/java/xyz/wbsite/dbtool/Application.java index 74351cd2..2dbf81bf 100644 --- a/src/main/java/xyz/wbsite/dbtool/Application.java +++ b/src/main/java/xyz/wbsite/dbtool/Application.java @@ -1,15 +1,12 @@ 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 xyz.wbsite.dbtool.web.frame.utils.ResourceUtil; +import xyz.wbsite.dbtool.javafx.JavaFxApplication; -import java.io.File; import java.io.FileNotFoundException; -import java.net.URL; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/JavaFxApplication.java b/src/main/java/xyz/wbsite/dbtool/javafx/JavaFxApplication.java index 5d139afa..bf3e5add 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/JavaFxApplication.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/JavaFxApplication.java @@ -57,16 +57,16 @@ import java.util.List; public class JavaFxApplication extends Application { - private ProjectManager dBmanger = ManagerFactory.getProjectManager(); - private TreeView mdtree = null; - private Pane detail = null; - private TableView feilds = null; + private ProjectManager dBmanager = ManagerFactory.getProjectManager(); + private TreeView mTree = null; + private Pane mDetail = null; + private TableView mFields = null; private Button add = null; private Button sub = null; - private FXMLLoader mainloader; - private FXMLLoader projectdetailloader; - private FXMLLoader mddetailloader; - private FXMLLoader tabledetailloader; + private FXMLLoader mMainLoader; + private FXMLLoader mProjectLoader; + private FXMLLoader mModuleLoader; + private FXMLLoader mTableLoader; private MainController mainController; private DetailProjectController detailProjectController; private DetailModuleController mdDetailController; @@ -83,7 +83,7 @@ public class JavaFxApplication extends Application { @Override public void start(Stage primaryStage) throws Exception { - BorderPane root = mainloader.getRoot(); + BorderPane root = mMainLoader.getRoot(); primaryStage.setTitle("DBtool"); primaryStage.setScene(new Scene(root, 700, 500)); @@ -105,15 +105,15 @@ public class JavaFxApplication extends Application { if (main == null) { main = getClass().getResource("../../../fxml/main.fxml"); } - mainloader = new FXMLLoader(main); - mainloader.load(); - mainController = mainloader.getController(); + mMainLoader = new FXMLLoader(main); + mMainLoader.load(); + mainController = mMainLoader.getController(); mainController.setMain(this); - mdtree = mainController.getDbtree(); - detail = mainController.getDetail(); - feilds = mainController.getFeilds(); - feilds.setEditable(true); - feilds.setSortPolicy(new Callback() { + mTree = mainController.getDbtree(); + mDetail = mainController.getDetail(); + mFields = mainController.getFeilds(); + mFields.setEditable(true); + mFields.setSortPolicy(new Callback() { @Override public Boolean call(TableView param) { //禁止点击列头排序 @@ -140,7 +140,7 @@ public class JavaFxApplication extends Application { @Override public void handle(ActionEvent event) { MenuItem target = (MenuItem) event.getTarget(); - int index = feilds.getSelectionModel().getSelectedIndex(); + int index = mFields.getSelectionModel().getSelectedIndex(); List fields = currentTable.getFields(); if ("新增".equals(target.getText())) { @@ -170,11 +170,11 @@ public class JavaFxApplication extends Application { break; } loadingTable(); - feilds.getSelectionModel().clearSelection(); + JavaFxApplication.this.mFields.getSelectionModel().clearSelection(); } } }); - feilds.setContextMenu(con); + mFields.setContextMenu(con); project_menu = new ContextMenu(new MenuItem("新增模块")); md_right_menu = new ContextMenu(new MenuItem("新增对象"), new MenuItem("删除模块"), new MenuItem("向上调整"), new MenuItem("向下调整")); @@ -187,31 +187,31 @@ public class JavaFxApplication extends Application { if (projectdetail == null) { projectdetail = getClass().getResource("../../../fxml/projectdetail.fxml"); } - projectdetailloader = new FXMLLoader(projectdetail); - projectdetailloader.load(); - detailProjectController = projectdetailloader.getController(); + mProjectLoader = new FXMLLoader(projectdetail); + mProjectLoader.load(); + detailProjectController = mProjectLoader.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(); + mModuleLoader = new FXMLLoader(mddetail); + mModuleLoader.load(); + mdDetailController = mModuleLoader.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(); - detailTableController = tabledetailloader.getController(); - - mdtree.setShowRoot(true); - mdtree.setEditable(true); - mdtree.setDisable(false); - mdtree.setCellFactory(new Callback() { + mTableLoader = new FXMLLoader(tabledetail); + mTableLoader.load(); + detailTableController = mTableLoader.getController(); + + mTree.setShowRoot(true); + mTree.setEditable(true); + mTree.setDisable(false); + mTree.setCellFactory(new Callback() { @Override public TreeCell call(TreeView param) { TextFieldTreeCell textFieldTreeCell = new TextFieldTreeCell(new DefaultStringConverter()); @@ -224,7 +224,7 @@ public class JavaFxApplication extends Application { public void handle(MouseEvent event) { TextFieldTreeCell source = (TextFieldTreeCell) event.getSource(); String text = source.getText(); - Module dbByDBName = dBmanger.findDBByDBName(text); + Module dbByDBName = dBmanager.findDBByDBName(text); if (dbByDBName != null) { dragMD = true; } else { @@ -248,7 +248,7 @@ public class JavaFxApplication extends Application { Dragboard md = event.getDragboard(); TextFieldTreeCell source = (TextFieldTreeCell) event.getSource(); - Module dbByDBName = dBmanger.findDBByDBName(source.getText()); + Module dbByDBName = dBmanager.findDBByDBName(source.getText()); if (dragMD && dbByDBName != null) { double y = event.getY(); @@ -284,7 +284,7 @@ public class JavaFxApplication extends Application { String m2 = ((TreeCell) event.getGestureTarget()).getItem(); if (dragMD) { - List mds = dBmanger.getMds(); + List mds = dBmanager.getMds(); int i1 = 0, i2 = 0; for (int i = 0; i < mds.size(); i++) { @@ -346,19 +346,19 @@ public class JavaFxApplication extends Application { } event.setDropCompleted(true); event.consume(); - mdtree.getSelectionModel().clearSelection(); - int focusedIndex = mdtree.getFocusModel().getFocusedIndex(); + mTree.getSelectionModel().clearSelection(); + int focusedIndex = mTree.getFocusModel().getFocusedIndex(); System.out.println(focusedIndex); } }); return textFieldTreeCell; } }); - mdtree.setOnEditCommit(new YEventHandler()); - mdtree.setOnMouseClicked(new EventHandler() { + mTree.setOnEditCommit(new YEventHandler()); + mTree.setOnMouseClicked(new EventHandler() { @Override public void handle(MouseEvent event) { - TreeItem targetItem = (TreeItem) mdtree.getSelectionModel().getSelectedItem(); + TreeItem targetItem = (TreeItem) mTree.getSelectionModel().getSelectedItem(); if (targetItem == null) return; @@ -367,24 +367,24 @@ public class JavaFxApplication extends Application { switch (level) { case 0: {//查看模块 - mdtree.setContextMenu(project_menu); + mTree.setContextMenu(project_menu); loadingProject(); } break; case 1: {//查看模块 - mdtree.setContextMenu(md_right_menu); - currentMD = dBmanger.findDBByDBName((String) targetItem.getValue()); + mTree.setContextMenu(md_right_menu); + currentMD = dBmanager.findDBByDBName((String) targetItem.getValue()); currentTable = null; loadingModule(); } break; case 2: {//查看对象 - mdtree.setContextMenu(table_right_menu); + mTree.setContextMenu(table_right_menu); TreeItem parent = targetItem.getParent(); - currentMD = dBmanger.findDBByDBName((String) parent.getValue()); + currentMD = dBmanager.findDBByDBName((String) parent.getValue()); if (currentMD != null) { - currentTable = dBmanger.findTableByTableName(currentMD, (String) targetItem.getValue()); + currentTable = dBmanager.findTableByTableName(currentMD, (String) targetItem.getValue()); } loadingTable(); break; @@ -533,21 +533,21 @@ public class JavaFxApplication extends Application { } private void addField() { - if (currentTable != null && feilds != null) { + if (currentTable != null && mFields != null) { List fields = currentTable.getFields(); - String fieldName = dBmanger.getNewFieldName(fields); + String fieldName = dBmanager.getNewFieldName(fields); System.out.println("新增字段-" + fieldName + "成功!"); - feilds.getSelectionModel().select(fields.size() - 1); + this.mFields.getSelectionModel().select(fields.size() - 1); loadingTable(); } } private void subField() { if (currentTable != null) { - int selectedIndex = feilds.getSelectionModel().getSelectedIndex(); + int selectedIndex = mFields.getSelectionModel().getSelectedIndex(); if (selectedIndex > -1 && !currentTable.getFields().get(selectedIndex).getIsSystem()) { currentTable.getFields().remove(selectedIndex); - feilds.getSelectionModel().clearSelection(); + mFields.getSelectionModel().clearSelection(); loadingTable(); } @@ -555,11 +555,11 @@ public class JavaFxApplication extends Application { } public void loadingProjectTree() { - currentProject = dBmanger.getProject(); + currentProject = dBmanager.getProject(); currentProject.setValue(currentProject.getProjectName()); currentProject.setExpanded(true); - mdtree.setRoot(currentProject); + mTree.setRoot(currentProject); for (int i = 0; i < currentProject.getModules().size(); i++) { Module module = currentProject.getModules().get(i); @@ -574,7 +574,7 @@ public class JavaFxApplication extends Application { } private int getLevel(TreeItem treeItem) { - TreeItem root = mdtree.getRoot(); + TreeItem root = mTree.getRoot(); int level = 0; if (treeItem == root) { level = 0; @@ -591,22 +591,22 @@ public class JavaFxApplication extends Application { return; } - GridPane gridPane = mddetailloader.getRoot(); + GridPane gridPane = mModuleLoader.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); + mDetail.getChildren().clear(); + mDetail.getChildren().add(gridPane); } - if (feilds != null && feilds.getItems() != null) { - feilds.getItems().clear(); + if (mFields != null && mFields.getItems() != null) { + mFields.getItems().clear(); } } public void loadingProject() { - GridPane gridPane = projectdetailloader.getRoot(); + GridPane gridPane = mProjectLoader.getRoot(); detailProjectController.getProjectName().setText(currentProject.getProjectName()); detailProjectController.getProjectBasePackage().setText(currentProject.getProjectBasePackage()); detailProjectController.getProjectAuthor().setText(currentProject.getProjectAuthor()); @@ -614,11 +614,11 @@ public class JavaFxApplication extends Application { detailProjectController.getSysMD().setSelected(currentProject.getSysMD()); if (gridPane != null) { - detail.getChildren().clear(); - detail.getChildren().add(gridPane); + mDetail.getChildren().clear(); + mDetail.getChildren().add(gridPane); } - if (feilds != null && feilds.getItems() != null) { - feilds.getItems().clear(); + if (mFields != null && mFields.getItems() != null) { + mFields.getItems().clear(); } } @@ -626,7 +626,7 @@ public class JavaFxApplication extends Application { * 加载对象信息 */ private void loadingTable() { - GridPane gridPane = tabledetailloader.getRoot(); + GridPane gridPane = mTableLoader.getRoot(); if (currentTable != null) { detailTableController.getTablename().setText(currentTable.getTableName()); detailTableController.getTablecomment().setText(currentTable.getTableComment()); @@ -641,10 +641,10 @@ public class JavaFxApplication extends Application { } if (gridPane != null) { - detail.getChildren().clear(); - detail.getChildren().add(gridPane); + mDetail.getChildren().clear(); + mDetail.getChildren().add(gridPane); } - ObservableList columns = feilds.getColumns(); + ObservableList columns = mFields.getColumns(); columns.get(0).setCellValueFactory(new PropertyValueFactory("fieldName")); columns.get(0).setCellFactory(new Callback() { @Override @@ -794,7 +794,7 @@ public class JavaFxApplication extends Application { FieldType fieldType = field.getFieldType(); if (fieldType.isFix() && fieldType.getDefaultLength() != field.getFieldLength()) { field.setFieldLength(fieldType.getDefaultLength()); - feilds.refresh(); + mFields.refresh(); } if (field.getIsSystem()) { ignoreField(this); @@ -819,7 +819,7 @@ public class JavaFxApplication extends Application { FieldType newValue = (FieldType) event.getNewValue(); field.setFieldLength(newValue.getDefaultLength()); field.setFieldType(newValue); - feilds.refresh(); + mFields.refresh(); } }); return choiceBoxTableCell; @@ -841,7 +841,7 @@ public class JavaFxApplication extends Application { e.printStackTrace(); } } - feilds.refresh(); + mFields.refresh(); } }); TextFieldTableCell textFieldTableCell = new TextFieldTableCell(new IntegerStringConverter()) { @@ -1079,7 +1079,7 @@ public class JavaFxApplication extends Application { data.addAll(fields); } - feilds.setItems(data); + mFields.setItems(data); } void ignoreField(TableCell tableCell) { @@ -1105,20 +1105,20 @@ public class JavaFxApplication extends Application { switch (level) { case 0: {//编辑项目名称 - dBmanger.getProject().setProjectName((String) event.getNewValue()); + dBmanager.getProject().setProjectName((String) event.getNewValue()); loadingProject(); } break; case 1: {//编辑模块 - Module md = dBmanger.findDBByDBName((String) event.getOldValue()); + Module md = dBmanager.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()); + Module md = dBmanager.findDBByDBName((String) parent.getValue()); + Table table = dBmanager.findTableByTableName(md, (String) event.getOldValue()); if (table != null) { table.setTableName((String) event.getNewValue()); loadingTable(); @@ -1141,40 +1141,40 @@ public class JavaFxApplication extends Application { MenuItem target = (MenuItem) event.getTarget(); String text = target.getText(); - Project project = (Project) mdtree.getRoot(); + Project project = (Project) mTree.getRoot(); - TreeItem targetItem = (TreeItem) mdtree.getFocusModel().getFocusedItem(); + TreeItem targetItem = (TreeItem) mTree.getFocusModel().getFocusedItem(); int index = -1; - index = mdtree.getFocusModel().getFocusedIndex(); + index = mTree.getFocusModel().getFocusedIndex(); if (targetItem == null) { - targetItem = (TreeItem) mdtree.getSelectionModel().getSelectedItem(); + targetItem = (TreeItem) mTree.getSelectionModel().getSelectedItem(); } if (index == -1) { - index = mdtree.getSelectionModel().getSelectedIndex(); + index = mTree.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); + Tool.exchange(dBmanager.getProject().getModules(), index - 1, index); + Tool.exchange(dBmanager.getProject().getChildren(), index - 1, index); } break; case "向下调整": - List mds = dBmanger.getMds(); + List mds = dBmanager.getMds(); if (index < mds.size() - 1) { - Tool.exchange(dBmanger.getProject().getModules(), index, index + 1); - Tool.exchange(dBmanger.getProject().getChildren(), index, index + 1); + Tool.exchange(dBmanager.getProject().getModules(), index, index + 1); + Tool.exchange(dBmanager.getProject().getChildren(), index, index + 1); } break; case "新增模块": - dBmanger.getNewModuleName(); + dBmanager.getNewModuleName(); break; case "删除模块": if (targetItem != null && targetItem.getParent() == project) { currentProject.getChildren().remove(targetItem); - boolean b = dBmanger.removeDBByDBName((String) targetItem.getValue()); + boolean b = dBmanager.removeDBByDBName((String) targetItem.getValue()); if (b) { System.out.println("删除模块" + targetItem.getValue() + "成功!"); } @@ -1186,9 +1186,9 @@ public class JavaFxApplication extends Application { switch (level) { case 1: {//对模块右击 System.out.println("模块:" + targetItem.getValue()); - Module md = dBmanger.findDBByDBName((String) targetItem.getValue()); + Module md = dBmanager.findDBByDBName((String) targetItem.getValue()); if (md != null) { - Table newTableName = dBmanger.getNewTableName(md); + Table newTableName = dBmanager.getNewTableName(md); targetItem.getChildren().add(newTableName); } } @@ -1196,8 +1196,8 @@ public class JavaFxApplication extends Application { case 2: {//对对象右击 TreeItem parent = targetItem.getParent(); System.out.println("对象:" + parent.getValue()); - Module md = dBmanger.findDBByDBName((String) parent.getValue()); - Table newTableName = dBmanger.getNewTableName(md); + Module md = dBmanager.findDBByDBName((String) parent.getValue()); + Table newTableName = dBmanager.getNewTableName(md); parent.getChildren().add(new TreeItem<>(newTableName.getTableName())); break; } @@ -1215,15 +1215,15 @@ public class JavaFxApplication extends Application { switch (level) { case 0: {//对模块右击 System.out.println("模块:" + targetItem.getValue()); - Module md = dBmanger.findDBByDBName((String) targetItem.getValue()); - Table newTableName = dBmanger.getNewTableName(md); + Module md = dBmanager.findDBByDBName((String) targetItem.getValue()); + Table newTableName = dBmanager.getNewTableName(md); 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()); + Module md = dBmanager.findDBByDBName((String) parent.getValue()); for (Table table : md.getTables()) { if (table.getTableName().equals(targetItem.getValue())) { @@ -1243,7 +1243,7 @@ public class JavaFxApplication extends Application { } else if (text != null && targetItem == null) { switch (text) { case "新增模块": - dBmanger.getNewModuleName(); + dBmanager.getNewModuleName(); break; default: break; @@ -1253,7 +1253,7 @@ public class JavaFxApplication extends Application { } private void updateDbTree(List mds) { - TreeItem root = mdtree.getRoot(); + TreeItem root = mTree.getRoot(); for (Module md : mds) { TreeItem treeItem = new TreeItem<>(md.getModuleName()); treeItem.setExpanded(true); diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/MainController.java b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/MainController.java index 430e708f..9f08039c 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/MainController.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/MainController.java @@ -200,6 +200,7 @@ public class MainController { public void generateAndroid(ActionEvent actionEvent) { Dialog.showAndroid(); } + @FXML public void generateSBMDB(ActionEvent actionEvent) { Dialog.showSBMDB(); diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/OptionAndroidController.java b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/OptionAndroidController.java index a2c0509d..122bddd8 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/OptionAndroidController.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/OptionAndroidController.java @@ -2,7 +2,6 @@ package xyz.wbsite.dbtool.javafx.ctrl; import javafx.fxml.FXML; import javafx.scene.control.Button; -import javafx.scene.control.CheckBox; import javafx.scene.control.TextField; public class OptionAndroidController { diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/OptionApiController.java b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/OptionApiController.java index 3340aa9a..d0ca99db 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/OptionApiController.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/OptionApiController.java @@ -6,7 +6,12 @@ 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.Button; +import javafx.scene.control.CheckBox; +import javafx.scene.control.TableCell; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; +import javafx.scene.control.TextField; import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.control.cell.TextFieldTableCell; import javafx.util.Callback; @@ -18,9 +23,14 @@ import xyz.wbsite.dbtool.javafx.tool.Dialog; import xyz.wbsite.dbtool.javafx.tool.Tool; import xyz.wbsite.dbtool.javafx.view.DBCheckBoxTableCell; -import java.io.*; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.UnsupportedEncodingException; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/OptionMainController.java b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/OptionMainController.java index e090b33d..bba75901 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/OptionMainController.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/OptionMainController.java @@ -1,11 +1,11 @@ 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; +import xyz.wbsite.dbtool.javafx.listener.GenerateOptionListener; public class OptionMainController { diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/OptionVueController.java b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/OptionVueController.java index b605d464..a24284da 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/OptionVueController.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/OptionVueController.java @@ -2,8 +2,6 @@ package xyz.wbsite.dbtool.javafx.ctrl; import javafx.fxml.FXML; import javafx.scene.control.Button; -import javafx.scene.control.CheckBox; -import javafx.scene.control.TextField; import javafx.scene.control.ToggleGroup; public class OptionVueController { diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/listener/GenerateOptionListener.java b/src/main/java/xyz/wbsite/dbtool/javafx/listener/GenerateOptionListener.java index 83d0e39c..c7981db0 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/listener/GenerateOptionListener.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/listener/GenerateOptionListener.java @@ -3,5 +3,5 @@ package xyz.wbsite.dbtool.javafx.listener; import xyz.wbsite.dbtool.javafx.enums.DataBase; public interface GenerateOptionListener { - void onGenerate(String option,DataBase dataBase); + 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 index 57bba0e3..5999143b 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/manger/FreeMarkerManager.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/FreeMarkerManager.java @@ -1,19 +1,20 @@ 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 freemarker.cache.ClassTemplateLoader; +import freemarker.cache.MultiTemplateLoader; +import freemarker.cache.TemplateLoader; +import freemarker.template.Configuration; +import freemarker.template.Template; +import freemarker.template.TemplateException; +import freemarker.template.TemplateExceptionHandler; 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; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.Writer; public class FreeMarkerManager { private FreeMarkerConfigurer freeMarkerConfigurer; @@ -47,7 +48,7 @@ public class FreeMarkerManager { //获取ftl,由于已经在配置文件中配置了路径所以在这里直接写模板名称就可以 Template temp = configuration.getTemplate(template); //输出文件路径 - Writer wr = new OutputStreamWriter(new FileOutputStream(outfile),"UTF-8"); + Writer wr = new OutputStreamWriter(new FileOutputStream(outfile), "UTF-8"); //写入 temp.process(model, wr); //关闭流 diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/manger/ManagerFactory.java b/src/main/java/xyz/wbsite/dbtool/javafx/manger/ManagerFactory.java index faedc098..98cc7b1b 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/manger/ManagerFactory.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/ManagerFactory.java @@ -4,7 +4,7 @@ import xyz.wbsite.dbtool.javafx.JavaFxApplication; public class ManagerFactory { private static XmlManager xmlManager = null; - private static ReflashManager reflashManager =null; + private static ReflashManager reflashManager = null; private static ProjectManager projectManager; private static FreeMarkerManager freeMarkerManager; @@ -28,7 +28,7 @@ public class ManagerFactory { } public static ReflashManager getReflashManager(JavaFxApplication main) { - if (reflashManager == null){ + if (reflashManager == null) { reflashManager = new ReflashManager(main); } return reflashManager; diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/manger/ReflashManager.java b/src/main/java/xyz/wbsite/dbtool/javafx/manger/ReflashManager.java index bbac4d1f..60189680 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/manger/ReflashManager.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/ReflashManager.java @@ -2,7 +2,7 @@ package xyz.wbsite.dbtool.javafx.manger; import xyz.wbsite.dbtool.javafx.JavaFxApplication; -public class ReflashManager extends Thread{ +public class ReflashManager extends Thread { private JavaFxApplication main; public ReflashManager(JavaFxApplication main) { @@ -11,13 +11,13 @@ public class ReflashManager extends Thread{ @Override public void run() { - while (true){ + while (true) { try { Thread.sleep(200); } catch (InterruptedException e) { e.printStackTrace(); } - if (ProjectManager.isUpdate){ + if (ProjectManager.isUpdate) { main.loadingProjectTree(); ProjectManager.isUpdate = false; } diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/ApiCallable.java b/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/ApiCallable.java index 914878cf..132acac4 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/ApiCallable.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/ApiCallable.java @@ -193,7 +193,7 @@ public class ApiCallable implements Callable { ArrayList apis = new ArrayList<>(); for (Api api : apiList) { - if (m.equals(api.getModule())){ + if (m.equals(api.getModule())) { apis.add(api); } } diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/po/AbstractDBmapper.java b/src/main/java/xyz/wbsite/dbtool/javafx/po/AbstractDBmapper.java index 5117a9df..71971ba0 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/po/AbstractDBmapper.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/po/AbstractDBmapper.java @@ -6,7 +6,7 @@ import xyz.wbsite.dbtool.javafx.enums.FieldType; public abstract class AbstractDBmapper { DataBase mDataBase = null; - private AbstractDBmapper(){ + private AbstractDBmapper() { } @@ -14,11 +14,13 @@ public abstract class AbstractDBmapper { this.mDataBase = mDataBase; } - DataBase getDataBase(){ + DataBase getDataBase() { return mDataBase; } 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 index 10091904..6ff57d8c 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/po/Api.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/po/Api.java @@ -1,9 +1,7 @@ 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 { diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/po/Field.java b/src/main/java/xyz/wbsite/dbtool/javafx/po/Field.java index bb408e8c..9d5438c0 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/po/Field.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/po/Field.java @@ -118,7 +118,7 @@ public class Field extends Table { value = "(byte)1"; } else if (fieldType.name().matches("Short")) { value = "(short)1"; - }else if (fieldType.name().matches("Integer")) { + } else if (fieldType.name().matches("Integer")) { value = "1"; } else if (fieldType.name().matches("Bytes")) { value = "null"; diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/po/Project.java b/src/main/java/xyz/wbsite/dbtool/javafx/po/Project.java index 5bcd1ddc..22e9c854 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/po/Project.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/po/Project.java @@ -5,7 +5,7 @@ import javafx.scene.control.TreeItem; import java.util.ArrayList; import java.util.List; -public class Project extends TreeItem{ +public class Project extends TreeItem { public Project() { this.projectName = "EXAMPLE-WEB"; diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/tool/EntityReader.java b/src/main/java/xyz/wbsite/dbtool/javafx/tool/EntityReader.java index ba4f9c78..ec98f2ce 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/tool/EntityReader.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/tool/EntityReader.java @@ -1,6 +1,10 @@ package xyz.wbsite.dbtool.javafx.tool; -import java.io.*; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashSet; import java.util.List; diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/tool/RequestReader.java b/src/main/java/xyz/wbsite/dbtool/javafx/tool/RequestReader.java index 5f4ea355..920534bc 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/tool/RequestReader.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/tool/RequestReader.java @@ -1,6 +1,10 @@ package xyz.wbsite.dbtool.javafx.tool; -import java.io.*; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashSet; import java.util.List; diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/tool/ResponseReader.java b/src/main/java/xyz/wbsite/dbtool/javafx/tool/ResponseReader.java index 4bab20ca..fa035c9d 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/tool/ResponseReader.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/tool/ResponseReader.java @@ -1,6 +1,10 @@ package xyz.wbsite.dbtool.javafx.tool; -import java.io.*; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -24,7 +28,7 @@ public class ResponseReader { private String findOrSearchflag = "0"; private String Tclass = null; - public ResponseReader(File javaClass){ + public ResponseReader(File javaClass) { this.javaClass = javaClass; importList = new ArrayList<>(); notesList = new ArrayList<>(); diff --git a/src/main/java/xyz/wbsite/dbtool/web/action/GlobalController.java b/src/main/java/xyz/wbsite/dbtool/web/action/GlobalController.java index 0e01a11e..02e15b2b 100644 --- a/src/main/java/xyz/wbsite/dbtool/web/action/GlobalController.java +++ b/src/main/java/xyz/wbsite/dbtool/web/action/GlobalController.java @@ -8,7 +8,13 @@ import org.springframework.boot.web.servlet.error.ErrorController; import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.DispatcherServlet; import org.springframework.web.servlet.LocaleResolver; @@ -17,7 +23,11 @@ import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver; import xyz.wbsite.dbtool.web.config.ActionConfig; import xyz.wbsite.dbtool.web.frame.auth.LocalData; -import xyz.wbsite.dbtool.web.frame.base.*; +import xyz.wbsite.dbtool.web.frame.base.BaseRequest; +import xyz.wbsite.dbtool.web.frame.base.BaseResponse; +import xyz.wbsite.dbtool.web.frame.base.ErrorType; +import xyz.wbsite.dbtool.web.frame.base.Screen; +import xyz.wbsite.dbtool.web.frame.base.Token; import xyz.wbsite.dbtool.web.frame.utils.MapperUtil; import javax.servlet.http.HttpServletRequest; diff --git a/src/main/java/xyz/wbsite/dbtool/web/action/control/Header.java b/src/main/java/xyz/wbsite/dbtool/web/action/control/Header.java index aa007342..baa0b84a 100644 --- a/src/main/java/xyz/wbsite/dbtool/web/action/control/Header.java +++ b/src/main/java/xyz/wbsite/dbtool/web/action/control/Header.java @@ -1,7 +1,7 @@ package xyz.wbsite.dbtool.web.action.control; -import xyz.wbsite.dbtool.web.frame.base.Control; import org.springframework.ui.Model; +import xyz.wbsite.dbtool.web.frame.base.Control; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; diff --git a/src/main/java/xyz/wbsite/dbtool/web/action/screen/Index.java b/src/main/java/xyz/wbsite/dbtool/web/action/screen/Index.java index 9f8757e7..44587d69 100644 --- a/src/main/java/xyz/wbsite/dbtool/web/action/screen/Index.java +++ b/src/main/java/xyz/wbsite/dbtool/web/action/screen/Index.java @@ -1,10 +1,11 @@ package xyz.wbsite.dbtool.web.action.screen; -import xyz.wbsite.dbtool.web.frame.base.Screen; import org.springframework.ui.Model; -import java.util.ArrayList; +import xyz.wbsite.dbtool.web.frame.base.Screen; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; public class Index extends Screen { diff --git a/src/main/java/xyz/wbsite/dbtool/web/config/ActionConfig.java b/src/main/java/xyz/wbsite/dbtool/web/config/ActionConfig.java index af8133fa..b5f7da0f 100644 --- a/src/main/java/xyz/wbsite/dbtool/web/config/ActionConfig.java +++ b/src/main/java/xyz/wbsite/dbtool/web/config/ActionConfig.java @@ -69,7 +69,7 @@ public class ActionConfig implements BeanDefinitionRegistryPostProcessor { @Override public String generateBeanName(BeanDefinition beanDefinition, BeanDefinitionRegistry beanDefinitionRegistry) { String beanClassName = beanDefinition.getBeanClassName(); - String beamName = beanClassName.replaceAll(basePackage + ".", SCREEN_PREFIX).replaceAll("\\.","/").toLowerCase(); + String beamName = beanClassName.replaceAll(basePackage + ".", SCREEN_PREFIX).replaceAll("\\.", "/").toLowerCase(); LogUtil.i("registry screen " + beamName); return beamName; } @@ -92,7 +92,7 @@ public class ActionConfig implements BeanDefinitionRegistryPostProcessor { @Override public String generateBeanName(BeanDefinition beanDefinition, BeanDefinitionRegistry beanDefinitionRegistry) { String beanClassName = beanDefinition.getBeanClassName(); - String beamName = beanClassName.replaceAll(basePackage + ".", CONTROL_PREFIX).replaceAll("\\.","/").toLowerCase(); + String beamName = beanClassName.replaceAll(basePackage + ".", CONTROL_PREFIX).replaceAll("\\.", "/").toLowerCase(); LogUtil.i("registry control " + beamName); return beamName; } @@ -115,7 +115,7 @@ public class ActionConfig implements BeanDefinitionRegistryPostProcessor { if (beanClassName != null && beanClassName.endsWith("Ajax")) { beanClassName = beanClassName.substring(0, beanClassName.length() - 4); } - String beamName = beanClassName.replaceAll(basePackage + ".", AJAX_PREFIX).replaceAll("\\.","/").toLowerCase(); + String beamName = beanClassName.replaceAll(basePackage + ".", AJAX_PREFIX).replaceAll("\\.", "/").toLowerCase(); LogUtil.i("registry ajax " + beamName); return beamName; } diff --git a/src/main/java/xyz/wbsite/dbtool/web/config/FreeMarkerConfig.java b/src/main/java/xyz/wbsite/dbtool/web/config/FreeMarkerConfig.java index 2dd2bff8..58952a0c 100644 --- a/src/main/java/xyz/wbsite/dbtool/web/config/FreeMarkerConfig.java +++ b/src/main/java/xyz/wbsite/dbtool/web/config/FreeMarkerConfig.java @@ -1,8 +1,5 @@ package xyz.wbsite.dbtool.web.config; -import xyz.wbsite.dbtool.web.frame.auth.LocalData; -import xyz.wbsite.dbtool.web.frame.base.Control; -import xyz.wbsite.dbtool.web.frame.utils.UrlUtil; import freemarker.template.SimpleScalar; import freemarker.template.TemplateMethodModelEx; import freemarker.template.TemplateModelException; @@ -17,6 +14,9 @@ import org.springframework.web.servlet.DispatcherServlet; import org.springframework.web.servlet.LocaleResolver; import org.springframework.web.servlet.View; import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver; +import xyz.wbsite.dbtool.web.frame.auth.LocalData; +import xyz.wbsite.dbtool.web.frame.base.Control; +import xyz.wbsite.dbtool.web.frame.utils.UrlUtil; import javax.annotation.PostConstruct; import javax.servlet.http.HttpServletRequest; diff --git a/src/main/java/xyz/wbsite/dbtool/web/config/SecurityConfig.java b/src/main/java/xyz/wbsite/dbtool/web/config/SecurityConfig.java index 76ddb692..ee0e2ba5 100644 --- a/src/main/java/xyz/wbsite/dbtool/web/config/SecurityConfig.java +++ b/src/main/java/xyz/wbsite/dbtool/web/config/SecurityConfig.java @@ -10,12 +10,16 @@ import org.springframework.security.config.annotation.web.builders.WebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.core.Authentication; +import org.springframework.security.web.access.intercept.FilterSecurityInterceptor; +import xyz.wbsite.dbtool.web.frame.auth.LocalData; import xyz.wbsite.dbtool.web.frame.base.Token; import xyz.wbsite.dbtool.web.frame.utils.CookieUtil; -import xyz.wbsite.dbtool.web.frame.auth.LocalData; -import org.springframework.security.web.access.intercept.FilterSecurityInterceptor; -import javax.servlet.*; +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import java.io.IOException; import java.util.regex.Matcher; diff --git a/src/main/java/xyz/wbsite/dbtool/web/config/TaskConfig.java b/src/main/java/xyz/wbsite/dbtool/web/config/TaskConfig.java index fbd7980c..e68fcb01 100644 --- a/src/main/java/xyz/wbsite/dbtool/web/config/TaskConfig.java +++ b/src/main/java/xyz/wbsite/dbtool/web/config/TaskConfig.java @@ -20,10 +20,10 @@ import java.util.concurrent.Executors; @Configuration @EnableScheduling @Profile("prod") -public class TaskConfig implements SchedulingConfigurer { +public class TaskConfig implements SchedulingConfigurer { - @Scheduled(cron="0/30 * * * * ? ") - public void task(){ + @Scheduled(cron = "0/30 * * * * ? ") + public void task() { // todo 自定实现的定时任务 SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss"); HashMap data = new HashMap<>(); diff --git a/src/main/java/xyz/wbsite/dbtool/web/frame/auth/LocalData.java b/src/main/java/xyz/wbsite/dbtool/web/frame/auth/LocalData.java index ecea0bff..dafc0c0b 100644 --- a/src/main/java/xyz/wbsite/dbtool/web/frame/auth/LocalData.java +++ b/src/main/java/xyz/wbsite/dbtool/web/frame/auth/LocalData.java @@ -1,10 +1,10 @@ package xyz.wbsite.dbtool.web.frame.auth; -import xyz.wbsite.dbtool.web.frame.base.Token; import org.springframework.context.ApplicationContext; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.support.WebApplicationContextUtils; +import xyz.wbsite.dbtool.web.frame.base.Token; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; diff --git a/src/main/java/xyz/wbsite/dbtool/web/frame/base/BaseEntity.java b/src/main/java/xyz/wbsite/dbtool/web/frame/base/BaseEntity.java index ef3b0f96..ed12d150 100644 --- a/src/main/java/xyz/wbsite/dbtool/web/frame/base/BaseEntity.java +++ b/src/main/java/xyz/wbsite/dbtool/web/frame/base/BaseEntity.java @@ -1,6 +1,7 @@ package xyz.wbsite.dbtool.web.frame.base; import com.fasterxml.jackson.annotation.JsonIgnore; + import java.io.Serializable; import java.util.Date; @@ -43,8 +44,8 @@ public class BaseEntity implements Serializable { private Date lastUpdateTime; /** - * 是否删除 - */ + * 是否删除 + */ @JsonIgnore private boolean isDeleted; diff --git a/src/main/java/xyz/wbsite/dbtool/web/frame/base/BaseFindResponse.java b/src/main/java/xyz/wbsite/dbtool/web/frame/base/BaseFindResponse.java index 0bff529b..96d32a67 100644 --- a/src/main/java/xyz/wbsite/dbtool/web/frame/base/BaseFindResponse.java +++ b/src/main/java/xyz/wbsite/dbtool/web/frame/base/BaseFindResponse.java @@ -9,7 +9,7 @@ import java.util.List; * @version 0.0.1 * @since 2017-01-01 */ -public class BaseFindResponse extends BaseResponse{ +public class BaseFindResponse extends BaseResponse { private List result; diff --git a/src/main/java/xyz/wbsite/dbtool/web/frame/base/BaseSearchRequest.java b/src/main/java/xyz/wbsite/dbtool/web/frame/base/BaseSearchRequest.java index be54ee39..c7bbac43 100644 --- a/src/main/java/xyz/wbsite/dbtool/web/frame/base/BaseSearchRequest.java +++ b/src/main/java/xyz/wbsite/dbtool/web/frame/base/BaseSearchRequest.java @@ -10,8 +10,8 @@ package xyz.wbsite.dbtool.web.frame.base; public class BaseSearchRequest extends BaseFindRequest { /** - * 模糊查询的关键字。 - */ + * 模糊查询的关键字。 + */ private String keyword; public String getKeyword() { diff --git a/src/main/java/xyz/wbsite/dbtool/web/frame/base/BaseUpdateRequest.java b/src/main/java/xyz/wbsite/dbtool/web/frame/base/BaseUpdateRequest.java index f79d08ad..85b1bc48 100644 --- a/src/main/java/xyz/wbsite/dbtool/web/frame/base/BaseUpdateRequest.java +++ b/src/main/java/xyz/wbsite/dbtool/web/frame/base/BaseUpdateRequest.java @@ -7,11 +7,11 @@ package xyz.wbsite.dbtool.web.frame.base; * @version 0.0.1 * @since 2017-01-01 */ -public class BaseUpdateRequest extends BaseRequest{ +public class BaseUpdateRequest extends BaseRequest { /** - * 版本戳 - */ + * 版本戳 + */ private long rowVersion; public long getRowVersion() { diff --git a/src/main/java/xyz/wbsite/dbtool/web/frame/base/Token.java b/src/main/java/xyz/wbsite/dbtool/web/frame/base/Token.java index 3c958a20..0b524cf3 100644 --- a/src/main/java/xyz/wbsite/dbtool/web/frame/base/Token.java +++ b/src/main/java/xyz/wbsite/dbtool/web/frame/base/Token.java @@ -13,11 +13,17 @@ import java.util.Set; */ public class Token implements Serializable { private static final Long serialVersionUID = 1L; - /** ID */ + /** + * ID + */ private long id; - /** 用户ID */ + /** + * 用户ID + */ private long userId; - /** 用户名称 */ + /** + * 用户名称 + */ private String userName; private Set resourceSet = new HashSet<>(); @@ -47,16 +53,16 @@ public class Token implements Serializable { this.userName = userName; } - public boolean hasResource(String resource){ + public boolean hasResource(String resource) { for (String s : resourceSet) { - if (resource.matches(s)){ + if (resource.matches(s)) { return true; } } return false; } - public void putResource(String resource){ + public void putResource(String resource) { resourceSet.add(resource); } @@ -64,11 +70,11 @@ public class Token implements Serializable { return resourceSet; } - public void addResourceSet(Set resourceSet){ + public void addResourceSet(Set resourceSet) { this.resourceSet.addAll(resourceSet); } - public void addResourceSet(Token token){ + public void addResourceSet(Token token) { addResourceSet(token.getResourceSet()); } } diff --git a/src/main/java/xyz/wbsite/dbtool/web/frame/utils/CookieUtil.java b/src/main/java/xyz/wbsite/dbtool/web/frame/utils/CookieUtil.java index 7a91cc33..1be66ba1 100644 --- a/src/main/java/xyz/wbsite/dbtool/web/frame/utils/CookieUtil.java +++ b/src/main/java/xyz/wbsite/dbtool/web/frame/utils/CookieUtil.java @@ -1,8 +1,9 @@ package xyz.wbsite.dbtool.web.frame.utils; - import xyz.wbsite.dbtool.web.frame.auth.LocalData; - import javax.servlet.http.Cookie; - import javax.servlet.http.HttpServletRequest; +import xyz.wbsite.dbtool.web.frame.auth.LocalData; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; /** * CookieUtil diff --git a/src/main/java/xyz/wbsite/dbtool/web/frame/utils/FileUtil.java b/src/main/java/xyz/wbsite/dbtool/web/frame/utils/FileUtil.java index b93984ad..8ed339c9 100644 --- a/src/main/java/xyz/wbsite/dbtool/web/frame/utils/FileUtil.java +++ b/src/main/java/xyz/wbsite/dbtool/web/frame/utils/FileUtil.java @@ -68,20 +68,20 @@ public class FileUtil { } public static byte[] toByteArray(InputStream input, int size) throws IOException { - if(size < 0) { + if (size < 0) { throw new IllegalArgumentException("Size must be equal or greater than zero: " + size); - } else if(size == 0) { + } else if (size == 0) { return new byte[0]; } else { byte[] data = new byte[size]; int offset; int read; - for(offset = 0; offset < size && (read = input.read(data, offset, size - offset)) != -1; offset += read) { + for (offset = 0; offset < size && (read = input.read(data, offset, size - offset)) != -1; offset += read) { ; } - if(offset != size) { + if (offset != size) { throw new IOException("Unexpected read size. current: " + offset + ", expected: " + size); } else { return data; diff --git a/src/main/java/xyz/wbsite/dbtool/web/frame/utils/IDgenerator.java b/src/main/java/xyz/wbsite/dbtool/web/frame/utils/IDgenerator.java index 53eda888..b22b2fba 100644 --- a/src/main/java/xyz/wbsite/dbtool/web/frame/utils/IDgenerator.java +++ b/src/main/java/xyz/wbsite/dbtool/web/frame/utils/IDgenerator.java @@ -1,9 +1,5 @@ package xyz.wbsite.dbtool.web.frame.utils; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; - /** * IDgenerator - ID生成器 * diff --git a/src/main/java/xyz/wbsite/dbtool/web/frame/utils/LogUtil.java b/src/main/java/xyz/wbsite/dbtool/web/frame/utils/LogUtil.java index 56f55d20..77c331fa 100644 --- a/src/main/java/xyz/wbsite/dbtool/web/frame/utils/LogUtil.java +++ b/src/main/java/xyz/wbsite/dbtool/web/frame/utils/LogUtil.java @@ -17,40 +17,44 @@ public class LogUtil { /** * 输出info日志 + * * @param context 日志内容 */ - public static void i(String context){ + public static void i(String context) { logger.info(context); } /** * 输出debug日志 + * * @param context 日志内容 */ - public static void d(String context){ + public static void d(String context) { logger.debug(context); } /** * 输出warn日志 + * * @param context 日志内容 */ - public static void w(String context){ + public static void w(String context) { logger.warn(context); } /** * 输出error日志 + * * @param context 日志内容 */ - public static void e(String context){ + public static void e(String context) { logger.error(context); } /** * 获取异常详细堆栈信息 */ - public static void dumpException(Throwable e){ + public static void dumpException(Throwable e) { StringBuffer msg = new StringBuffer("null"); if (e != null) { msg = new StringBuffer(""); diff --git a/src/main/java/xyz/wbsite/dbtool/web/frame/utils/MD5Util.java b/src/main/java/xyz/wbsite/dbtool/web/frame/utils/MD5Util.java index 26871221..54679ae7 100644 --- a/src/main/java/xyz/wbsite/dbtool/web/frame/utils/MD5Util.java +++ b/src/main/java/xyz/wbsite/dbtool/web/frame/utils/MD5Util.java @@ -1,9 +1,7 @@ package xyz.wbsite.dbtool.web.frame.utils; -import com.fasterxml.jackson.core.TreeNode; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; -import java.util.Iterator; /** * MD5Util - MD5工具类 diff --git a/src/main/java/xyz/wbsite/dbtool/web/frame/utils/MapperUtil.java b/src/main/java/xyz/wbsite/dbtool/web/frame/utils/MapperUtil.java index 51bcba39..34a7a0f0 100644 --- a/src/main/java/xyz/wbsite/dbtool/web/frame/utils/MapperUtil.java +++ b/src/main/java/xyz/wbsite/dbtool/web/frame/utils/MapperUtil.java @@ -4,9 +4,14 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.TreeNode; import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; import org.dozer.DozerBeanMapper; import org.dozer.Mapper; + import java.io.IOException; import java.io.InputStream; import java.util.List; @@ -32,7 +37,7 @@ public class MapperUtil { //反序列化是忽略多余字段 om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); //支持空类序列化时出错InvalidDefinitionException - om.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS,false); + om.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); mapper = new DozerBeanMapper(); } diff --git a/src/main/java/xyz/wbsite/dbtool/web/frame/utils/ProcessUtil.java b/src/main/java/xyz/wbsite/dbtool/web/frame/utils/ProcessUtil.java index 6deffa11..110faed5 100644 --- a/src/main/java/xyz/wbsite/dbtool/web/frame/utils/ProcessUtil.java +++ b/src/main/java/xyz/wbsite/dbtool/web/frame/utils/ProcessUtil.java @@ -1,8 +1,6 @@ package xyz.wbsite.dbtool.web.frame.utils; -import java.awt.*; import java.io.BufferedReader; -import java.io.File; import java.io.IOException; import java.io.InputStreamReader; @@ -16,6 +14,7 @@ import java.io.InputStreamReader; public class ProcessUtil { /** * 启动windows系统下的exe文件 + * * @param path 可执行exe文件路径 */ public static void execExe(String path) { @@ -30,6 +29,7 @@ public class ProcessUtil { /** * 执行windows批处理文件路 + * * @param path 可执行批处理文件路径 */ public static void execBat(String path) { @@ -44,6 +44,7 @@ public class ProcessUtil { /** * 执行windows cmd命令 + * * @param command cmd命令 */ public static String execCmd(String command) { @@ -53,6 +54,7 @@ public class ProcessUtil { /** * 执行运行环境命令 + * * @param command cmd命令 */ public static String exec(String command) { diff --git a/src/main/java/xyz/wbsite/dbtool/web/frame/utils/RSAUtil.java b/src/main/java/xyz/wbsite/dbtool/web/frame/utils/RSAUtil.java index 45e0902c..3115777a 100644 --- a/src/main/java/xyz/wbsite/dbtool/web/frame/utils/RSAUtil.java +++ b/src/main/java/xyz/wbsite/dbtool/web/frame/utils/RSAUtil.java @@ -3,7 +3,13 @@ package xyz.wbsite.dbtool.web.frame.utils; import javax.crypto.Cipher; import java.io.ByteArrayOutputStream; import java.io.UnsupportedEncodingException; -import java.security.*; +import java.security.KeyFactory; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.NoSuchAlgorithmException; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.security.Signature; import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPublicKey; import java.security.spec.InvalidKeySpecException; diff --git a/src/main/java/xyz/wbsite/dbtool/web/frame/utils/ValidationUtil.java b/src/main/java/xyz/wbsite/dbtool/web/frame/utils/ValidationUtil.java index 0de96ca5..98e23630 100644 --- a/src/main/java/xyz/wbsite/dbtool/web/frame/utils/ValidationUtil.java +++ b/src/main/java/xyz/wbsite/dbtool/web/frame/utils/ValidationUtil.java @@ -3,18 +3,12 @@ package xyz.wbsite.dbtool.web.frame.utils; import xyz.wbsite.dbtool.web.frame.base.BaseRequest; import xyz.wbsite.dbtool.web.frame.base.BaseResponse; import xyz.wbsite.dbtool.web.frame.base.ErrorType; + import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.Validator; import javax.validation.ValidatorFactory; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; /** * 验证工具类。提供一些通用简单的数据验证功能 diff --git a/src/main/java/xyz/wbsite/dbtool/web/frame/utils/WebUtils.java b/src/main/java/xyz/wbsite/dbtool/web/frame/utils/WebUtils.java index 5b65fb96..e1ef2b22 100644 --- a/src/main/java/xyz/wbsite/dbtool/web/frame/utils/WebUtils.java +++ b/src/main/java/xyz/wbsite/dbtool/web/frame/utils/WebUtils.java @@ -1,7 +1,16 @@ package xyz.wbsite.dbtool.web.frame.utils; -import javax.net.ssl.*; -import java.io.*; +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.Reader; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLDecoder; diff --git a/src/main/java/xyz/wbsite/dbtool/web/frame/utils/ZipUtil.java b/src/main/java/xyz/wbsite/dbtool/web/frame/utils/ZipUtil.java index b102c54f..5aebcde4 100644 --- a/src/main/java/xyz/wbsite/dbtool/web/frame/utils/ZipUtil.java +++ b/src/main/java/xyz/wbsite/dbtool/web/frame/utils/ZipUtil.java @@ -1,6 +1,10 @@ package xyz.wbsite.dbtool.web.frame.utils; -import java.io.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; import java.util.Enumeration; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; diff --git a/src/main/java/xyz/wbsite/dbtool/web/frame/validation/Dict.java b/src/main/java/xyz/wbsite/dbtool/web/frame/validation/Dict.java index f906ce9e..c54ecf5a 100644 --- a/src/main/java/xyz/wbsite/dbtool/web/frame/validation/Dict.java +++ b/src/main/java/xyz/wbsite/dbtool/web/frame/validation/Dict.java @@ -2,7 +2,10 @@ package xyz.wbsite.dbtool.web.frame.validation; import javax.validation.Constraint; import javax.validation.Payload; -import java.lang.annotation.*; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; @Target({ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) diff --git a/src/test/TestConnect.java b/src/test/TestConnect.java index b3d0b525..e921b7bf 100644 --- a/src/test/TestConnect.java +++ b/src/test/TestConnect.java @@ -1,4 +1,5 @@ import xyz.wbsite.dbtool.javafx.manger.ProjectManager; + import java.util.HashMap; public class TestConnect {