Former-commit-id: b691d608a5767d4945af345de028238c50a081c9
master
wangbingit@outlook.com 5 years ago
parent 057f3ddb9f
commit bd70252646

@ -1,15 +1,12 @@
package xyz.wbsite.dbtool; package xyz.wbsite.dbtool;
import xyz.wbsite.dbtool.javafx.JavaFxApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; 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.io.FileNotFoundException;
import java.net.URL;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;

@ -57,16 +57,16 @@ import java.util.List;
public class JavaFxApplication extends Application { public class JavaFxApplication extends Application {
private ProjectManager dBmanger = ManagerFactory.getProjectManager(); private ProjectManager dBmanager = ManagerFactory.getProjectManager();
private TreeView mdtree = null; private TreeView mTree = null;
private Pane detail = null; private Pane mDetail = null;
private TableView feilds = null; private TableView mFields = null;
private Button add = null; private Button add = null;
private Button sub = null; private Button sub = null;
private FXMLLoader mainloader; private FXMLLoader mMainLoader;
private FXMLLoader projectdetailloader; private FXMLLoader mProjectLoader;
private FXMLLoader mddetailloader; private FXMLLoader mModuleLoader;
private FXMLLoader tabledetailloader; private FXMLLoader mTableLoader;
private MainController mainController; private MainController mainController;
private DetailProjectController detailProjectController; private DetailProjectController detailProjectController;
private DetailModuleController mdDetailController; private DetailModuleController mdDetailController;
@ -83,7 +83,7 @@ public class JavaFxApplication extends Application {
@Override @Override
public void start(Stage primaryStage) throws Exception { public void start(Stage primaryStage) throws Exception {
BorderPane root = mainloader.getRoot(); BorderPane root = mMainLoader.getRoot();
primaryStage.setTitle("DBtool"); primaryStage.setTitle("DBtool");
primaryStage.setScene(new Scene(root, 700, 500)); primaryStage.setScene(new Scene(root, 700, 500));
@ -105,15 +105,15 @@ public class JavaFxApplication extends Application {
if (main == null) { if (main == null) {
main = getClass().getResource("../../../fxml/main.fxml"); main = getClass().getResource("../../../fxml/main.fxml");
} }
mainloader = new FXMLLoader(main); mMainLoader = new FXMLLoader(main);
mainloader.load(); mMainLoader.load();
mainController = mainloader.getController(); mainController = mMainLoader.getController();
mainController.setMain(this); mainController.setMain(this);
mdtree = mainController.getDbtree(); mTree = mainController.getDbtree();
detail = mainController.getDetail(); mDetail = mainController.getDetail();
feilds = mainController.getFeilds(); mFields = mainController.getFeilds();
feilds.setEditable(true); mFields.setEditable(true);
feilds.setSortPolicy(new Callback<TableView, Boolean>() { mFields.setSortPolicy(new Callback<TableView, Boolean>() {
@Override @Override
public Boolean call(TableView param) { public Boolean call(TableView param) {
//禁止点击列头排序 //禁止点击列头排序
@ -140,7 +140,7 @@ public class JavaFxApplication extends Application {
@Override @Override
public void handle(ActionEvent event) { public void handle(ActionEvent event) {
MenuItem target = (MenuItem) event.getTarget(); MenuItem target = (MenuItem) event.getTarget();
int index = feilds.getSelectionModel().getSelectedIndex(); int index = mFields.getSelectionModel().getSelectedIndex();
List<Field> fields = currentTable.getFields(); List<Field> fields = currentTable.getFields();
if ("新增".equals(target.getText())) { if ("新增".equals(target.getText())) {
@ -170,11 +170,11 @@ public class JavaFxApplication extends Application {
break; break;
} }
loadingTable(); loadingTable();
feilds.getSelectionModel().clearSelection(); JavaFxApplication.this.mFields.getSelectionModel().clearSelection();
} }
} }
}); });
feilds.setContextMenu(con); mFields.setContextMenu(con);
project_menu = new ContextMenu(new MenuItem("新增模块")); project_menu = new ContextMenu(new MenuItem("新增模块"));
md_right_menu = new ContextMenu(new MenuItem("新增对象"), new MenuItem("删除模块"), new MenuItem("向上调整"), 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) { if (projectdetail == null) {
projectdetail = getClass().getResource("../../../fxml/projectdetail.fxml"); projectdetail = getClass().getResource("../../../fxml/projectdetail.fxml");
} }
projectdetailloader = new FXMLLoader(projectdetail); mProjectLoader = new FXMLLoader(projectdetail);
projectdetailloader.load(); mProjectLoader.load();
detailProjectController = projectdetailloader.getController(); detailProjectController = mProjectLoader.getController();
URL mddetail = JavaFxApplication.class.getClassLoader().getResource("fxml/moduledetail.fxml"); URL mddetail = JavaFxApplication.class.getClassLoader().getResource("fxml/moduledetail.fxml");
if (mddetail == null) { if (mddetail == null) {
mddetail = getClass().getResource("../../../fxml/moduledetail.fxml"); mddetail = getClass().getResource("../../../fxml/moduledetail.fxml");
} }
mddetailloader = new FXMLLoader(mddetail); mModuleLoader = new FXMLLoader(mddetail);
mddetailloader.load(); mModuleLoader.load();
mdDetailController = mddetailloader.getController(); mdDetailController = mModuleLoader.getController();
URL tabledetail = JavaFxApplication.class.getClassLoader().getResource("fxml/tabledetail.fxml"); URL tabledetail = JavaFxApplication.class.getClassLoader().getResource("fxml/tabledetail.fxml");
if (tabledetail == null) { if (tabledetail == null) {
tabledetail = getClass().getResource("../../../fxml/tabledetail.fxml"); tabledetail = getClass().getResource("../../../fxml/tabledetail.fxml");
} }
tabledetailloader = new FXMLLoader(tabledetail); mTableLoader = new FXMLLoader(tabledetail);
tabledetailloader.load(); mTableLoader.load();
detailTableController = tabledetailloader.getController(); detailTableController = mTableLoader.getController();
mdtree.setShowRoot(true); mTree.setShowRoot(true);
mdtree.setEditable(true); mTree.setEditable(true);
mdtree.setDisable(false); mTree.setDisable(false);
mdtree.setCellFactory(new Callback<TreeView, TreeCell>() { mTree.setCellFactory(new Callback<TreeView, TreeCell>() {
@Override @Override
public TreeCell call(TreeView param) { public TreeCell call(TreeView param) {
TextFieldTreeCell textFieldTreeCell = new TextFieldTreeCell(new DefaultStringConverter()); TextFieldTreeCell textFieldTreeCell = new TextFieldTreeCell(new DefaultStringConverter());
@ -224,7 +224,7 @@ public class JavaFxApplication extends Application {
public void handle(MouseEvent event) { public void handle(MouseEvent event) {
TextFieldTreeCell source = (TextFieldTreeCell) event.getSource(); TextFieldTreeCell source = (TextFieldTreeCell) event.getSource();
String text = source.getText(); String text = source.getText();
Module dbByDBName = dBmanger.findDBByDBName(text); Module dbByDBName = dBmanager.findDBByDBName(text);
if (dbByDBName != null) { if (dbByDBName != null) {
dragMD = true; dragMD = true;
} else { } else {
@ -248,7 +248,7 @@ public class JavaFxApplication extends Application {
Dragboard md = event.getDragboard(); Dragboard md = event.getDragboard();
TextFieldTreeCell source = (TextFieldTreeCell) event.getSource(); TextFieldTreeCell source = (TextFieldTreeCell) event.getSource();
Module dbByDBName = dBmanger.findDBByDBName(source.getText()); Module dbByDBName = dBmanager.findDBByDBName(source.getText());
if (dragMD && dbByDBName != null) { if (dragMD && dbByDBName != null) {
double y = event.getY(); double y = event.getY();
@ -284,7 +284,7 @@ public class JavaFxApplication extends Application {
String m2 = ((TreeCell<String>) event.getGestureTarget()).getItem(); String m2 = ((TreeCell<String>) event.getGestureTarget()).getItem();
if (dragMD) { if (dragMD) {
List<Module> mds = dBmanger.getMds(); List<Module> mds = dBmanager.getMds();
int i1 = 0, i2 = 0; int i1 = 0, i2 = 0;
for (int i = 0; i < mds.size(); i++) { for (int i = 0; i < mds.size(); i++) {
@ -346,19 +346,19 @@ public class JavaFxApplication extends Application {
} }
event.setDropCompleted(true); event.setDropCompleted(true);
event.consume(); event.consume();
mdtree.getSelectionModel().clearSelection(); mTree.getSelectionModel().clearSelection();
int focusedIndex = mdtree.getFocusModel().getFocusedIndex(); int focusedIndex = mTree.getFocusModel().getFocusedIndex();
System.out.println(focusedIndex); System.out.println(focusedIndex);
} }
}); });
return textFieldTreeCell; return textFieldTreeCell;
} }
}); });
mdtree.setOnEditCommit(new YEventHandler()); mTree.setOnEditCommit(new YEventHandler());
mdtree.setOnMouseClicked(new EventHandler<MouseEvent>() { mTree.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override @Override
public void handle(MouseEvent event) { public void handle(MouseEvent event) {
TreeItem targetItem = (TreeItem) mdtree.getSelectionModel().getSelectedItem(); TreeItem targetItem = (TreeItem) mTree.getSelectionModel().getSelectedItem();
if (targetItem == null) if (targetItem == null)
return; return;
@ -367,24 +367,24 @@ public class JavaFxApplication extends Application {
switch (level) { switch (level) {
case 0: {//查看模块 case 0: {//查看模块
mdtree.setContextMenu(project_menu); mTree.setContextMenu(project_menu);
loadingProject(); loadingProject();
} }
break; break;
case 1: {//查看模块 case 1: {//查看模块
mdtree.setContextMenu(md_right_menu); mTree.setContextMenu(md_right_menu);
currentMD = dBmanger.findDBByDBName((String) targetItem.getValue()); currentMD = dBmanager.findDBByDBName((String) targetItem.getValue());
currentTable = null; currentTable = null;
loadingModule(); loadingModule();
} }
break; break;
case 2: {//查看对象 case 2: {//查看对象
mdtree.setContextMenu(table_right_menu); mTree.setContextMenu(table_right_menu);
TreeItem parent = targetItem.getParent(); TreeItem parent = targetItem.getParent();
currentMD = dBmanger.findDBByDBName((String) parent.getValue()); currentMD = dBmanager.findDBByDBName((String) parent.getValue());
if (currentMD != null) { if (currentMD != null) {
currentTable = dBmanger.findTableByTableName(currentMD, (String) targetItem.getValue()); currentTable = dBmanager.findTableByTableName(currentMD, (String) targetItem.getValue());
} }
loadingTable(); loadingTable();
break; break;
@ -533,21 +533,21 @@ public class JavaFxApplication extends Application {
} }
private void addField() { private void addField() {
if (currentTable != null && feilds != null) { if (currentTable != null && mFields != null) {
List<Field> fields = currentTable.getFields(); List<Field> fields = currentTable.getFields();
String fieldName = dBmanger.getNewFieldName(fields); String fieldName = dBmanager.getNewFieldName(fields);
System.out.println("新增字段-" + fieldName + "成功!"); System.out.println("新增字段-" + fieldName + "成功!");
feilds.getSelectionModel().select(fields.size() - 1); this.mFields.getSelectionModel().select(fields.size() - 1);
loadingTable(); loadingTable();
} }
} }
private void subField() { private void subField() {
if (currentTable != null) { if (currentTable != null) {
int selectedIndex = feilds.getSelectionModel().getSelectedIndex(); int selectedIndex = mFields.getSelectionModel().getSelectedIndex();
if (selectedIndex > -1 && !currentTable.getFields().get(selectedIndex).getIsSystem()) { if (selectedIndex > -1 && !currentTable.getFields().get(selectedIndex).getIsSystem()) {
currentTable.getFields().remove(selectedIndex); currentTable.getFields().remove(selectedIndex);
feilds.getSelectionModel().clearSelection(); mFields.getSelectionModel().clearSelection();
loadingTable(); loadingTable();
} }
@ -555,11 +555,11 @@ public class JavaFxApplication extends Application {
} }
public void loadingProjectTree() { public void loadingProjectTree() {
currentProject = dBmanger.getProject(); currentProject = dBmanager.getProject();
currentProject.setValue(currentProject.getProjectName()); currentProject.setValue(currentProject.getProjectName());
currentProject.setExpanded(true); currentProject.setExpanded(true);
mdtree.setRoot(currentProject); mTree.setRoot(currentProject);
for (int i = 0; i < currentProject.getModules().size(); i++) { for (int i = 0; i < currentProject.getModules().size(); i++) {
Module module = currentProject.getModules().get(i); Module module = currentProject.getModules().get(i);
@ -574,7 +574,7 @@ public class JavaFxApplication extends Application {
} }
private int getLevel(TreeItem treeItem) { private int getLevel(TreeItem treeItem) {
TreeItem root = mdtree.getRoot(); TreeItem root = mTree.getRoot();
int level = 0; int level = 0;
if (treeItem == root) { if (treeItem == root) {
level = 0; level = 0;
@ -591,22 +591,22 @@ public class JavaFxApplication extends Application {
return; return;
} }
GridPane gridPane = mddetailloader.getRoot(); GridPane gridPane = mModuleLoader.getRoot();
mdDetailController.getModuleComment().setText(currentMD.getModuleComment()); mdDetailController.getModuleComment().setText(currentMD.getModuleComment());
mdDetailController.getModulePrefix().setText(currentMD.getModulePrefix()); mdDetailController.getModulePrefix().setText(currentMD.getModulePrefix());
mdDetailController.getModuleName().setText(currentMD.getModuleName()); mdDetailController.getModuleName().setText(currentMD.getModuleName());
if (gridPane != null) { if (gridPane != null) {
detail.getChildren().clear(); mDetail.getChildren().clear();
detail.getChildren().add(gridPane); mDetail.getChildren().add(gridPane);
} }
if (feilds != null && feilds.getItems() != null) { if (mFields != null && mFields.getItems() != null) {
feilds.getItems().clear(); mFields.getItems().clear();
} }
} }
public void loadingProject() { public void loadingProject() {
GridPane gridPane = projectdetailloader.getRoot(); GridPane gridPane = mProjectLoader.getRoot();
detailProjectController.getProjectName().setText(currentProject.getProjectName()); detailProjectController.getProjectName().setText(currentProject.getProjectName());
detailProjectController.getProjectBasePackage().setText(currentProject.getProjectBasePackage()); detailProjectController.getProjectBasePackage().setText(currentProject.getProjectBasePackage());
detailProjectController.getProjectAuthor().setText(currentProject.getProjectAuthor()); detailProjectController.getProjectAuthor().setText(currentProject.getProjectAuthor());
@ -614,11 +614,11 @@ public class JavaFxApplication extends Application {
detailProjectController.getSysMD().setSelected(currentProject.getSysMD()); detailProjectController.getSysMD().setSelected(currentProject.getSysMD());
if (gridPane != null) { if (gridPane != null) {
detail.getChildren().clear(); mDetail.getChildren().clear();
detail.getChildren().add(gridPane); mDetail.getChildren().add(gridPane);
} }
if (feilds != null && feilds.getItems() != null) { if (mFields != null && mFields.getItems() != null) {
feilds.getItems().clear(); mFields.getItems().clear();
} }
} }
@ -626,7 +626,7 @@ public class JavaFxApplication extends Application {
* *
*/ */
private void loadingTable() { private void loadingTable() {
GridPane gridPane = tabledetailloader.getRoot(); GridPane gridPane = mTableLoader.getRoot();
if (currentTable != null) { if (currentTable != null) {
detailTableController.getTablename().setText(currentTable.getTableName()); detailTableController.getTablename().setText(currentTable.getTableName());
detailTableController.getTablecomment().setText(currentTable.getTableComment()); detailTableController.getTablecomment().setText(currentTable.getTableComment());
@ -641,10 +641,10 @@ public class JavaFxApplication extends Application {
} }
if (gridPane != null) { if (gridPane != null) {
detail.getChildren().clear(); mDetail.getChildren().clear();
detail.getChildren().add(gridPane); mDetail.getChildren().add(gridPane);
} }
ObservableList<TableColumn> columns = feilds.getColumns(); ObservableList<TableColumn> columns = mFields.getColumns();
columns.get(0).setCellValueFactory(new PropertyValueFactory<Field, String>("fieldName")); columns.get(0).setCellValueFactory(new PropertyValueFactory<Field, String>("fieldName"));
columns.get(0).setCellFactory(new Callback<TableColumn, TableCell>() { columns.get(0).setCellFactory(new Callback<TableColumn, TableCell>() {
@Override @Override
@ -794,7 +794,7 @@ public class JavaFxApplication extends Application {
FieldType fieldType = field.getFieldType(); FieldType fieldType = field.getFieldType();
if (fieldType.isFix() && fieldType.getDefaultLength() != field.getFieldLength()) { if (fieldType.isFix() && fieldType.getDefaultLength() != field.getFieldLength()) {
field.setFieldLength(fieldType.getDefaultLength()); field.setFieldLength(fieldType.getDefaultLength());
feilds.refresh(); mFields.refresh();
} }
if (field.getIsSystem()) { if (field.getIsSystem()) {
ignoreField(this); ignoreField(this);
@ -819,7 +819,7 @@ public class JavaFxApplication extends Application {
FieldType newValue = (FieldType) event.getNewValue(); FieldType newValue = (FieldType) event.getNewValue();
field.setFieldLength(newValue.getDefaultLength()); field.setFieldLength(newValue.getDefaultLength());
field.setFieldType(newValue); field.setFieldType(newValue);
feilds.refresh(); mFields.refresh();
} }
}); });
return choiceBoxTableCell; return choiceBoxTableCell;
@ -841,7 +841,7 @@ public class JavaFxApplication extends Application {
e.printStackTrace(); e.printStackTrace();
} }
} }
feilds.refresh(); mFields.refresh();
} }
}); });
TextFieldTableCell textFieldTableCell = new TextFieldTableCell(new IntegerStringConverter()) { TextFieldTableCell textFieldTableCell = new TextFieldTableCell(new IntegerStringConverter()) {
@ -1079,7 +1079,7 @@ public class JavaFxApplication extends Application {
data.addAll(fields); data.addAll(fields);
} }
feilds.setItems(data); mFields.setItems(data);
} }
void ignoreField(TableCell tableCell) { void ignoreField(TableCell tableCell) {
@ -1105,20 +1105,20 @@ public class JavaFxApplication extends Application {
switch (level) { switch (level) {
case 0: {//编辑项目名称 case 0: {//编辑项目名称
dBmanger.getProject().setProjectName((String) event.getNewValue()); dBmanager.getProject().setProjectName((String) event.getNewValue());
loadingProject(); loadingProject();
} }
break; break;
case 1: {//编辑模块 case 1: {//编辑模块
Module md = dBmanger.findDBByDBName((String) event.getOldValue()); Module md = dBmanager.findDBByDBName((String) event.getOldValue());
md.setModuleName((String) event.getNewValue()); md.setModuleName((String) event.getNewValue());
loadingModule(); loadingModule();
} }
break; break;
case 2: {//编辑对象 case 2: {//编辑对象
TreeItem parent = treeItem.getParent(); TreeItem parent = treeItem.getParent();
Module md = dBmanger.findDBByDBName((String) parent.getValue()); Module md = dBmanager.findDBByDBName((String) parent.getValue());
Table table = dBmanger.findTableByTableName(md, (String) event.getOldValue()); Table table = dBmanager.findTableByTableName(md, (String) event.getOldValue());
if (table != null) { if (table != null) {
table.setTableName((String) event.getNewValue()); table.setTableName((String) event.getNewValue());
loadingTable(); loadingTable();
@ -1141,40 +1141,40 @@ public class JavaFxApplication extends Application {
MenuItem target = (MenuItem) event.getTarget(); MenuItem target = (MenuItem) event.getTarget();
String text = target.getText(); 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; int index = -1;
index = mdtree.getFocusModel().getFocusedIndex(); index = mTree.getFocusModel().getFocusedIndex();
if (targetItem == null) { if (targetItem == null) {
targetItem = (TreeItem) mdtree.getSelectionModel().getSelectedItem(); targetItem = (TreeItem) mTree.getSelectionModel().getSelectedItem();
} }
if (index == -1) { if (index == -1) {
index = mdtree.getSelectionModel().getSelectedIndex(); index = mTree.getSelectionModel().getSelectedIndex();
} }
if (text != null && targetItem != null) { if (text != null && targetItem != null) {
switch (text) { switch (text) {
case "向上调整": case "向上调整":
if (index > 0) { if (index > 0) {
Tool.exchange(dBmanger.getProject().getModules(), index - 1, index); Tool.exchange(dBmanager.getProject().getModules(), index - 1, index);
Tool.exchange(dBmanger.getProject().getChildren(), index - 1, index); Tool.exchange(dBmanager.getProject().getChildren(), index - 1, index);
} }
break; break;
case "向下调整": case "向下调整":
List<Module> mds = dBmanger.getMds(); List<Module> mds = dBmanager.getMds();
if (index < mds.size() - 1) { if (index < mds.size() - 1) {
Tool.exchange(dBmanger.getProject().getModules(), index, index + 1); Tool.exchange(dBmanager.getProject().getModules(), index, index + 1);
Tool.exchange(dBmanger.getProject().getChildren(), index, index + 1); Tool.exchange(dBmanager.getProject().getChildren(), index, index + 1);
} }
break; break;
case "新增模块": case "新增模块":
dBmanger.getNewModuleName(); dBmanager.getNewModuleName();
break; break;
case "删除模块": case "删除模块":
if (targetItem != null && targetItem.getParent() == project) { if (targetItem != null && targetItem.getParent() == project) {
currentProject.getChildren().remove(targetItem); currentProject.getChildren().remove(targetItem);
boolean b = dBmanger.removeDBByDBName((String) targetItem.getValue()); boolean b = dBmanager.removeDBByDBName((String) targetItem.getValue());
if (b) { if (b) {
System.out.println("删除模块" + targetItem.getValue() + "成功!"); System.out.println("删除模块" + targetItem.getValue() + "成功!");
} }
@ -1186,9 +1186,9 @@ public class JavaFxApplication extends Application {
switch (level) { switch (level) {
case 1: {//对模块右击 case 1: {//对模块右击
System.out.println("模块:" + targetItem.getValue()); System.out.println("模块:" + targetItem.getValue());
Module md = dBmanger.findDBByDBName((String) targetItem.getValue()); Module md = dBmanager.findDBByDBName((String) targetItem.getValue());
if (md != null) { if (md != null) {
Table newTableName = dBmanger.getNewTableName(md); Table newTableName = dBmanager.getNewTableName(md);
targetItem.getChildren().add(newTableName); targetItem.getChildren().add(newTableName);
} }
} }
@ -1196,8 +1196,8 @@ public class JavaFxApplication extends Application {
case 2: {//对对象右击 case 2: {//对对象右击
TreeItem parent = targetItem.getParent(); TreeItem parent = targetItem.getParent();
System.out.println("对象:" + parent.getValue()); System.out.println("对象:" + parent.getValue());
Module md = dBmanger.findDBByDBName((String) parent.getValue()); Module md = dBmanager.findDBByDBName((String) parent.getValue());
Table newTableName = dBmanger.getNewTableName(md); Table newTableName = dBmanager.getNewTableName(md);
parent.getChildren().add(new TreeItem<>(newTableName.getTableName())); parent.getChildren().add(new TreeItem<>(newTableName.getTableName()));
break; break;
} }
@ -1215,15 +1215,15 @@ public class JavaFxApplication extends Application {
switch (level) { switch (level) {
case 0: {//对模块右击 case 0: {//对模块右击
System.out.println("模块:" + targetItem.getValue()); System.out.println("模块:" + targetItem.getValue());
Module md = dBmanger.findDBByDBName((String) targetItem.getValue()); Module md = dBmanager.findDBByDBName((String) targetItem.getValue());
Table newTableName = dBmanger.getNewTableName(md); Table newTableName = dBmanager.getNewTableName(md);
targetItem.getChildren().add(new TreeItem<>(newTableName.getTableName())); targetItem.getChildren().add(new TreeItem<>(newTableName.getTableName()));
} }
break; break;
case 1: {//对对象右击 case 1: {//对对象右击
TreeItem parent = targetItem.getParent(); TreeItem parent = targetItem.getParent();
System.out.println("对象:" + parent.getValue()); System.out.println("对象:" + parent.getValue());
Module md = dBmanger.findDBByDBName((String) parent.getValue()); Module md = dBmanager.findDBByDBName((String) parent.getValue());
for (Table table : md.getTables()) { for (Table table : md.getTables()) {
if (table.getTableName().equals(targetItem.getValue())) { if (table.getTableName().equals(targetItem.getValue())) {
@ -1243,7 +1243,7 @@ public class JavaFxApplication extends Application {
} else if (text != null && targetItem == null) { } else if (text != null && targetItem == null) {
switch (text) { switch (text) {
case "新增模块": case "新增模块":
dBmanger.getNewModuleName(); dBmanager.getNewModuleName();
break; break;
default: default:
break; break;
@ -1253,7 +1253,7 @@ public class JavaFxApplication extends Application {
} }
private void updateDbTree(List<Module> mds) { private void updateDbTree(List<Module> mds) {
TreeItem root = mdtree.getRoot(); TreeItem root = mTree.getRoot();
for (Module md : mds) { for (Module md : mds) {
TreeItem<String> treeItem = new TreeItem<>(md.getModuleName()); TreeItem<String> treeItem = new TreeItem<>(md.getModuleName());
treeItem.setExpanded(true); treeItem.setExpanded(true);

@ -200,6 +200,7 @@ public class MainController {
public void generateAndroid(ActionEvent actionEvent) { public void generateAndroid(ActionEvent actionEvent) {
Dialog.showAndroid(); Dialog.showAndroid();
} }
@FXML @FXML
public void generateSBMDB(ActionEvent actionEvent) { public void generateSBMDB(ActionEvent actionEvent) {
Dialog.showSBMDB(); Dialog.showSBMDB();

@ -2,7 +2,6 @@ package xyz.wbsite.dbtool.javafx.ctrl;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
public class OptionAndroidController { public class OptionAndroidController {

@ -6,7 +6,12 @@ import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.fxml.FXML; 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.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell; import javafx.scene.control.cell.TextFieldTableCell;
import javafx.util.Callback; 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.tool.Tool;
import xyz.wbsite.dbtool.javafx.view.DBCheckBoxTableCell; 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.ArrayList;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;

@ -1,11 +1,11 @@
package xyz.wbsite.dbtool.javafx.ctrl; package xyz.wbsite.dbtool.javafx.ctrl;
import xyz.wbsite.dbtool.javafx.listener.GenerateOptionListener;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.control.CheckBox; import javafx.scene.control.CheckBox;
import javafx.scene.control.RadioButton; import javafx.scene.control.RadioButton;
import javafx.scene.control.ToggleGroup; import javafx.scene.control.ToggleGroup;
import xyz.wbsite.dbtool.javafx.listener.GenerateOptionListener;
public class OptionMainController { public class OptionMainController {

@ -2,8 +2,6 @@ package xyz.wbsite.dbtool.javafx.ctrl;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup; import javafx.scene.control.ToggleGroup;
public class OptionVueController { public class OptionVueController {

@ -3,5 +3,5 @@ package xyz.wbsite.dbtool.javafx.listener;
import xyz.wbsite.dbtool.javafx.enums.DataBase; import xyz.wbsite.dbtool.javafx.enums.DataBase;
public interface GenerateOptionListener { public interface GenerateOptionListener {
void onGenerate(String option,DataBase dataBase); void onGenerate(String option, DataBase dataBase);
} }

@ -1,19 +1,20 @@
package xyz.wbsite.dbtool.javafx.manger; package xyz.wbsite.dbtool.javafx.manger;
import freemarker.cache.*; import freemarker.cache.ClassTemplateLoader;
import freemarker.template.*; import freemarker.cache.MultiTemplateLoader;
import org.springframework.core.io.DefaultResourceLoader; import freemarker.cache.TemplateLoader;
import org.springframework.core.io.Resource; import freemarker.template.Configuration;
import org.springframework.core.io.ResourceLoader; import freemarker.template.Template;
import org.springframework.lang.Nullable; import freemarker.template.TemplateException;
import org.springframework.ui.freemarker.SpringTemplateLoader; import freemarker.template.TemplateExceptionHandler;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer; import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
import org.springframework.web.util.UriTemplate;
import java.io.*; import java.io.File;
import java.net.URL; import java.io.FileOutputStream;
import java.util.Properties; import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
public class FreeMarkerManager { public class FreeMarkerManager {
private FreeMarkerConfigurer freeMarkerConfigurer; private FreeMarkerConfigurer freeMarkerConfigurer;
@ -47,7 +48,7 @@ public class FreeMarkerManager {
//获取ftl,由于已经在配置文件中配置了路径所以在这里直接写模板名称就可以 //获取ftl,由于已经在配置文件中配置了路径所以在这里直接写模板名称就可以
Template temp = configuration.getTemplate(template); 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); temp.process(model, wr);
//关闭流 //关闭流

@ -4,7 +4,7 @@ import xyz.wbsite.dbtool.javafx.JavaFxApplication;
public class ManagerFactory { public class ManagerFactory {
private static XmlManager xmlManager = null; private static XmlManager xmlManager = null;
private static ReflashManager reflashManager =null; private static ReflashManager reflashManager = null;
private static ProjectManager projectManager; private static ProjectManager projectManager;
private static FreeMarkerManager freeMarkerManager; private static FreeMarkerManager freeMarkerManager;
@ -28,7 +28,7 @@ public class ManagerFactory {
} }
public static ReflashManager getReflashManager(JavaFxApplication main) { public static ReflashManager getReflashManager(JavaFxApplication main) {
if (reflashManager == null){ if (reflashManager == null) {
reflashManager = new ReflashManager(main); reflashManager = new ReflashManager(main);
} }
return reflashManager; return reflashManager;

@ -2,7 +2,7 @@ package xyz.wbsite.dbtool.javafx.manger;
import xyz.wbsite.dbtool.javafx.JavaFxApplication; import xyz.wbsite.dbtool.javafx.JavaFxApplication;
public class ReflashManager extends Thread{ public class ReflashManager extends Thread {
private JavaFxApplication main; private JavaFxApplication main;
public ReflashManager(JavaFxApplication main) { public ReflashManager(JavaFxApplication main) {
@ -11,13 +11,13 @@ public class ReflashManager extends Thread{
@Override @Override
public void run() { public void run() {
while (true){ while (true) {
try { try {
Thread.sleep(200); Thread.sleep(200);
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
if (ProjectManager.isUpdate){ if (ProjectManager.isUpdate) {
main.loadingProjectTree(); main.loadingProjectTree();
ProjectManager.isUpdate = false; ProjectManager.isUpdate = false;
} }

@ -193,7 +193,7 @@ public class ApiCallable implements Callable {
ArrayList<Api> apis = new ArrayList<>(); ArrayList<Api> apis = new ArrayList<>();
for (Api api : apiList) { for (Api api : apiList) {
if (m.equals(api.getModule())){ if (m.equals(api.getModule())) {
apis.add(api); apis.add(api);
} }
} }

@ -6,7 +6,7 @@ import xyz.wbsite.dbtool.javafx.enums.FieldType;
public abstract class AbstractDBmapper { public abstract class AbstractDBmapper {
DataBase mDataBase = null; DataBase mDataBase = null;
private AbstractDBmapper(){ private AbstractDBmapper() {
} }
@ -14,11 +14,13 @@ public abstract class AbstractDBmapper {
this.mDataBase = mDataBase; this.mDataBase = mDataBase;
} }
DataBase getDataBase(){ DataBase getDataBase() {
return mDataBase; return mDataBase;
} }
public abstract String getDataBaseType(FieldType type); public abstract String getDataBaseType(FieldType type);
abstract String getFieldSql(Field field); abstract String getFieldSql(Field field);
public abstract FieldType getType(String type, int lenght, int precision, int scale); public abstract FieldType getType(String type, int lenght, int precision, int scale);
} }

@ -1,9 +1,7 @@
package xyz.wbsite.dbtool.javafx.po; package xyz.wbsite.dbtool.javafx.po;
import java.io.File; import java.io.File;
import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Set; import java.util.Set;
public class Api { public class Api {

@ -118,7 +118,7 @@ public class Field extends Table {
value = "(byte)1"; value = "(byte)1";
} else if (fieldType.name().matches("Short")) { } else if (fieldType.name().matches("Short")) {
value = "(short)1"; value = "(short)1";
}else if (fieldType.name().matches("Integer")) { } else if (fieldType.name().matches("Integer")) {
value = "1"; value = "1";
} else if (fieldType.name().matches("Bytes")) { } else if (fieldType.name().matches("Bytes")) {
value = "null"; value = "null";

@ -5,7 +5,7 @@ import javafx.scene.control.TreeItem;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class Project extends TreeItem{ public class Project extends TreeItem {
public Project() { public Project() {
this.projectName = "EXAMPLE-WEB"; this.projectName = "EXAMPLE-WEB";

@ -1,6 +1,10 @@
package xyz.wbsite.dbtool.javafx.tool; 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.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;

@ -1,6 +1,10 @@
package xyz.wbsite.dbtool.javafx.tool; 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.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;

@ -1,6 +1,10 @@
package xyz.wbsite.dbtool.javafx.tool; 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.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -24,7 +28,7 @@ public class ResponseReader {
private String findOrSearchflag = "0"; private String findOrSearchflag = "0";
private String Tclass = null; private String Tclass = null;
public ResponseReader(File javaClass){ public ResponseReader(File javaClass) {
this.javaClass = javaClass; this.javaClass = javaClass;
importList = new ArrayList<>(); importList = new ArrayList<>();
notesList = new ArrayList<>(); notesList = new ArrayList<>();

@ -8,7 +8,13 @@ import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; 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.multipart.MultipartFile;
import org.springframework.web.servlet.DispatcherServlet; import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.LocaleResolver; 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 org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
import xyz.wbsite.dbtool.web.config.ActionConfig; import xyz.wbsite.dbtool.web.config.ActionConfig;
import xyz.wbsite.dbtool.web.frame.auth.LocalData; 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 xyz.wbsite.dbtool.web.frame.utils.MapperUtil;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;

@ -1,7 +1,7 @@
package xyz.wbsite.dbtool.web.action.control; package xyz.wbsite.dbtool.web.action.control;
import xyz.wbsite.dbtool.web.frame.base.Control;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import xyz.wbsite.dbtool.web.frame.base.Control;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;

@ -1,10 +1,11 @@
package xyz.wbsite.dbtool.web.action.screen; package xyz.wbsite.dbtool.web.action.screen;
import xyz.wbsite.dbtool.web.frame.base.Screen;
import org.springframework.ui.Model; 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.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
public class Index extends Screen { public class Index extends Screen {

@ -69,7 +69,7 @@ public class ActionConfig implements BeanDefinitionRegistryPostProcessor {
@Override @Override
public String generateBeanName(BeanDefinition beanDefinition, BeanDefinitionRegistry beanDefinitionRegistry) { public String generateBeanName(BeanDefinition beanDefinition, BeanDefinitionRegistry beanDefinitionRegistry) {
String beanClassName = beanDefinition.getBeanClassName(); 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); LogUtil.i("registry screen " + beamName);
return beamName; return beamName;
} }
@ -92,7 +92,7 @@ public class ActionConfig implements BeanDefinitionRegistryPostProcessor {
@Override @Override
public String generateBeanName(BeanDefinition beanDefinition, BeanDefinitionRegistry beanDefinitionRegistry) { public String generateBeanName(BeanDefinition beanDefinition, BeanDefinitionRegistry beanDefinitionRegistry) {
String beanClassName = beanDefinition.getBeanClassName(); 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); LogUtil.i("registry control " + beamName);
return beamName; return beamName;
} }
@ -115,7 +115,7 @@ public class ActionConfig implements BeanDefinitionRegistryPostProcessor {
if (beanClassName != null && beanClassName.endsWith("Ajax")) { if (beanClassName != null && beanClassName.endsWith("Ajax")) {
beanClassName = beanClassName.substring(0, beanClassName.length() - 4); 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); LogUtil.i("registry ajax " + beamName);
return beamName; return beamName;
} }

@ -1,8 +1,5 @@
package xyz.wbsite.dbtool.web.config; 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.SimpleScalar;
import freemarker.template.TemplateMethodModelEx; import freemarker.template.TemplateMethodModelEx;
import freemarker.template.TemplateModelException; 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.LocaleResolver;
import org.springframework.web.servlet.View; import org.springframework.web.servlet.View;
import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver; 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.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;

@ -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.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.core.Authentication; 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.base.Token;
import xyz.wbsite.dbtool.web.frame.utils.CookieUtil; 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 javax.servlet.http.HttpServletRequest;
import java.io.IOException; import java.io.IOException;
import java.util.regex.Matcher; import java.util.regex.Matcher;

@ -20,10 +20,10 @@ import java.util.concurrent.Executors;
@Configuration @Configuration
@EnableScheduling @EnableScheduling
@Profile("prod") @Profile("prod")
public class TaskConfig implements SchedulingConfigurer { public class TaskConfig implements SchedulingConfigurer {
@Scheduled(cron="0/30 * * * * ? ") @Scheduled(cron = "0/30 * * * * ? ")
public void task(){ public void task() {
// todo 自定实现的定时任务 // todo 自定实现的定时任务
SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss"); SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
HashMap<String, String> data = new HashMap<>(); HashMap<String, String> data = new HashMap<>();

@ -1,10 +1,10 @@
package xyz.wbsite.dbtool.web.frame.auth; package xyz.wbsite.dbtool.web.frame.auth;
import xyz.wbsite.dbtool.web.frame.base.Token;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.support.WebApplicationContextUtils; import org.springframework.web.context.support.WebApplicationContextUtils;
import xyz.wbsite.dbtool.web.frame.base.Token;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;

@ -1,6 +1,7 @@
package xyz.wbsite.dbtool.web.frame.base; package xyz.wbsite.dbtool.web.frame.base;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
@ -43,8 +44,8 @@ public class BaseEntity implements Serializable {
private Date lastUpdateTime; private Date lastUpdateTime;
/** /**
* *
*/ */
@JsonIgnore @JsonIgnore
private boolean isDeleted; private boolean isDeleted;

@ -9,7 +9,7 @@ import java.util.List;
* @version 0.0.1 * @version 0.0.1
* @since 2017-01-01 * @since 2017-01-01
*/ */
public class BaseFindResponse<T> extends BaseResponse{ public class BaseFindResponse<T> extends BaseResponse {
private List<T> result; private List<T> result;

@ -10,8 +10,8 @@ package xyz.wbsite.dbtool.web.frame.base;
public class BaseSearchRequest extends BaseFindRequest { public class BaseSearchRequest extends BaseFindRequest {
/** /**
* *
*/ */
private String keyword; private String keyword;
public String getKeyword() { public String getKeyword() {

@ -7,11 +7,11 @@ package xyz.wbsite.dbtool.web.frame.base;
* @version 0.0.1 * @version 0.0.1
* @since 2017-01-01 * @since 2017-01-01
*/ */
public class BaseUpdateRequest extends BaseRequest{ public class BaseUpdateRequest extends BaseRequest {
/** /**
* *
*/ */
private long rowVersion; private long rowVersion;
public long getRowVersion() { public long getRowVersion() {

@ -13,11 +13,17 @@ import java.util.Set;
*/ */
public class Token implements Serializable { public class Token implements Serializable {
private static final Long serialVersionUID = 1L; private static final Long serialVersionUID = 1L;
/** ID */ /**
* ID
*/
private long id; private long id;
/** 用户ID */ /**
* ID
*/
private long userId; private long userId;
/** 用户名称 */ /**
*
*/
private String userName; private String userName;
private Set<String> resourceSet = new HashSet<>(); private Set<String> resourceSet = new HashSet<>();
@ -47,16 +53,16 @@ public class Token implements Serializable {
this.userName = userName; this.userName = userName;
} }
public boolean hasResource(String resource){ public boolean hasResource(String resource) {
for (String s : resourceSet) { for (String s : resourceSet) {
if (resource.matches(s)){ if (resource.matches(s)) {
return true; return true;
} }
} }
return false; return false;
} }
public void putResource(String resource){ public void putResource(String resource) {
resourceSet.add(resource); resourceSet.add(resource);
} }
@ -64,11 +70,11 @@ public class Token implements Serializable {
return resourceSet; return resourceSet;
} }
public void addResourceSet(Set<String> resourceSet){ public void addResourceSet(Set<String> resourceSet) {
this.resourceSet.addAll(resourceSet); this.resourceSet.addAll(resourceSet);
} }
public void addResourceSet(Token token){ public void addResourceSet(Token token) {
addResourceSet(token.getResourceSet()); addResourceSet(token.getResourceSet());
} }
} }

@ -1,8 +1,9 @@
package xyz.wbsite.dbtool.web.frame.utils; package xyz.wbsite.dbtool.web.frame.utils;
import xyz.wbsite.dbtool.web.frame.auth.LocalData; import xyz.wbsite.dbtool.web.frame.auth.LocalData;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
/** /**
* CookieUtil * CookieUtil

@ -68,20 +68,20 @@ public class FileUtil {
} }
public static byte[] toByteArray(InputStream input, int size) throws IOException { 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); throw new IllegalArgumentException("Size must be equal or greater than zero: " + size);
} else if(size == 0) { } else if (size == 0) {
return new byte[0]; return new byte[0];
} else { } else {
byte[] data = new byte[size]; byte[] data = new byte[size];
int offset; int offset;
int read; 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); throw new IOException("Unexpected read size. current: " + offset + ", expected: " + size);
} else { } else {
return data; return data;

@ -1,9 +1,5 @@
package xyz.wbsite.dbtool.web.frame.utils; package xyz.wbsite.dbtool.web.frame.utils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/** /**
* IDgenerator - ID * IDgenerator - ID
* *

@ -17,40 +17,44 @@ public class LogUtil {
/** /**
* info * info
*
* @param context * @param context
*/ */
public static void i(String context){ public static void i(String context) {
logger.info(context); logger.info(context);
} }
/** /**
* debug * debug
*
* @param context * @param context
*/ */
public static void d(String context){ public static void d(String context) {
logger.debug(context); logger.debug(context);
} }
/** /**
* warn * warn
*
* @param context * @param context
*/ */
public static void w(String context){ public static void w(String context) {
logger.warn(context); logger.warn(context);
} }
/** /**
* error * error
*
* @param context * @param context
*/ */
public static void e(String context){ public static void e(String context) {
logger.error(context); logger.error(context);
} }
/** /**
* *
*/ */
public static void dumpException(Throwable e){ public static void dumpException(Throwable e) {
StringBuffer msg = new StringBuffer("null"); StringBuffer msg = new StringBuffer("null");
if (e != null) { if (e != null) {
msg = new StringBuffer(""); msg = new StringBuffer("");

@ -1,9 +1,7 @@
package xyz.wbsite.dbtool.web.frame.utils; package xyz.wbsite.dbtool.web.frame.utils;
import com.fasterxml.jackson.core.TreeNode;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.Iterator;
/** /**
* MD5Util - MD5 * MD5Util - MD5

@ -4,9 +4,14 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.TreeNode; import com.fasterxml.jackson.core.TreeNode;
import com.fasterxml.jackson.core.type.TypeReference; 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.DozerBeanMapper;
import org.dozer.Mapper; import org.dozer.Mapper;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.List; import java.util.List;
@ -32,7 +37,7 @@ public class MapperUtil {
//反序列化是忽略多余字段 //反序列化是忽略多余字段
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
//支持空类序列化时出错InvalidDefinitionException //支持空类序列化时出错InvalidDefinitionException
om.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS,false); om.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
mapper = new DozerBeanMapper(); mapper = new DozerBeanMapper();
} }

@ -1,8 +1,6 @@
package xyz.wbsite.dbtool.web.frame.utils; package xyz.wbsite.dbtool.web.frame.utils;
import java.awt.*;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@ -16,6 +14,7 @@ import java.io.InputStreamReader;
public class ProcessUtil { public class ProcessUtil {
/** /**
* windowsexe * windowsexe
*
* @param path exe * @param path exe
*/ */
public static void execExe(String path) { public static void execExe(String path) {
@ -30,6 +29,7 @@ public class ProcessUtil {
/** /**
* windows * windows
*
* @param path * @param path
*/ */
public static void execBat(String path) { public static void execBat(String path) {
@ -44,6 +44,7 @@ public class ProcessUtil {
/** /**
* windows cmd * windows cmd
*
* @param command cmd * @param command cmd
*/ */
public static String execCmd(String command) { public static String execCmd(String command) {
@ -53,6 +54,7 @@ public class ProcessUtil {
/** /**
* *
*
* @param command cmd * @param command cmd
*/ */
public static String exec(String command) { public static String exec(String command) {

@ -3,7 +3,13 @@ package xyz.wbsite.dbtool.web.frame.utils;
import javax.crypto.Cipher; import javax.crypto.Cipher;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.UnsupportedEncodingException; 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.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey; import java.security.interfaces.RSAPublicKey;
import java.security.spec.InvalidKeySpecException; import java.security.spec.InvalidKeySpecException;

@ -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.BaseRequest;
import xyz.wbsite.dbtool.web.frame.base.BaseResponse; import xyz.wbsite.dbtool.web.frame.base.BaseResponse;
import xyz.wbsite.dbtool.web.frame.base.ErrorType; import xyz.wbsite.dbtool.web.frame.base.ErrorType;
import javax.validation.ConstraintViolation; import javax.validation.ConstraintViolation;
import javax.validation.Validation; import javax.validation.Validation;
import javax.validation.Validator; import javax.validation.Validator;
import javax.validation.ValidatorFactory; 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.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** /**
* *

@ -1,7 +1,16 @@
package xyz.wbsite.dbtool.web.frame.utils; package xyz.wbsite.dbtool.web.frame.utils;
import javax.net.ssl.*; import javax.net.ssl.HostnameVerifier;
import java.io.*; 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.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.net.URLDecoder; import java.net.URLDecoder;

@ -1,6 +1,10 @@
package xyz.wbsite.dbtool.web.frame.utils; 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.Enumeration;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;

@ -2,7 +2,10 @@ package xyz.wbsite.dbtool.web.frame.validation;
import javax.validation.Constraint; import javax.validation.Constraint;
import javax.validation.Payload; 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}) @Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)

@ -1,4 +1,5 @@
import xyz.wbsite.dbtool.javafx.manger.ProjectManager; import xyz.wbsite.dbtool.javafx.manger.ProjectManager;
import java.util.HashMap; import java.util.HashMap;
public class TestConnect { public class TestConnect {

Loading…
Cancel
Save

Powered by TurnKey Linux.