|
|
@ -1,7 +1,6 @@
|
|
|
|
package xyz.wbsite.dbtool.javafx.manger;
|
|
|
|
package xyz.wbsite.dbtool.javafx.manger;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.boot.system.ApplicationHome;
|
|
|
|
import org.springframework.boot.system.ApplicationHome;
|
|
|
|
import xyz.wbsite.dbtool.javafx.enums.DataBase;
|
|
|
|
|
|
|
|
import xyz.wbsite.dbtool.javafx.enums.FieldType;
|
|
|
|
import xyz.wbsite.dbtool.javafx.enums.FieldType;
|
|
|
|
import xyz.wbsite.dbtool.javafx.manger.callable.AndroidCallable;
|
|
|
|
import xyz.wbsite.dbtool.javafx.manger.callable.AndroidCallable;
|
|
|
|
import xyz.wbsite.dbtool.javafx.manger.callable.ApiCallable;
|
|
|
|
import xyz.wbsite.dbtool.javafx.manger.callable.ApiCallable;
|
|
|
@ -17,7 +16,6 @@ import xyz.wbsite.dbtool.javafx.po.MySQLDBmapper;
|
|
|
|
import xyz.wbsite.dbtool.javafx.po.OracleDBmapper;
|
|
|
|
import xyz.wbsite.dbtool.javafx.po.OracleDBmapper;
|
|
|
|
import xyz.wbsite.dbtool.javafx.po.Project;
|
|
|
|
import xyz.wbsite.dbtool.javafx.po.Project;
|
|
|
|
import xyz.wbsite.dbtool.javafx.po.SBMDBOption;
|
|
|
|
import xyz.wbsite.dbtool.javafx.po.SBMDBOption;
|
|
|
|
import xyz.wbsite.dbtool.javafx.po.SQLiteDBmapper;
|
|
|
|
|
|
|
|
import xyz.wbsite.dbtool.javafx.po.Table;
|
|
|
|
import xyz.wbsite.dbtool.javafx.po.Table;
|
|
|
|
import xyz.wbsite.dbtool.javafx.po.VueOption;
|
|
|
|
import xyz.wbsite.dbtool.javafx.po.VueOption;
|
|
|
|
import xyz.wbsite.dbtool.javafx.tool.Dialog;
|
|
|
|
import xyz.wbsite.dbtool.javafx.tool.Dialog;
|
|
|
@ -43,8 +41,8 @@ public class ProjectManager {
|
|
|
|
public static boolean isUpdate = false;
|
|
|
|
public static boolean isUpdate = false;
|
|
|
|
private XmlManager xmlService;
|
|
|
|
private XmlManager xmlService;
|
|
|
|
private JsonManager jsonManager;
|
|
|
|
private JsonManager jsonManager;
|
|
|
|
public static AbstractDBmapper dBmapper;
|
|
|
|
|
|
|
|
public static File path;
|
|
|
|
public static File path;
|
|
|
|
|
|
|
|
private ExecutorService service = Executors.newCachedThreadPool();
|
|
|
|
private Project project = new Project();
|
|
|
|
private Project project = new Project();
|
|
|
|
|
|
|
|
|
|
|
|
public ProjectManager() {
|
|
|
|
public ProjectManager() {
|
|
|
@ -324,32 +322,18 @@ public class ProjectManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static ExecutorService service = Executors.newFixedThreadPool(1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void tryGetDBmapper(Project project) {
|
|
|
|
|
|
|
|
if (project.getDatabase().equals(DataBase.MySQL.name())) {
|
|
|
|
|
|
|
|
dBmapper = new MySQLDBmapper();
|
|
|
|
|
|
|
|
} else if (project.getDatabase().equals(DataBase.Oracle.name())) {
|
|
|
|
|
|
|
|
dBmapper = new OracleDBmapper();
|
|
|
|
|
|
|
|
} else if (project.getDatabase().equals(DataBase.SQLite.name())) {
|
|
|
|
|
|
|
|
dBmapper = new SQLiteDBmapper();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 生成模板 入口
|
|
|
|
* 生成模板 入口
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param path
|
|
|
|
* @param root
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void generate(Project project, final String path) {
|
|
|
|
public void generate(Project project, final File root) {
|
|
|
|
tryGetDBmapper(project);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
File root = new File(path);
|
|
|
|
|
|
|
|
if (!root.exists()) {
|
|
|
|
if (!root.exists()) {
|
|
|
|
Dialog.showTimedDialog(1000, "目录不存在!");
|
|
|
|
Dialog.showTimedDialog(1000, "目录不存在!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Dialog.showProgress("生成中...");
|
|
|
|
Dialog.showProgress("生成中...");
|
|
|
|
new Thread() {
|
|
|
|
|
|
|
|
|
|
|
|
service.execute(new Runnable() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
Callable callback = new SpringBootCallable(project, path);
|
|
|
|
Callable callback = new SpringBootCallable(project, path);
|
|
|
@ -365,13 +349,14 @@ public class ProjectManager {
|
|
|
|
Dialog.stopPopup();
|
|
|
|
Dialog.stopPopup();
|
|
|
|
Dialog.showSuccess("生成完毕.");
|
|
|
|
Dialog.showSuccess("生成完毕.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}.start();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void generateApi(File module, File api, List<String> domainList, List<Api> apis) {
|
|
|
|
public void generateApi(File module, File api, List<String> domainList, List<Api> apis) {
|
|
|
|
if (module.exists()) {
|
|
|
|
if (module.exists()) {
|
|
|
|
Dialog.showProgress("生成中...");
|
|
|
|
Dialog.showProgress("生成中...");
|
|
|
|
new Thread() {
|
|
|
|
|
|
|
|
|
|
|
|
service.execute(new Runnable() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
boolean mkdirs = api.mkdirs();
|
|
|
|
boolean mkdirs = api.mkdirs();
|
|
|
@ -391,7 +376,7 @@ public class ProjectManager {
|
|
|
|
Dialog.stopPopup();
|
|
|
|
Dialog.stopPopup();
|
|
|
|
Dialog.showSuccess("Api生成完毕.");
|
|
|
|
Dialog.showSuccess("Api生成完毕.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}.start();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -401,6 +386,7 @@ public class ProjectManager {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
AndroidCallable androidCallable = new AndroidCallable(path, option);
|
|
|
|
AndroidCallable androidCallable = new AndroidCallable(path, option);
|
|
|
|
|
|
|
|
|
|
|
|
Future submit = service.submit(androidCallable);
|
|
|
|
Future submit = service.submit(androidCallable);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Boolean b = (Boolean) submit.get();
|
|
|
|
Boolean b = (Boolean) submit.get();
|
|
|
@ -425,6 +411,7 @@ public class ProjectManager {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
VueCallable vueCallable = new VueCallable(path, option);
|
|
|
|
VueCallable vueCallable = new VueCallable(path, option);
|
|
|
|
|
|
|
|
|
|
|
|
Future submit = service.submit(vueCallable);
|
|
|
|
Future submit = service.submit(vueCallable);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Boolean b = (Boolean) submit.get();
|
|
|
|
Boolean b = (Boolean) submit.get();
|
|
|
@ -449,6 +436,7 @@ public class ProjectManager {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
SBMDBCallable callable = new SBMDBCallable(path, option);
|
|
|
|
SBMDBCallable callable = new SBMDBCallable(path, option);
|
|
|
|
|
|
|
|
|
|
|
|
Future submit = service.submit(callable);
|
|
|
|
Future submit = service.submit(callable);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Boolean b = (Boolean) submit.get();
|
|
|
|
Boolean b = (Boolean) submit.get();
|
|
|
@ -520,9 +508,9 @@ public class ProjectManager {
|
|
|
|
String driverClassName = properties.get("driverClassName");
|
|
|
|
String driverClassName = properties.get("driverClassName");
|
|
|
|
Connection cn = null;
|
|
|
|
Connection cn = null;
|
|
|
|
|
|
|
|
|
|
|
|
if ("Orcale".equals(type)) {
|
|
|
|
if ("Oracle".equals(type)) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
dBmapper = new OracleDBmapper();
|
|
|
|
AbstractDBmapper dBmapper = new OracleDBmapper();
|
|
|
|
|
|
|
|
|
|
|
|
//加载驱动类
|
|
|
|
//加载驱动类
|
|
|
|
Class.forName(driverClassName);
|
|
|
|
Class.forName(driverClassName);
|
|
|
@ -593,7 +581,7 @@ public class ProjectManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if ("Mysql".equals(type)) {
|
|
|
|
} else if ("Mysql".equals(type)) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
dBmapper = new MySQLDBmapper();
|
|
|
|
AbstractDBmapper dBmapper = new MySQLDBmapper();
|
|
|
|
|
|
|
|
|
|
|
|
//加载驱动类
|
|
|
|
//加载驱动类
|
|
|
|
Class.forName(driverClassName);
|
|
|
|
Class.forName(driverClassName);
|
|
|
@ -665,7 +653,6 @@ public class ProjectManager {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|