fc
This commit is contained in:
commit
240d453337
57
pom.xml
Normal file
57
pom.xml
Normal file
@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>ink.wgink</groupId>
|
||||
<artifactId>code-factory</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-controls</artifactId>
|
||||
<version>15.0.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.49</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.11</version>
|
||||
</dependency>
|
||||
|
||||
<!-- pingyin start -->
|
||||
<dependency>
|
||||
<groupId>com.belerweb</groupId>
|
||||
<artifactId>pinyin4j</artifactId>
|
||||
<version>2.5.1</version>
|
||||
</dependency>
|
||||
<!-- pingyin end -->
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-maven-plugin</artifactId>
|
||||
<version>0.0.5</version>
|
||||
<configuration>
|
||||
<mainClass>HelloFX</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
31
src/main/java/ink/wgink/code/factory/StartUp.java
Normal file
31
src/main/java/ink/wgink/code/factory/StartUp.java
Normal file
@ -0,0 +1,31 @@
|
||||
package ink.wgink.code.factory;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: StartUp
|
||||
* @Description: 启动
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/3/2 12:54
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class StartUp extends Application {
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/route/main.fxml"));
|
||||
primaryStage.setScene(new Scene(fxmlLoader.load()));
|
||||
primaryStage.show();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package ink.wgink.code.factory.controller;
|
||||
|
||||
import ink.wgink.code.factory.factory.CheckBoxTableCellFactory;
|
||||
import ink.wgink.code.factory.factory.ChoiceBoxTableCellFactory;
|
||||
import ink.wgink.code.factory.service.FieldService;
|
||||
import ink.wgink.code.factory.service.GenerateService;
|
||||
import ink.wgink.code.factory.vos.TableVO;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: GenerateController
|
||||
* @Description: 生成器
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/3/6 10:11
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class GenerateController implements Initializable {
|
||||
|
||||
@FXML
|
||||
private CheckBox apiCheckBox;
|
||||
@FXML
|
||||
private CheckBox appCheckBox;
|
||||
@FXML
|
||||
private CheckBox resourceCheckBox;
|
||||
@FXML
|
||||
private CheckBox iServiceCheckBox;
|
||||
@FXML
|
||||
private CheckBox serviceImplCheckBox;
|
||||
@FXML
|
||||
private CheckBox iDaoCheckBox;
|
||||
@FXML
|
||||
private CheckBox mysqlCheckBox;
|
||||
@FXML
|
||||
private TextField tablePrefixTextField;
|
||||
@FXML
|
||||
private CheckBox htmlCheckBox;
|
||||
@FXML
|
||||
private CheckBox thymeleafCheckBox;
|
||||
@FXML
|
||||
private CheckBox routeCheckBox;
|
||||
@FXML
|
||||
private TextField contextTextField;
|
||||
@FXML
|
||||
private TextField packageTextField;
|
||||
@FXML
|
||||
private TableView fieldTableView;
|
||||
|
||||
private TableVO tableVO;
|
||||
private FieldService fieldService;
|
||||
private GenerateService generateService;
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
initTableView();
|
||||
}
|
||||
|
||||
private void initTableView() {
|
||||
ObservableList<TableColumn> tableColumns = fieldTableView.getColumns();
|
||||
tableColumns.get(0).setCellValueFactory(new PropertyValueFactory<>("rowNumber"));
|
||||
tableColumns.get(1).setCellValueFactory(new PropertyValueFactory<>("columnName"));
|
||||
tableColumns.get(2).setCellValueFactory(new PropertyValueFactory<>("columnComment"));
|
||||
tableColumns.get(3).setCellValueFactory(new PropertyValueFactory<>("columnDefault"));
|
||||
tableColumns.get(4).setCellValueFactory(new PropertyValueFactory<>("columnType"));
|
||||
tableColumns.get(5).setCellValueFactory(new PropertyValueFactory<>("propertyName"));
|
||||
tableColumns.get(6).setCellValueFactory(new PropertyValueFactory<>("propertyType"));
|
||||
tableColumns.get(7).setCellValueFactory(new PropertyValueFactory<>("propertyLength"));
|
||||
tableColumns.get(8).setCellValueFactory(new CheckBoxTableCellFactory("isFormShow"));
|
||||
tableColumns.get(9).setCellValueFactory(new CheckBoxTableCellFactory("isListShow"));
|
||||
tableColumns.get(10).setCellValueFactory(new CheckBoxTableCellFactory("isNotNull"));
|
||||
tableColumns.get(11).setCellValueFactory(new ChoiceBoxTableCellFactory("formFieldType"));
|
||||
}
|
||||
|
||||
public void setTableVO(TableVO tableVO) {
|
||||
this.tablePrefixTextField.setText(tableVO.getTableName().split("\\_")[0] + "_");
|
||||
this.tableVO = tableVO;
|
||||
fieldService = new FieldService(fieldTableView, tableVO.getTableName());
|
||||
generateService = new GenerateService(fieldTableView);
|
||||
fieldService.showField();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package ink.wgink.code.factory.controller;
|
||||
|
||||
import com.sun.javafx.robot.impl.FXRobotHelper;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: LoginController
|
||||
* @Description: 登录
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/3/2 21:25
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class LoginController {
|
||||
|
||||
@FXML
|
||||
private Button clickButton;
|
||||
|
||||
@FXML
|
||||
public void onAction(ActionEvent actionEvent) throws IOException {
|
||||
Scene scene = new Scene(FXMLLoader.load(getClass().getResource("/route/main.fxml")), 400, 300);
|
||||
Stage stage = FXRobotHelper.getStages().get(0);
|
||||
stage.setScene(scene);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,160 @@
|
||||
package ink.wgink.code.factory.controller;
|
||||
|
||||
import ink.wgink.code.factory.service.TableService;
|
||||
import ink.wgink.code.factory.utils.MsgUtil;
|
||||
import ink.wgink.code.factory.vos.TableVO;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.control.Alert.AlertType;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.StageStyle;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: MainController
|
||||
* @Description: 主页
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/3/3 20:02
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class MainController implements Initializable {
|
||||
|
||||
@FXML
|
||||
private TextField dbUrlField;
|
||||
@FXML
|
||||
private TextField dbPortField;
|
||||
@FXML
|
||||
private TextField dbNameField;
|
||||
@FXML
|
||||
private TextField dbUsernameField;
|
||||
@FXML
|
||||
private PasswordField dbPasswordField;
|
||||
@FXML
|
||||
private Button connectionDatabaseButton;
|
||||
@FXML
|
||||
private TableView dbTableTableView;
|
||||
private TableService tableService;
|
||||
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
initDBTableTableView();
|
||||
this.tableService = new TableService(dbTableTableView);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化 数据库表 TableView
|
||||
*/
|
||||
private void initDBTableTableView() {
|
||||
ObservableList<TableColumn<TableVO, String>> tableColumns = dbTableTableView.getColumns();
|
||||
tableColumns.get(0).setCellValueFactory(new PropertyValueFactory<>("rowNumber"));
|
||||
tableColumns.get(1).setCellValueFactory(new PropertyValueFactory<>("tableName"));
|
||||
tableColumns.get(2).setCellValueFactory(new PropertyValueFactory<>("tableComment"));
|
||||
tableColumns.get(3).setCellValueFactory(new PropertyValueFactory<>("tableCollation"));
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void onConnectDatabase(ActionEvent event) {
|
||||
String dbUrl = dbUrlField.getText();
|
||||
if (StringUtils.isBlank(dbUrl)) {
|
||||
MsgUtil.errorAlert("数据库地址不能为空");
|
||||
return;
|
||||
}
|
||||
String dbPort = dbPortField.getText();
|
||||
if (StringUtils.isBlank(dbPort)) {
|
||||
MsgUtil.errorAlert("数据库端口不能为空");
|
||||
return;
|
||||
}
|
||||
String dbName = dbNameField.getText();
|
||||
if (StringUtils.isBlank(dbName)) {
|
||||
MsgUtil.errorAlert("数据库名不能为空");
|
||||
return;
|
||||
}
|
||||
String dbUsername = dbUsernameField.getText();
|
||||
if (StringUtils.isBlank(dbUsername)) {
|
||||
MsgUtil.errorAlert("数据库用户名不能为空");
|
||||
return;
|
||||
}
|
||||
String dbPassword = dbPasswordField.getText();
|
||||
if (StringUtils.isBlank(dbPassword)) {
|
||||
MsgUtil.errorAlert("数据库密码不能为空");
|
||||
return;
|
||||
}
|
||||
tableService.connectionDatabase(dbUrl, dbPort, dbName, dbUsername, dbPassword);
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void onTableRowClick(MouseEvent event) throws IOException {
|
||||
if (event.getClickCount() == 2) {
|
||||
TableVO tableVO = (TableVO) this.dbTableTableView.getSelectionModel().getSelectedItem();
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/route/generate.fxml"));
|
||||
Stage stage = new Stage(StageStyle.DECORATED);
|
||||
stage.setScene(new Scene(fxmlLoader.load(), 800D, 600D));
|
||||
stage.initModality(Modality.APPLICATION_MODAL);
|
||||
stage.setTitle("生成代码【" + tableVO.getTableName() + "】");
|
||||
stage.show();
|
||||
|
||||
GenerateController generateController = fxmlLoader.getController();
|
||||
generateController.setTableVO(tableVO);
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void dbUrlReleased(KeyEvent keyEvent) {
|
||||
String port = dbUrlField.getText();
|
||||
if (StringUtils.isBlank(port)) {
|
||||
dbUrlField.setText("");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void dbNameReleased(KeyEvent keyEvent) {
|
||||
String port = dbNameField.getText();
|
||||
if (StringUtils.isBlank(port)) {
|
||||
dbNameField.setText("");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void dbUsernameReleased(KeyEvent keyEvent) {
|
||||
String port = dbUsernameField.getText();
|
||||
if (StringUtils.isBlank(port)) {
|
||||
dbUsernameField.setText("");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void dbPortReleased(KeyEvent keyEvent) {
|
||||
String port = dbPortField.getText();
|
||||
if (StringUtils.isBlank(port)) {
|
||||
dbPortField.setText("");
|
||||
return;
|
||||
}
|
||||
if (!NumberUtils.isDigits(port)) {
|
||||
MsgUtil.alert(AlertType.ERROR, "端口号只能是数字");
|
||||
dbPortField.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package ink.wgink.code.factory.enums;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: DataTypeEnum
|
||||
* @Description: 数据类型
|
||||
* @Author: WangGeng
|
||||
* @Date: 2019/11/15 8:20 下午
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public enum ColumnDataTypeEnum {
|
||||
|
||||
/**
|
||||
* 整形
|
||||
*/
|
||||
INT("int"),
|
||||
/**
|
||||
* 长整形
|
||||
*/
|
||||
BIGINT("bigint"),
|
||||
/**
|
||||
* 双精度
|
||||
*/
|
||||
DOUBLE("double"),
|
||||
/**
|
||||
* 时间戳
|
||||
*/
|
||||
DATETIME("datetime"),
|
||||
/**
|
||||
* 日期
|
||||
*/
|
||||
DATE("date"),
|
||||
/**
|
||||
* 字符串
|
||||
*/
|
||||
VARCHAR("varchar"),
|
||||
/**
|
||||
* 字符
|
||||
*/
|
||||
CHAR("char"),
|
||||
/**
|
||||
* 文本
|
||||
*/
|
||||
TEXT("text"),
|
||||
/**
|
||||
* 长文本
|
||||
*/
|
||||
LONGTEXT("longtext"),
|
||||
/**
|
||||
* ID和名称
|
||||
*/
|
||||
ID_AND_NAME("idAndName"),
|
||||
/**
|
||||
* ID列表和名称列表
|
||||
*/
|
||||
IDS_AND_NAMES("idsAndNames");
|
||||
|
||||
private String value;
|
||||
|
||||
ColumnDataTypeEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value == null ? "" : value.trim();
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package ink.wgink.code.factory.enums;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: ColumnIsNullable
|
||||
* @Description: 可为空
|
||||
* @Author: WangGeng
|
||||
* @Date: 2019/11/15 9:28 下午
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public enum ColumnIsNullableEnum {
|
||||
|
||||
YES("YES"),
|
||||
NO("NO");
|
||||
|
||||
String value;
|
||||
|
||||
ColumnIsNullableEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value == null ? "" : value.trim();
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package ink.wgink.code.factory.enums;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: FieldRequireTypeEnum
|
||||
* @Description: 字段校验类型
|
||||
* @Author: WangGeng
|
||||
* @Date: 2019/12/4 17:29
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public enum FormFieldRequireTypeEnum {
|
||||
NONE("none"),
|
||||
REQUIRED("required"),
|
||||
PHONE("phone"),
|
||||
EMAIL("email"),
|
||||
URL("url"),
|
||||
NUMBER("number"),
|
||||
DATE("date"),
|
||||
IDENTITY("identity"),
|
||||
CUSTOM("custom");
|
||||
|
||||
private String value;
|
||||
|
||||
FormFieldRequireTypeEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value == null ? "" : value;
|
||||
}
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
package ink.wgink.code.factory.enums;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: DynamicFormEnum
|
||||
* @Description: 动态表单
|
||||
* @Author: WangGeng
|
||||
* @Date: 2019/12/2 5:28 下午
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public enum FormFieldTypeEnum {
|
||||
|
||||
/**
|
||||
* 文本
|
||||
*/
|
||||
TEXT("text"),
|
||||
/**
|
||||
* 时间戳
|
||||
*/
|
||||
DATETIME("datetime"),
|
||||
/**
|
||||
* 日期
|
||||
*/
|
||||
DATE("date"),
|
||||
/**
|
||||
* 整形
|
||||
*/
|
||||
NUMBER("number"),
|
||||
/**
|
||||
* 双精度
|
||||
*/
|
||||
DOUBLE("double"),
|
||||
/**
|
||||
* 文本域
|
||||
*/
|
||||
TEXTAREA("textarea"),
|
||||
/**
|
||||
* 富文本
|
||||
*/
|
||||
RICH_TEXT("richText"),
|
||||
/**
|
||||
* ID 选择
|
||||
*/
|
||||
ID_SELECT("idSelect"),
|
||||
/**
|
||||
* 下拉选择
|
||||
*/
|
||||
SELECT("select"),
|
||||
/**
|
||||
* 复选
|
||||
*/
|
||||
CHECKBOX("checkbox"),
|
||||
/**
|
||||
* 单选
|
||||
*/
|
||||
RADIO("radio"),
|
||||
/**
|
||||
* 选择人员
|
||||
*/
|
||||
SELECT_USER("selectUser"),
|
||||
/**
|
||||
* 选择部门
|
||||
*/
|
||||
SELECT_DEPARTMENT("selectDepartment"),
|
||||
/**
|
||||
* 文件
|
||||
*/
|
||||
FILE("file"),
|
||||
/**
|
||||
* 图片
|
||||
*/
|
||||
IMAGE("image"),
|
||||
/**
|
||||
* 视频
|
||||
*/
|
||||
VIDEO("video"),
|
||||
/**
|
||||
* 音频
|
||||
*/
|
||||
AUDIO("audio"),
|
||||
/**
|
||||
* 当前用户
|
||||
*/
|
||||
CURRENT_USER("currentUser"),
|
||||
/**
|
||||
* 当前部门
|
||||
*/
|
||||
CURRENT_DEPARTMENT("currentDepartment"),
|
||||
/**
|
||||
* 当前角色
|
||||
*/
|
||||
CURRENT_ROLE("currentRole"),
|
||||
/**
|
||||
* 当前组
|
||||
*/
|
||||
CURRENT_GROUP("currentGroup"),
|
||||
/**
|
||||
* 当前职位
|
||||
*/
|
||||
CURRENT_POSITION("currentPosition");
|
||||
|
||||
private String value;
|
||||
|
||||
FormFieldTypeEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value == null ? "" : value.trim();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package ink.wgink.code.factory.enums;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: PropertyTypeEnum
|
||||
* @Description: Java属性类型
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/3/7 10:31
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public enum PropertyTypeEnum {
|
||||
STRING("string"),
|
||||
DOUBLE("double"),
|
||||
INTEGER("integer"),
|
||||
LONG("long");
|
||||
|
||||
private String value;
|
||||
|
||||
PropertyTypeEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value == null ? "" : value.trim();
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package ink.wgink.code.factory.factory;
|
||||
|
||||
import ink.wgink.code.factory.vos.FieldVO;
|
||||
import javafx.beans.property.ReadOnlyObjectWrapper;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.util.Callback;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: CheckboxTableCellFactory
|
||||
* @Description: 表格checkbox
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/3/6 18:46
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class CheckBoxTableCellFactory implements Callback<TableColumn.CellDataFeatures<FieldVO, String>, ObservableValue<CheckBox>> {
|
||||
public static final String IS_FORM_SHOW = "isFormShow";
|
||||
public static final String IS_LIST_SHOW = "isListShow";
|
||||
public static final String IS_NOT_NULL = "isNotNull";
|
||||
private final String property;
|
||||
|
||||
public CheckBoxTableCellFactory(String property) {
|
||||
this.property = property;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObservableValue<CheckBox> call(TableColumn.CellDataFeatures<FieldVO, String> param) {
|
||||
CheckBox checkBox = new CheckBox();
|
||||
if (StringUtils.equals(IS_FORM_SHOW, property)) {
|
||||
Boolean isFormShow = param.getValue().getFormShow();
|
||||
checkBox.setSelected(isFormShow == null || !isFormShow ? false : true);
|
||||
}
|
||||
if (StringUtils.equals(IS_LIST_SHOW, property)) {
|
||||
Boolean isListShow = param.getValue().getListShow();
|
||||
checkBox.setSelected(isListShow == null || !isListShow ? false : true);
|
||||
}
|
||||
if (StringUtils.equals(IS_NOT_NULL, property)) {
|
||||
Boolean isNotNull = param.getValue().getNotNull();
|
||||
checkBox.setSelected(isNotNull == null || !isNotNull ? false : true);
|
||||
}
|
||||
return new ReadOnlyObjectWrapper<>(checkBox);
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package ink.wgink.code.factory.factory;
|
||||
|
||||
import ink.wgink.code.factory.enums.FormFieldTypeEnum;
|
||||
import ink.wgink.code.factory.vos.FieldVO;
|
||||
import javafx.beans.property.ReadOnlyObjectWrapper;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.scene.control.ChoiceBox;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.util.Callback;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.text.Normalizer;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: SelectTableCellFactory
|
||||
* @Description: 表格下拉列表
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/3/7 10:52
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class ChoiceBoxTableCellFactory implements Callback<TableColumn.CellDataFeatures<FieldVO, String>, ObservableValue<ChoiceBox<String>>> {
|
||||
|
||||
private final String property;
|
||||
private ObservableList<String> normalSelect = FXCollections.observableArrayList(
|
||||
"", FormFieldTypeEnum.TEXT.getValue(), FormFieldTypeEnum.NUMBER.getValue(),
|
||||
FormFieldTypeEnum.DOUBLE.getValue(), FormFieldTypeEnum.TEXTAREA.getValue(),
|
||||
FormFieldTypeEnum.SELECT_USER.getValue(), FormFieldTypeEnum.SELECT_DEPARTMENT.getValue(),
|
||||
FormFieldTypeEnum.FILE.getValue(), FormFieldTypeEnum.IMAGE.getValue(),
|
||||
FormFieldTypeEnum.AUDIO.getValue(), FormFieldTypeEnum.VIDEO.getValue(),
|
||||
FormFieldTypeEnum.CHECKBOX.getValue()
|
||||
);
|
||||
private ObservableList<String> singleSelect = FXCollections.observableArrayList(
|
||||
"",
|
||||
FormFieldTypeEnum.RADIO.getValue(),
|
||||
FormFieldTypeEnum.SELECT.getValue()
|
||||
);
|
||||
|
||||
public ChoiceBoxTableCellFactory(String property) {
|
||||
this.property = property;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObservableValue<ChoiceBox<String>> call(TableColumn.CellDataFeatures<FieldVO, String> param) {
|
||||
ChoiceBox choiceBox = new ChoiceBox();
|
||||
choiceBox.setPrefWidth(150);
|
||||
if (StringUtils.equalsIgnoreCase(FormFieldTypeEnum.ID_SELECT.getValue(), param.getValue().getFormFieldType())) {
|
||||
choiceBox.setItems(singleSelect);
|
||||
} else {
|
||||
choiceBox.setItems(normalSelect);
|
||||
}
|
||||
choiceBox.getSelectionModel().select(param.getValue().getFormFieldType());
|
||||
return new ReadOnlyObjectWrapper<>(choiceBox);
|
||||
}
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
package ink.wgink.code.factory.manager;
|
||||
|
||||
import ink.wgink.code.factory.utils.JdbcUtil;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: JdbcManager
|
||||
* @Description: JDBC管理
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/3/5 21:23
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class JdbcManager {
|
||||
|
||||
private static JdbcManager jdbcManager = JdbcManagerBuilder.jdbcManager;
|
||||
private String dbUrl;
|
||||
private String dbPort;
|
||||
private String dbName;
|
||||
private String dbUsername;
|
||||
private String dbPassword;
|
||||
private Connection connection;
|
||||
|
||||
static {
|
||||
try {
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private JdbcManager() {
|
||||
}
|
||||
|
||||
public static JdbcManager getInstance() {
|
||||
return jdbcManager;
|
||||
}
|
||||
|
||||
public void setDatabaseInfo(String dbUrl, String dbPort, String dbName, String dbUsername, String dbPassword) {
|
||||
this.dbUrl = dbUrl;
|
||||
this.dbPort = dbPort;
|
||||
this.dbName = dbName;
|
||||
this.dbUsername = dbUsername;
|
||||
this.dbPassword = dbPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据库链接
|
||||
*
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
public Connection getConnection() throws SQLException {
|
||||
if (connection == null || connection.isClosed()) {
|
||||
this.connection = DriverManager.getConnection(String.format("jdbc:mysql://%s:%s/%s", dbUrl, dbPort, dbName), dbUsername, dbPassword);
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据库表列表
|
||||
*
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
public List<Map<String, Object>> listDatabaseTable() throws SQLException {
|
||||
String SQL = "SELECT * FROM `information_schema`.`TABLES` WHERE TABLE_SCHEMA = ?";
|
||||
PreparedStatement preparedStatement = getConnection().prepareStatement(SQL);
|
||||
preparedStatement.setString(1, this.dbName);
|
||||
return JdbcUtil.listResult(preparedStatement.executeQuery());
|
||||
}
|
||||
|
||||
/**
|
||||
* 表字段列表
|
||||
*
|
||||
* @param tableName
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
public List<Map<String, Object>> listTableField(String tableName) throws SQLException {
|
||||
String SQL = "SELECT * FROM `information_schema`.`COLUMNS` WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ?";
|
||||
PreparedStatement preparedStatement = getConnection().prepareStatement(SQL);
|
||||
preparedStatement.setString(1, this.dbName);
|
||||
preparedStatement.setString(2, tableName);
|
||||
return JdbcUtil.listResult(preparedStatement.executeQuery());
|
||||
}
|
||||
|
||||
private static class JdbcManagerBuilder {
|
||||
public static JdbcManager jdbcManager = new JdbcManager();
|
||||
}
|
||||
|
||||
}
|
135
src/main/java/ink/wgink/code/factory/service/FieldService.java
Normal file
135
src/main/java/ink/wgink/code/factory/service/FieldService.java
Normal file
@ -0,0 +1,135 @@
|
||||
package ink.wgink.code.factory.service;
|
||||
|
||||
import ink.wgink.code.factory.enums.ColumnDataTypeEnum;
|
||||
import ink.wgink.code.factory.enums.ColumnIsNullableEnum;
|
||||
import ink.wgink.code.factory.enums.FormFieldTypeEnum;
|
||||
import ink.wgink.code.factory.enums.PropertyTypeEnum;
|
||||
import ink.wgink.code.factory.manager.JdbcManager;
|
||||
import ink.wgink.code.factory.utils.WStringUtil;
|
||||
import ink.wgink.code.factory.vos.FieldVO;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.concurrent.Service;
|
||||
import javafx.concurrent.Task;
|
||||
import javafx.scene.control.TableView;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: FieldService
|
||||
* @Description: 字段业务
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/3/6 16:11
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class FieldService {
|
||||
|
||||
private static final String DEFAULT_FIELD_ID = "id";
|
||||
private static final String DEFAULT_FIELD_CREATOR = "creator";
|
||||
private static final String DEFAULT_FIELD_GMT_CREATE = "gmtCreate";
|
||||
private static final String DEFAULT_FIELD_MODIFIER = "modifier";
|
||||
private static final String DEFAULT_FIELD_GMT_MODIFIED = "gmtModified";
|
||||
private static final String DEFAULT_FIELD_IS_DELETE = "isDelete";
|
||||
|
||||
private ObservableList<FieldVO> fieldVOObservableList = FXCollections.observableArrayList();
|
||||
private TableView tableView;
|
||||
private String tableName;
|
||||
|
||||
public FieldService(TableView tableView, String tableName) {
|
||||
this.tableView = tableView;
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单字段类型
|
||||
*
|
||||
* @param columnDataType
|
||||
* @return
|
||||
*/
|
||||
public String getFormFieldType(String columnDataType) {
|
||||
if (StringUtils.equalsIgnoreCase(ColumnDataTypeEnum.INT.getValue(), columnDataType)) {
|
||||
return FormFieldTypeEnum.NUMBER.getValue();
|
||||
} else if (StringUtils.equalsIgnoreCase(ColumnDataTypeEnum.BIGINT.getValue(), columnDataType)) {
|
||||
return FormFieldTypeEnum.NUMBER.getValue();
|
||||
} else if (StringUtils.equalsIgnoreCase(ColumnDataTypeEnum.DOUBLE.getValue(), columnDataType)) {
|
||||
return FormFieldTypeEnum.DOUBLE.getValue();
|
||||
} else if (StringUtils.equalsIgnoreCase(ColumnDataTypeEnum.DATETIME.getValue(), columnDataType)) {
|
||||
return FormFieldTypeEnum.DATETIME.getValue();
|
||||
} else if (StringUtils.equalsIgnoreCase(ColumnDataTypeEnum.DATE.getValue(), columnDataType)) {
|
||||
return FormFieldTypeEnum.DATE.getValue();
|
||||
} else if (StringUtils.equalsIgnoreCase(ColumnDataTypeEnum.TEXT.getValue(), columnDataType)) {
|
||||
return FormFieldTypeEnum.TEXTAREA.getValue();
|
||||
} else if (StringUtils.equalsIgnoreCase(ColumnDataTypeEnum.LONGTEXT.getValue(), columnDataType)) {
|
||||
return FormFieldTypeEnum.RICH_TEXT.getValue();
|
||||
} else if (StringUtils.equalsIgnoreCase(ColumnDataTypeEnum.CHAR.getValue(), columnDataType)) {
|
||||
return FormFieldTypeEnum.ID_SELECT.getValue();
|
||||
}
|
||||
return FormFieldTypeEnum.TEXT.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Java属性栏类型
|
||||
*
|
||||
* @param columnDataType
|
||||
* @return
|
||||
*/
|
||||
public String getPropertyType(String columnDataType) {
|
||||
if (StringUtils.equalsIgnoreCase(ColumnDataTypeEnum.INT.getValue(), columnDataType)) {
|
||||
return PropertyTypeEnum.INTEGER.getValue();
|
||||
} else if (StringUtils.equalsIgnoreCase(ColumnDataTypeEnum.BIGINT.getValue(), columnDataType)) {
|
||||
return PropertyTypeEnum.LONG.getValue();
|
||||
} else if (StringUtils.equalsIgnoreCase(ColumnDataTypeEnum.DOUBLE.getValue(), columnDataType)) {
|
||||
return PropertyTypeEnum.DOUBLE.getValue();
|
||||
}
|
||||
return PropertyTypeEnum.STRING.getValue();
|
||||
}
|
||||
|
||||
public void showField() {
|
||||
new Service<Integer>() {
|
||||
|
||||
@Override
|
||||
protected Task<Integer> createTask() {
|
||||
return new Task<Integer>() {
|
||||
@Override
|
||||
protected Integer call() throws Exception {
|
||||
List<Map<String, Object>> tableFields = JdbcManager.getInstance().listTableField(tableName);
|
||||
fieldVOObservableList.clear();
|
||||
for (int i = 0; i < tableFields.size(); i++) {
|
||||
Map<String, Object> field = tableFields.get(i);
|
||||
System.out.println(field);
|
||||
|
||||
FieldVO fieldVO = new FieldVO();
|
||||
fieldVO.setRowNumber(i + 1);
|
||||
fieldVO.setColumnName(field.get("COLUMN_NAME").toString());
|
||||
fieldVO.setColumnType(field.get("COLUMN_TYPE").toString());
|
||||
fieldVO.setDataType(field.get("DATA_TYPE").toString());
|
||||
fieldVO.setCharacterMaximum(field.get("CHARACTER_MAXIMUM") == null ? 0 : Integer.valueOf(field.get("CHARACTER_MAXIMUM").toString()));
|
||||
fieldVO.setNumericPrecision(field.get("NUMERIC_PRECISION") == null ? 0 : Integer.valueOf(field.get("NUMERIC_PRECISION").toString()));
|
||||
fieldVO.setNumericScale(field.get("NUMERIC_SCALE") == null ? 0 : Integer.valueOf(field.get("NUMERIC_SCALE").toString()));
|
||||
fieldVO.setColumnComment(field.get("COLUMN_COMMENT") == null ? "" : field.get("COLUMN_COMMENT").toString());
|
||||
fieldVO.setColumnDefault(field.get("COLUMN_DEFAULT") == null ? "" : field.get("COLUMN_DEFAULT").toString());
|
||||
fieldVO.setPropertyName(WStringUtil.underLine2LowerUpper(fieldVO.getColumnName()));
|
||||
fieldVO.setNotNull(StringUtils.equalsIgnoreCase(ColumnIsNullableEnum.YES.getValue(), field.get("IS_NULLABLE").toString()) ? false : true);
|
||||
fieldVO.setPropertyType(getPropertyType(fieldVO.getDataType()));
|
||||
fieldVO.setFormFieldType(getFormFieldType(fieldVO.getDataType()));
|
||||
fieldVOObservableList.add(fieldVO);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void succeeded() {
|
||||
tableView.setItems(fieldVOObservableList);
|
||||
super.succeeded();
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package ink.wgink.code.factory.service;
|
||||
|
||||
import ink.wgink.code.factory.vos.FieldVO;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableArray;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.scene.control.TableView;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: GenerateService
|
||||
* @Description: 代码生成
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/3/6 16:11
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class GenerateService {
|
||||
|
||||
private TableView tableView;
|
||||
|
||||
public GenerateService(TableView tableView) {
|
||||
this.tableView = tableView;
|
||||
}
|
||||
|
||||
public void showField() {
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package ink.wgink.code.factory.service;
|
||||
|
||||
import ink.wgink.code.factory.manager.JdbcManager;
|
||||
import ink.wgink.code.factory.vos.TableVO;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.concurrent.Service;
|
||||
import javafx.concurrent.Task;
|
||||
import javafx.scene.control.TableView;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: TableService
|
||||
* @Description: 表
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/3/5 21:18
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class TableService {
|
||||
|
||||
private TableView dbTableTableView;
|
||||
private ObservableList<TableVO> tableVOObservableList = FXCollections.observableArrayList();
|
||||
|
||||
public TableService(TableView dbTableTableView) {
|
||||
this.dbTableTableView = dbTableTableView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 链接数据库
|
||||
*
|
||||
* @param dbUrl 数据库链接
|
||||
* @param dbPort 数据库端口
|
||||
* @param dbName 数据库名称
|
||||
* @param dbUsername 数据库用户名
|
||||
* @param dbPassword 数据库密码
|
||||
*/
|
||||
public void connectionDatabase(String dbUrl, String dbPort, String dbName, String dbUsername, String dbPassword) {
|
||||
JdbcManager.getInstance().setDatabaseInfo(dbUrl, dbPort, dbName, dbUsername, dbPassword);
|
||||
showTable();
|
||||
}
|
||||
|
||||
private void showTable() {
|
||||
new Service<Integer>() {
|
||||
@Override
|
||||
protected Task<Integer> createTask() {
|
||||
return new Task<Integer>() {
|
||||
@Override
|
||||
protected Integer call() throws Exception {
|
||||
List<Map<String, Object>> tables = JdbcManager.getInstance().listDatabaseTable();
|
||||
tableVOObservableList.clear();
|
||||
for (int i = 0; i < tables.size(); i++) {
|
||||
Map<String, Object> table = tables.get(i);
|
||||
TableVO tableVO = new TableVO();
|
||||
tableVO.setRowNumber(i + 1);
|
||||
tableVO.setTableName(table.get("TABLE_NAME").toString());
|
||||
tableVO.setTableComment(table.get("TABLE_COMMENT").toString());
|
||||
tableVO.setTableCollation(table.get("TABLE_COLLATION").toString());
|
||||
tableVOObservableList.add(tableVO);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void succeeded() {
|
||||
dbTableTableView.setItems(tableVOObservableList);
|
||||
super.succeeded();
|
||||
}
|
||||
};
|
||||
}
|
||||
}.start();
|
||||
|
||||
|
||||
}
|
||||
}
|
57
src/main/java/ink/wgink/code/factory/utils/JdbcUtil.java
Normal file
57
src/main/java/ink/wgink/code/factory/utils/JdbcUtil.java
Normal file
@ -0,0 +1,57 @@
|
||||
package ink.wgink.code.factory.utils;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @ClassName: JdbcUtil
|
||||
* @Description: Jdbc
|
||||
* @Author: WangGeng
|
||||
* @Date: 2019-07-14 18:53
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class JdbcUtil {
|
||||
|
||||
/**
|
||||
* 获取单条信息
|
||||
*
|
||||
* @param resultSet
|
||||
* @return
|
||||
*/
|
||||
public static Map<String, Object> getResult(ResultSet resultSet) {
|
||||
List<Map<String, Object>> resultList = listResult(resultSet);
|
||||
if (resultList.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return resultList.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
*
|
||||
* @param resultSet
|
||||
* @return
|
||||
*/
|
||||
public static List<Map<String, Object>> listResult(ResultSet resultSet) {
|
||||
List<Map<String, Object>> resultList = new ArrayList<>();
|
||||
try {
|
||||
ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
|
||||
int columnCount = resultSetMetaData.getColumnCount();
|
||||
while (resultSet.next()) {
|
||||
Map<String, Object> row = new HashMap<>(16);
|
||||
for (int i = 0; i < columnCount; i++) {
|
||||
row.put(resultSetMetaData.getColumnLabel(i + 1), resultSet.getObject(i + 1));
|
||||
}
|
||||
resultList.add(row);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
}
|
123
src/main/java/ink/wgink/code/factory/utils/MsgUtil.java
Normal file
123
src/main/java/ink/wgink/code/factory/utils/MsgUtil.java
Normal file
@ -0,0 +1,123 @@
|
||||
package ink.wgink.code.factory.utils;
|
||||
|
||||
import com.sun.javafx.robot.FXRobot;
|
||||
import com.sun.javafx.robot.impl.FXRobotHelper;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.property.ReadOnlyBooleanProperty;
|
||||
import javafx.beans.property.ReadOnlyDoubleProperty;
|
||||
import javafx.beans.property.ReadOnlyObjectProperty;
|
||||
import javafx.beans.property.ReadOnlyStringProperty;
|
||||
import javafx.concurrent.Service;
|
||||
import javafx.concurrent.Task;
|
||||
import javafx.concurrent.Worker;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.control.Alert.AlertType;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.StageStyle;
|
||||
|
||||
import javax.xml.soap.Text;
|
||||
import java.util.Stack;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: MessageUtil
|
||||
* @Description: 消息工具
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/3/3 21:25
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class MsgUtil {
|
||||
|
||||
/**
|
||||
* 错误
|
||||
*
|
||||
* @param msg
|
||||
*/
|
||||
public static void errorAlert(String msg) {
|
||||
alert(AlertType.NONE, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 确定
|
||||
*
|
||||
* @param alertType
|
||||
* @param msg
|
||||
*/
|
||||
public static void alert(Alert.AlertType alertType, String msg) {
|
||||
|
||||
Alert alert = new Alert(alertType, msg, ButtonType.CLOSE);
|
||||
alert.setTitle("提示");
|
||||
alert.getDialogPane().setPrefWidth(150);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* 提醒
|
||||
*
|
||||
* @param msg
|
||||
*/
|
||||
public static void msg(final String msg) {
|
||||
HBox hBox = new HBox();
|
||||
hBox.setPadding(new Insets(5, 5, 5, 5));
|
||||
hBox.setAlignment(Pos.CENTER);
|
||||
|
||||
Label label = new Label(msg);
|
||||
label.setId("msgLabel");
|
||||
hBox.getChildren().add(label);
|
||||
Stage stage = new Stage(StageStyle.UNDECORATED);
|
||||
stage.setScene(new Scene(hBox));
|
||||
stage.show();
|
||||
|
||||
// Platform.runLater(() -> {
|
||||
// // 子线程更新主线程UI的代码
|
||||
// stage.close();
|
||||
// });
|
||||
//
|
||||
|
||||
// 这种方式提倡,call中编写代码,successed方法中填写刷新UI的操作,
|
||||
Service<String> service = new Service<String>() {
|
||||
@Override
|
||||
protected Task<String> createTask() {
|
||||
return new Task<String>() {
|
||||
@Override
|
||||
protected String call() throws Exception {
|
||||
Thread.sleep(2000);
|
||||
return "success";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void scheduled() {
|
||||
// 任务开始, 填写刷新UI的操作
|
||||
super.scheduled();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void running() {
|
||||
// 任务执行
|
||||
super.running();
|
||||
}
|
||||
|
||||
// 任务成功之后,关闭提示
|
||||
@Override
|
||||
protected void succeeded() {
|
||||
// 任务执行成功
|
||||
stage.close();
|
||||
super.succeeded();
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
service.start();
|
||||
|
||||
}
|
||||
|
||||
}
|
285
src/main/java/ink/wgink/code/factory/utils/WStringUtil.java
Normal file
285
src/main/java/ink/wgink/code/factory/utils/WStringUtil.java
Normal file
@ -0,0 +1,285 @@
|
||||
package ink.wgink.code.factory.utils;
|
||||
|
||||
|
||||
import net.sourceforge.pinyin4j.PinyinHelper;
|
||||
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
|
||||
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
|
||||
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
|
||||
import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
|
||||
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 字符串相关方法
|
||||
*/
|
||||
public class WStringUtil {
|
||||
|
||||
static final Pattern LOWER_UPPER_PATTERN = Pattern.compile("[A-Z][a-z]*");
|
||||
static final Pattern PHONE_PATTERN = Pattern.compile("1\\d{10}");
|
||||
static final Pattern EMAIL_PATTERN = Pattern.compile("^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$");
|
||||
|
||||
/**
|
||||
* 是否是电话
|
||||
*
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public static boolean isPhone(String value) {
|
||||
return PHONE_PATTERN.matcher(value).matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是邮箱
|
||||
*
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public static boolean isEmail(String value) {
|
||||
return EMAIL_PATTERN.matcher(value).matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将以逗号分隔的字符串转换成字符串数组
|
||||
*
|
||||
* @param valStr
|
||||
* @return String[]
|
||||
*/
|
||||
public static String[] StrList(String valStr) {
|
||||
int i = 0;
|
||||
String TempStr = valStr;
|
||||
String[] returnStr = new String[valStr.length() + 1 - TempStr.replace(",", "").length()];
|
||||
valStr = valStr + ",";
|
||||
while (valStr.indexOf(',') > 0) {
|
||||
returnStr[i] = valStr.substring(0, valStr.indexOf(','));
|
||||
valStr = valStr.substring(valStr.indexOf(',') + 1, valStr.length());
|
||||
|
||||
i++;
|
||||
}
|
||||
return returnStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字符串编码
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static String getEncoding(String str) {
|
||||
String encode = "GB2312";
|
||||
try {
|
||||
if (str.equals(new String(str.getBytes(encode), encode))) {
|
||||
String s = encode;
|
||||
return s;
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
encode = "ISO-8859-1";
|
||||
try {
|
||||
if (str.equals(new String(str.getBytes(encode), encode))) {
|
||||
String s1 = encode;
|
||||
return s1;
|
||||
}
|
||||
} catch (Exception exception1) {
|
||||
}
|
||||
encode = "UTF-8";
|
||||
try {
|
||||
if (str.equals(new String(str.getBytes(encode), encode))) {
|
||||
String s2 = encode;
|
||||
return s2;
|
||||
}
|
||||
} catch (Exception exception2) {
|
||||
}
|
||||
encode = "GBK";
|
||||
try {
|
||||
if (str.equals(new String(str.getBytes(encode), encode))) {
|
||||
String s3 = encode;
|
||||
return s3;
|
||||
}
|
||||
} catch (Exception exception3) {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 第一个字母转小写,英文
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static String firstToLower(String str) {
|
||||
return str.substring(0, 1).toLowerCase() + str.substring(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 第一个字母大写、英文
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static String firstToUpper(String str) {
|
||||
return str.substring(0, 1).toUpperCase() + str.substring(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* title 驼峰名称转下划线名称
|
||||
* </p>
|
||||
* <p>
|
||||
* description 驼峰名称转小写名称用下划线名称
|
||||
* </p>
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
* @author WenG
|
||||
* @date 2018年2月28日 下午4:28:45
|
||||
* @modifier WenG
|
||||
* @date 2018年2月28日 下午4:28:45
|
||||
*/
|
||||
public static String lowerUpper2UnderLine(String str) {
|
||||
Matcher matcher = LOWER_UPPER_PATTERN.matcher(str);
|
||||
while (matcher.find()) {
|
||||
String group = matcher.group();
|
||||
String lower = "_" + group.toLowerCase();
|
||||
str = str.replaceFirst(group, lower);
|
||||
matcher = LOWER_UPPER_PATTERN.matcher(str);
|
||||
}
|
||||
if (str.startsWith("_")) {
|
||||
str = str.substring(1, str.length());
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* title 下划线分割转驼峰式
|
||||
* </p>
|
||||
* <p>
|
||||
* description 下划线分割转驼峰式
|
||||
* </p>
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
* @author WenG
|
||||
* @date 2018年2月28日 下午4:49:13
|
||||
* @modifier WenG
|
||||
* @date 2018年2月28日 下午4:49:13
|
||||
*/
|
||||
public static String underLine2LowerUpper(String str) {
|
||||
String[] strs = str.split("_");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < strs.length; i++) {
|
||||
String letter = strs[i].toLowerCase();
|
||||
if (letter.length() == 0) {
|
||||
continue;
|
||||
}
|
||||
if (i == 0) {
|
||||
sb.append(letter);
|
||||
} else {
|
||||
int firstLetter = letter.charAt(0);
|
||||
firstLetter -= 32;
|
||||
sb.append((char) firstLetter).append(letter.substring(1));
|
||||
}
|
||||
}
|
||||
if (sb.length() > 0) {
|
||||
return sb.toString();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* title 下划线分割转驼峰式
|
||||
* </p>
|
||||
* <p>
|
||||
* description 下划线分割转驼峰式
|
||||
* </p>
|
||||
*
|
||||
* @param str
|
||||
* @param firstLower 第一个字母小写
|
||||
* @return
|
||||
* @author WenG
|
||||
* @date 2018年2月28日 下午4:56:28
|
||||
* @modifier WenG
|
||||
* @date 2018年2月28日 下午4:56:28
|
||||
*/
|
||||
public static String underLine2LowerUpper(String str, boolean firstLower) {
|
||||
String result = underLine2LowerUpper(str);
|
||||
if (firstLower) {
|
||||
int first = result.charAt(0) + 32;
|
||||
result = ((char) first) + result.substring(1, result.length());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取拼音
|
||||
*
|
||||
* @param src
|
||||
* @return
|
||||
*/
|
||||
public static String getPingYin(String src) {
|
||||
char[] t1 = null;
|
||||
t1 = src.toCharArray();
|
||||
String[] t2 = new String[t1.length];
|
||||
HanyuPinyinOutputFormat t3 = new HanyuPinyinOutputFormat();
|
||||
t3.setCaseType(HanyuPinyinCaseType.LOWERCASE);
|
||||
t3.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
|
||||
t3.setVCharType(HanyuPinyinVCharType.WITH_V);
|
||||
String t4 = "";
|
||||
int t0 = t1.length;
|
||||
try {
|
||||
for (int i = 0; i < t0; i++) {
|
||||
// 判断是否为汉字字符
|
||||
if (Character.toString(t1[i]).matches("[\\u4E00-\\u9FA5]+")) {
|
||||
t2 = PinyinHelper.toHanyuPinyinStringArray(t1[i], t3);
|
||||
t4 += t2[0];
|
||||
} else {
|
||||
t4 += Character.toString(t1[i]);
|
||||
}
|
||||
}
|
||||
return t4;
|
||||
} catch (BadHanyuPinyinOutputFormatCombination e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
return t4;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取中文首字母
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static String getPinYinHeadChar(String str) {
|
||||
String convert = "";
|
||||
for (int j = 0; j < str.length(); j++) {
|
||||
char word = str.charAt(j);
|
||||
String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(word);
|
||||
if (pinyinArray != null) {
|
||||
convert += pinyinArray[0].charAt(0);
|
||||
} else {
|
||||
convert += word;
|
||||
}
|
||||
}
|
||||
return convert;
|
||||
}
|
||||
|
||||
/**
|
||||
* 汉字转ASCII码
|
||||
*
|
||||
* @param cnStr
|
||||
* @return
|
||||
*/
|
||||
public static String getCnASCII(String cnStr) {
|
||||
StringBuffer strBuf = new StringBuffer();
|
||||
byte[] bGBK = cnStr.getBytes();
|
||||
for (int i = 0; i < bGBK.length; i++) {
|
||||
// System.out.println(Integer.toHexString(bGBK[i]&0xff));
|
||||
strBuf.append(Integer.toHexString(bGBK[i] & 0xff));
|
||||
}
|
||||
return strBuf.toString();
|
||||
}
|
||||
|
||||
}
|
205
src/main/java/ink/wgink/code/factory/vos/FieldVO.java
Normal file
205
src/main/java/ink/wgink/code/factory/vos/FieldVO.java
Normal file
@ -0,0 +1,205 @@
|
||||
package ink.wgink.code.factory.vos;
|
||||
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: FieldVO
|
||||
* @Description: 字段
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/3/6 17:35
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class FieldVO {
|
||||
|
||||
private SimpleIntegerProperty rowNumber;
|
||||
private SimpleStringProperty columnName;
|
||||
private SimpleStringProperty columnComment;
|
||||
private SimpleStringProperty columnDefault;
|
||||
private String dataType;
|
||||
private SimpleStringProperty columnType;
|
||||
private Integer characterMaximum;
|
||||
private Integer numericPrecision;
|
||||
private Integer numericScale;
|
||||
private SimpleStringProperty propertyName;
|
||||
private SimpleStringProperty propertyType;
|
||||
private SimpleIntegerProperty propertyLength;
|
||||
private String formFieldType;
|
||||
private Boolean isFormShow;
|
||||
private Boolean isListShow;
|
||||
private Boolean isNotNull;
|
||||
|
||||
public FieldVO() {
|
||||
this.rowNumber = new SimpleIntegerProperty(0);
|
||||
this.columnName = new SimpleStringProperty();
|
||||
this.columnComment = new SimpleStringProperty();
|
||||
this.columnDefault = new SimpleStringProperty();
|
||||
this.columnType = new SimpleStringProperty();
|
||||
this.propertyName = new SimpleStringProperty();
|
||||
this.propertyType = new SimpleStringProperty();
|
||||
this.propertyLength = new SimpleIntegerProperty(0);
|
||||
}
|
||||
|
||||
public int getRowNumber() {
|
||||
return rowNumber.get();
|
||||
}
|
||||
|
||||
public SimpleIntegerProperty rowNumberProperty() {
|
||||
return rowNumber;
|
||||
}
|
||||
|
||||
public void setRowNumber(int rowNumber) {
|
||||
this.rowNumber.set(rowNumber);
|
||||
}
|
||||
|
||||
public String getColumnName() {
|
||||
return columnName.get();
|
||||
}
|
||||
|
||||
public SimpleStringProperty columnNameProperty() {
|
||||
return columnName;
|
||||
}
|
||||
|
||||
public void setColumnName(String columnName) {
|
||||
this.columnName.set(columnName);
|
||||
}
|
||||
|
||||
public String getColumnComment() {
|
||||
return columnComment.get();
|
||||
}
|
||||
|
||||
public SimpleStringProperty columnCommentProperty() {
|
||||
return columnComment;
|
||||
}
|
||||
|
||||
public void setColumnComment(String columnComment) {
|
||||
this.columnComment.set(columnComment);
|
||||
}
|
||||
|
||||
public String getColumnDefault() {
|
||||
return columnDefault.get();
|
||||
}
|
||||
|
||||
public SimpleStringProperty columnDefaultProperty() {
|
||||
return columnDefault;
|
||||
}
|
||||
|
||||
public void setColumnDefault(String columnDefault) {
|
||||
this.columnDefault.set(columnDefault);
|
||||
}
|
||||
|
||||
public String getDataType() {
|
||||
return dataType == null ? "" : dataType.trim();
|
||||
}
|
||||
|
||||
public void setDataType(String dataType) {
|
||||
this.dataType = dataType;
|
||||
}
|
||||
|
||||
public String getColumnType() {
|
||||
return columnType.get();
|
||||
}
|
||||
|
||||
public SimpleStringProperty columnTypeProperty() {
|
||||
return columnType;
|
||||
}
|
||||
|
||||
public void setColumnType(String columnType) {
|
||||
this.columnType.set(columnType);
|
||||
}
|
||||
|
||||
public Integer getCharacterMaximum() {
|
||||
return characterMaximum;
|
||||
}
|
||||
|
||||
public void setCharacterMaximum(Integer characterMaximum) {
|
||||
this.characterMaximum = characterMaximum;
|
||||
}
|
||||
|
||||
public Integer getNumericPrecision() {
|
||||
return numericPrecision;
|
||||
}
|
||||
|
||||
public void setNumericPrecision(Integer numericPrecision) {
|
||||
this.numericPrecision = numericPrecision;
|
||||
}
|
||||
|
||||
public Integer getNumericScale() {
|
||||
return numericScale;
|
||||
}
|
||||
|
||||
public void setNumericScale(Integer numericScale) {
|
||||
this.numericScale = numericScale;
|
||||
}
|
||||
|
||||
public String getPropertyName() {
|
||||
return propertyName.get();
|
||||
}
|
||||
|
||||
public SimpleStringProperty propertyNameProperty() {
|
||||
return propertyName;
|
||||
}
|
||||
|
||||
public void setPropertyName(String propertyName) {
|
||||
this.propertyName.set(propertyName);
|
||||
}
|
||||
|
||||
public String getPropertyType() {
|
||||
return propertyType.get();
|
||||
}
|
||||
|
||||
public SimpleStringProperty propertyTypeProperty() {
|
||||
return propertyType;
|
||||
}
|
||||
|
||||
public void setPropertyType(String propertyType) {
|
||||
this.propertyType.set(propertyType);
|
||||
}
|
||||
|
||||
public int getPropertyLength() {
|
||||
return propertyLength.get();
|
||||
}
|
||||
|
||||
public SimpleIntegerProperty propertyLengthProperty() {
|
||||
return propertyLength;
|
||||
}
|
||||
|
||||
public void setPropertyLength(int propertyLength) {
|
||||
this.propertyLength.set(propertyLength);
|
||||
}
|
||||
|
||||
public String getFormFieldType() {
|
||||
return formFieldType == null ? "" : formFieldType.trim();
|
||||
}
|
||||
|
||||
public void setFormFieldType(String formFieldType) {
|
||||
this.formFieldType = formFieldType;
|
||||
}
|
||||
|
||||
public Boolean getFormShow() {
|
||||
return isFormShow;
|
||||
}
|
||||
|
||||
public void setFormShow(Boolean formShow) {
|
||||
isFormShow = formShow;
|
||||
}
|
||||
|
||||
public Boolean getListShow() {
|
||||
return isListShow;
|
||||
}
|
||||
|
||||
public void setListShow(Boolean listShow) {
|
||||
isListShow = listShow;
|
||||
}
|
||||
|
||||
public Boolean getNotNull() {
|
||||
return isNotNull;
|
||||
}
|
||||
|
||||
public void setNotNull(Boolean notNull) {
|
||||
isNotNull = notNull;
|
||||
}
|
||||
}
|
84
src/main/java/ink/wgink/code/factory/vos/TableVO.java
Normal file
84
src/main/java/ink/wgink/code/factory/vos/TableVO.java
Normal file
@ -0,0 +1,84 @@
|
||||
package ink.wgink.code.factory.vos;
|
||||
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: TableVO
|
||||
* @Description:
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/3/3 14:07
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class TableVO {
|
||||
|
||||
private SimpleIntegerProperty rowNumber;
|
||||
private SimpleStringProperty tableName;
|
||||
private SimpleStringProperty tableCollation;
|
||||
private SimpleStringProperty tableComment;
|
||||
|
||||
public TableVO() {
|
||||
this.rowNumber = new SimpleIntegerProperty();
|
||||
this.tableName = new SimpleStringProperty();
|
||||
this.tableCollation = new SimpleStringProperty();
|
||||
this.tableComment = new SimpleStringProperty();
|
||||
}
|
||||
|
||||
public TableVO(Integer rowNumber, String tableName, String tableCollation, String tableComment) {
|
||||
this.rowNumber = new SimpleIntegerProperty(rowNumber);
|
||||
this.tableName = new SimpleStringProperty(tableName);
|
||||
this.tableCollation = new SimpleStringProperty(tableCollation);
|
||||
this.tableComment = new SimpleStringProperty(tableComment);
|
||||
}
|
||||
|
||||
public int getRowNumber() {
|
||||
return rowNumber.get();
|
||||
}
|
||||
|
||||
public SimpleIntegerProperty rowNumberProperty() {
|
||||
return rowNumber;
|
||||
}
|
||||
|
||||
public void setRowNumber(int rowNumber) {
|
||||
this.rowNumber.set(rowNumber);
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return tableName.get();
|
||||
}
|
||||
|
||||
public SimpleStringProperty tableNameProperty() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName.set(tableName);
|
||||
}
|
||||
|
||||
public String getTableCollation() {
|
||||
return tableCollation.get();
|
||||
}
|
||||
|
||||
public SimpleStringProperty tableCollationProperty() {
|
||||
return tableCollation;
|
||||
}
|
||||
|
||||
public void setTableCollation(String tableCollation) {
|
||||
this.tableCollation.set(tableCollation);
|
||||
}
|
||||
|
||||
public String getTableComment() {
|
||||
return tableComment.get();
|
||||
}
|
||||
|
||||
public SimpleStringProperty tableCommentProperty() {
|
||||
return tableComment;
|
||||
}
|
||||
|
||||
public void setTableComment(String tableComment) {
|
||||
this.tableComment.set(tableComment);
|
||||
}
|
||||
}
|
3
src/main/resources/assets/css/style.css
Normal file
3
src/main/resources/assets/css/style.css
Normal file
@ -0,0 +1,3 @@
|
||||
table {
|
||||
-fx-alignment: center;
|
||||
}
|
191
src/main/resources/route/generate.fxml
Normal file
191
src/main/resources/route/generate.fxml
Normal file
@ -0,0 +1,191 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.*?>
|
||||
<?import java.lang.*?>
|
||||
<?import java.util.*?>
|
||||
<?import javafx.scene.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
|
||||
<AnchorPane prefHeight="600.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ink.wgink.code.factory.controller.GenerateController">
|
||||
<children>
|
||||
<BorderPane layoutX="200.0" layoutY="100.0" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<top>
|
||||
<VBox prefHeight="200.0" prefWidth="100.0" BorderPane.alignment="CENTER">
|
||||
<children>
|
||||
<HBox spacing="5.0">
|
||||
<children>
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" prefWidth="80.0" style="-fx-font-weight: bold;" text="Controller" textAlignment="CENTER">
|
||||
<padding>
|
||||
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
|
||||
</padding>
|
||||
</Label>
|
||||
<CheckBox fx:id="apiCheckbox" mnemonicParsing="false" prefWidth="100.0" selected="true" text="Api">
|
||||
<padding>
|
||||
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
|
||||
</padding>
|
||||
</CheckBox>
|
||||
<CheckBox fx:id="appCheckbox" mnemonicParsing="false" prefWidth="100.0" selected="true" text="App">
|
||||
<padding>
|
||||
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
|
||||
</padding>
|
||||
</CheckBox>
|
||||
<CheckBox fx:id="resourceCheckbox" mnemonicParsing="false" prefWidth="100.0" selected="true" text="Resource">
|
||||
<padding>
|
||||
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
|
||||
</padding>
|
||||
</CheckBox>
|
||||
</children>
|
||||
<opaqueInsets>
|
||||
<Insets />
|
||||
</opaqueInsets>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
</HBox>
|
||||
<HBox spacing="5.0">
|
||||
<children>
|
||||
<Label alignment="CENTER" prefWidth="80.0" style="-fx-font-weight: bold;" text="Service" textAlignment="CENTER">
|
||||
<padding>
|
||||
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
|
||||
</padding>
|
||||
</Label>
|
||||
<CheckBox fx:id="iServiceCheckbox" mnemonicParsing="false" prefWidth="100.0" selected="true" text="IService">
|
||||
<padding>
|
||||
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
|
||||
</padding>
|
||||
</CheckBox>
|
||||
<CheckBox fx:id="serviceImplCheckbox" mnemonicParsing="false" prefWidth="100.0" selected="true" text="ServiceImpl">
|
||||
<padding>
|
||||
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
|
||||
</padding>
|
||||
</CheckBox>
|
||||
</children>
|
||||
<VBox.margin>
|
||||
<Insets />
|
||||
</VBox.margin>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
</HBox>
|
||||
<HBox spacing="5.0">
|
||||
<children>
|
||||
<Label alignment="CENTER" prefWidth="80.0" style="-fx-font-weight: bold;" text="Dao" textAlignment="CENTER">
|
||||
<padding>
|
||||
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
|
||||
</padding>
|
||||
</Label>
|
||||
<CheckBox fx:id="iDaoCheckbox" mnemonicParsing="false" prefWidth="100.0" selected="true" text="IDao">
|
||||
<padding>
|
||||
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
|
||||
</padding>
|
||||
</CheckBox>
|
||||
</children>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
</HBox>
|
||||
<HBox spacing="5.0">
|
||||
<children>
|
||||
<Label alignment="CENTER" prefWidth="80.0" style="-fx-font-weight: bold;" text="Mapper">
|
||||
<padding>
|
||||
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
|
||||
</padding>
|
||||
</Label>
|
||||
<CheckBox fx:id="mysqlCheckbox" mnemonicParsing="false" prefWidth="100.0" selected="true" text="MySQL">
|
||||
<padding>
|
||||
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
|
||||
</padding>
|
||||
</CheckBox>
|
||||
<Label alignment="CENTER" prefWidth="80.0" style="-fx-font-weight: bold;" text="TablePrefix" textAlignment="CENTER">
|
||||
<padding>
|
||||
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
|
||||
</padding>
|
||||
</Label>
|
||||
<TextField fx:id="tablePrefixTextField" prefWidth="100.0" promptText="表前缀" text="gen_" />
|
||||
</children>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
</HBox>
|
||||
<HBox spacing="5.0">
|
||||
<children>
|
||||
<Label alignment="CENTER" prefWidth="80.0" style="-fx-font-weight: bold;" text="Page" textAlignment="CENTER">
|
||||
<padding>
|
||||
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
|
||||
</padding>
|
||||
</Label>
|
||||
<CheckBox fx:id="htmlCheckbox" mnemonicParsing="false" prefWidth="100.0" selected="true" text="html">
|
||||
<padding>
|
||||
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
|
||||
</padding>
|
||||
</CheckBox>
|
||||
<CheckBox fx:id="thymeleafCheckbox" mnemonicParsing="false" prefWidth="100.0" selected="true" text="thymeleaf">
|
||||
<padding>
|
||||
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
|
||||
</padding>
|
||||
</CheckBox>
|
||||
<CheckBox fx:id="routeCheckbox" mnemonicParsing="false" prefWidth="100.0" selected="true" text="route">
|
||||
<padding>
|
||||
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
|
||||
</padding>
|
||||
</CheckBox>
|
||||
</children>
|
||||
<opaqueInsets>
|
||||
<Insets />
|
||||
</opaqueInsets>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
</HBox>
|
||||
<HBox spacing="5.0">
|
||||
<children>
|
||||
<Label alignment="CENTER" prefWidth="80.0" style="-fx-font-weight: bold;" text="Context" textAlignment="CENTER">
|
||||
<padding>
|
||||
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
|
||||
</padding>
|
||||
</Label>
|
||||
<TextField fx:id="contextTextField" prefWidth="100.0" promptText="项目路径" text="usercenter" />
|
||||
<Label alignment="CENTER" prefWidth="80.0" style="-fx-font-weight: bold;" text="Package" textAlignment="CENTER">
|
||||
<padding>
|
||||
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
|
||||
</padding>
|
||||
</Label>
|
||||
<TextField fx:id="packageTextField" prefWidth="100.0" promptText="代码基础包" text="ink.wgink" />
|
||||
<Button mnemonicParsing="false" text="Generator" />
|
||||
</children>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
</HBox>
|
||||
</children>
|
||||
</VBox>
|
||||
</top>
|
||||
<center>
|
||||
<HBox>
|
||||
<children>
|
||||
<TableView fx:id="fieldTableView" BorderPane.alignment="CENTER">
|
||||
<columns>
|
||||
<TableColumn maxWidth="50.0" minWidth="50.0" prefWidth="50.0" resizable="false" style="-fx-alignment: center;" text="行号" />
|
||||
<TableColumn prefWidth="250.0" style="-fx-alignment: center;" text="列名" />
|
||||
<TableColumn prefWidth="250.0" style="-fx-alignment: center;" text="列描述" />
|
||||
<TableColumn prefWidth="75.0" style="-fx-alignment: center;" text="列默认值" />
|
||||
<TableColumn prefWidth="150.0" style="-fx-alignment: center;" text="列类型" />
|
||||
<TableColumn prefWidth="250.0" style="-fx-alignment: center;" text="属性名" />
|
||||
<TableColumn prefWidth="100.0" style="-fx-alignment: center;" text="属性类型" />
|
||||
<TableColumn prefWidth="100.0" style="-fx-alignment: center;" text="属性长度" />
|
||||
<TableColumn style="-fx-alignment: center;" text="表单显示" />
|
||||
<TableColumn style="-fx-alignment: center;" text="列表显示" />
|
||||
<TableColumn style="-fx-alignment: center;" text="不可空" />
|
||||
<TableColumn prefWidth="150.0" style="-fx-alignment: center;" text="表单字段类型" />
|
||||
</columns>
|
||||
</TableView>
|
||||
</children>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
</HBox>
|
||||
</center>
|
||||
</BorderPane>
|
||||
</children>
|
||||
</AnchorPane>
|
49
src/main/resources/route/login.fxml
Normal file
49
src/main/resources/route/login.fxml
Normal file
@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
<?import java.lang.*?>
|
||||
<?import java.util.*?>
|
||||
<?import javafx.scene.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
|
||||
<AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ink.wgink.code.factory.controller.LoginController">
|
||||
<children>
|
||||
<GridPane alignment="CENTER" hgap="5.0" layoutX="200.0" layoutY="140.0" vgap="5.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="95.0" minWidth="10.0" prefWidth="49.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="158.0" minWidth="10.0" prefWidth="151.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="4">
|
||||
<children>
|
||||
<Button mnemonicParsing="false" onAction="#onAction" text="点击" />
|
||||
</children>
|
||||
</HBox>
|
||||
<Label text="用户名" GridPane.halignment="RIGHT" GridPane.rowIndex="1" />
|
||||
<Label text="密码" GridPane.halignment="RIGHT" GridPane.rowIndex="2" />
|
||||
<TextField prefHeight="23.0" prefWidth="116.0" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
||||
<PasswordField GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
||||
<Label text="欢迎" GridPane.columnIndex="1">
|
||||
<font>
|
||||
<Font size="18.0" />
|
||||
</font>
|
||||
</Label>
|
||||
</children>
|
||||
<padding>
|
||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||
</padding>
|
||||
<opaqueInsets>
|
||||
<Insets />
|
||||
</opaqueInsets>
|
||||
</GridPane>
|
||||
</children>
|
||||
</AnchorPane>
|
62
src/main/resources/route/main.fxml
Normal file
62
src/main/resources/route/main.fxml
Normal file
@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.*?>
|
||||
<?import java.lang.*?>
|
||||
<?import java.util.*?>
|
||||
<?import javafx.scene.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
|
||||
<AnchorPane prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ink.wgink.code.factory.controller.MainController">
|
||||
<children>
|
||||
<BorderPane layoutX="200.0" layoutY="100.0" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<top>
|
||||
<GridPane BorderPane.alignment="CENTER">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints halignment="CENTER" hgrow="SOMETIMES" maxWidth="95.0" minWidth="10.0" prefWidth="66.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="134.0" minWidth="10.0" prefWidth="121.0" />
|
||||
<ColumnConstraints halignment="CENTER" hgrow="SOMETIMES" maxWidth="93.0" minWidth="10.0" prefWidth="53.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="174.0" minWidth="10.0" prefWidth="94.0" />
|
||||
<ColumnConstraints halignment="CENTER" hgrow="SOMETIMES" maxWidth="122.0" minWidth="10.0" prefWidth="69.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="197.0" minWidth="10.0" prefWidth="188.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Label text="地址" />
|
||||
<TextField id="dbUrlField" fx:id="dbUrlField" onKeyReleased="#dbUrlReleased" promptText="数据库地址" text="127.0.0.1" GridPane.columnIndex="1" />
|
||||
<Label text="端口" GridPane.columnIndex="2" />
|
||||
<TextField id="dbPortField" fx:id="dbPortField" onKeyReleased="#dbPortReleased" promptText="数据库端口" text="3306" GridPane.columnIndex="3" />
|
||||
<Label text="数据库" GridPane.columnIndex="4" />
|
||||
<TextField id="dbNameField" fx:id="dbNameField" onKeyReleased="#dbNameReleased" promptText="数据库名称" text="db_wg_basic" GridPane.columnIndex="5" />
|
||||
<Label text="用户名" GridPane.rowIndex="1" />
|
||||
<TextField id="dbUsernameField" fx:id="dbUsernameField" onKeyReleased="#dbUsernameReleased" promptText="数据库用户名" text="root" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
||||
<Label text="密码" GridPane.columnIndex="2" GridPane.rowIndex="1" />
|
||||
<PasswordField id="dbPasswordField" fx:id="dbPasswordField" promptText="数据库密码" text="root" GridPane.columnIndex="3" GridPane.rowIndex="1" />
|
||||
<HBox alignment="CENTER_RIGHT" prefHeight="100.0" prefWidth="200.0" GridPane.columnIndex="5" GridPane.rowIndex="1">
|
||||
<children>
|
||||
<Button id="connectionDatabaseButton" fx:id="connectionDatabaseButton" mnemonicParsing="false" onAction="#onConnectDatabase" text="链接" />
|
||||
</children>
|
||||
</HBox>
|
||||
</children>
|
||||
</GridPane>
|
||||
</top>
|
||||
<center>
|
||||
<TableView fx:id="dbTableTableView" onMouseClicked="#onTableRowClick" prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
||||
<columns>
|
||||
<TableColumn maxWidth="50.0" minWidth="50.0" prefWidth="50.0" resizable="false" style="-fx-alignment: center;" text="行号" />
|
||||
<TableColumn prefWidth="250.0" style="-fx-alignment: center;" text="表名" />
|
||||
<TableColumn prefWidth="142.0" style="-fx-alignment: center;" text="描述" />
|
||||
<TableColumn prefWidth="138.0" style="-fx-alignment: center;" text="编码集合" />
|
||||
</columns>
|
||||
</TableView>
|
||||
</center>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
</BorderPane>
|
||||
</children>
|
||||
</AnchorPane>
|
Loading…
Reference in New Issue
Block a user