From 00e6451242938bf1177148d89b577fe732aaad00 Mon Sep 17 00:00:00 2001 From: wangbing Date: Mon, 20 May 2019 23:43:43 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81ajax=20es6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dbtool/javafx/manger/ProjectManager.java | 14 +++++ .../dbtool/javafx/manger/XmlManager.java | 14 ++--- .../manger/callable/SpringBootCallable.java | 28 ++++----- .../xyz/wbsite/dbtool/javafx/po/Table.java | 58 +++++++++---------- .../xyz/wbsite/dbtool/javafx/tool/Dialog.java | 20 +++---- .../SpringBoot/java/mpr/mapper_nosys.ftl | 1 + .../SpringBoot/resources/application-dev.ftl | 2 +- .../SpringBoot/test/application.properties | 21 +++---- 8 files changed, 87 insertions(+), 71 deletions(-) diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/manger/ProjectManager.java b/src/main/java/xyz/wbsite/dbtool/javafx/manger/ProjectManager.java index d87439fa..9bc24d69 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/manger/ProjectManager.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/ProjectManager.java @@ -418,6 +418,13 @@ public class ProjectManager { while (rs.next()) { Table table = new Table(rs.getString("table_name"), rs.getString("comments")); + table.setCreate(true); + table.setDelete(true); + table.setUpdate(true); + table.setFind(true); + table.setGet(false); + table.setGetAll(false); + table.setSearch(false); md.putTable(table); } @@ -486,6 +493,13 @@ public class ProjectManager { while (rs.next()) { Table table = new Table(rs.getString("TABLE_NAME"), rs.getString("TABLE_COMMENT")); + table.setCreate(true); + table.setDelete(true); + table.setUpdate(true); + table.setFind(true); + table.setGet(false); + table.setGetAll(false); + table.setSearch(false); md.putTable(table); } diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/manger/XmlManager.java b/src/main/java/xyz/wbsite/dbtool/javafx/manger/XmlManager.java index 66fc4e9a..bc73dd8e 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/manger/XmlManager.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/XmlManager.java @@ -193,13 +193,13 @@ public class XmlManager { Element table = doc.createElement("table"); table.setAttribute("tableName", t.getTableName()); table.setAttribute("tableComment", t.getTableComment()); - table.setAttribute("create", t.getCreate().toString()); - table.setAttribute("delete", t.getDelete().toString()); - table.setAttribute("update", t.getUpdate().toString()); - table.setAttribute("find", t.getFind().toString()); - table.setAttribute("get", t.getGet().toString()); - table.setAttribute("search", t.getSearch().toString()); - table.setAttribute("getAll", t.getGetAll().toString()); + table.setAttribute("create", Boolean.toString(t.getCreate())); + table.setAttribute("delete", Boolean.toString(t.getDelete())); + table.setAttribute("update", Boolean.toString(t.getUpdate())); + table.setAttribute("find", Boolean.toString(t.getFind())); + table.setAttribute("get", Boolean.toString(t.getGet())); + table.setAttribute("search", Boolean.toString(t.getSearch())); + table.setAttribute("getAll", Boolean.toString(t.getGetAll())); Element fields = doc.createElement("fields"); diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java b/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java index 4bafbe65..d6d6ed51 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java @@ -396,30 +396,30 @@ public class SpringBootCallable implements Callable { for (Table table : md.getTables()) { ctx.put("table", table); - if (table.getCreate() != null && table.getCreate()) { + if (table.getCreate()) { freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "CreateRequest" + ".java"), option + "/java/req/createRequestClass.ftl", ctx); } - if (table.getDelete() != null && table.getDelete()) { + if (table.getDelete()) { freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "DeleteRequest" + ".java"), option + "/java/req/deleteRequestClass.ftl", ctx); } - if (table.getUpdate() != null && table.getUpdate()) { + if (table.getUpdate()) { freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "UpdateRequest" + ".java"), option + "/java/req/updateRequestClass.ftl", ctx); } - if (table.getFind() != null && table.getFind()) { + if (table.getFind()) { freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "FindRequest" + ".java"), option + "/java/req/findRequestClass.ftl", ctx); } - if (table.getGet() != null && table.getGet()) { + if (table.getGet()) { freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "GetRequest" + ".java"), option + "/java/req/getRequestClass.ftl", ctx); } - if (table.getSearch() != null && table.getSearch()) { + if (table.getSearch()) { freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "SearchRequest" + ".java"), option + "/java/req/searchRequestClass.ftl", ctx); } - if (table.getGetAll() != null && table.getGetAll()) { + if (table.getGetAll()) { freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "GetAllRequest" + ".java"), option + "/java/req/getAllRequestClass.ftl", ctx); } } @@ -453,30 +453,30 @@ public class SpringBootCallable implements Callable { for (Table table : md.getTables()) { ctx.put("table", table); - if (table.getCreate() != null && table.getCreate()) { + if (table.getCreate()) { freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "CreateResponse" + ".java"), option + "/java/rsp/createResponseClass.ftl", ctx); } - if (table.getDelete() != null && table.getDelete()) { + if (table.getDelete()) { freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "DeleteResponse" + ".java"), option + "/java/rsp/deleteResponseClass.ftl", ctx); } - if (table.getUpdate() != null && table.getUpdate()) { + if (table.getUpdate()) { freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "UpdateResponse" + ".java"), option + "/java/rsp/updateResponseClass.ftl", ctx); } - if (table.getFind() != null && table.getFind()) { + if (table.getFind()) { freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "FindResponse" + ".java"), option + "/java/rsp/findResponseClass.ftl", ctx); } - if (table.getGet() != null && table.getGet()) { + if (table.getGet()) { freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "GetResponse" + ".java"), option + "/java/rsp/getResponseClass.ftl", ctx); } - if (table.getSearch() != null && table.getSearch()) { + if (table.getSearch()) { freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "SearchResponse" + ".java"), option + "/java/rsp/searchResponseClass.ftl", ctx); } - if (table.getGetAll() != null && table.getGetAll()) { + if (table.getGetAll()) { freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "GetAllResponse" + ".java"), option + "/java/rsp/getAllResponseClass.ftl", ctx); } } diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/po/Table.java b/src/main/java/xyz/wbsite/dbtool/javafx/po/Table.java index 1417da02..e11c4bae 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/po/Table.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/po/Table.java @@ -35,13 +35,13 @@ public class Table extends TreeItem { */ private String tableComment; - private Boolean create = true; - private Boolean delete = true; - private Boolean update = true; - private Boolean find = true; - private Boolean get = true; - private Boolean search = false; - private Boolean getAll = false; + private boolean create = true; + private boolean delete = true; + private boolean update = true; + private boolean find = true; + private boolean get = true; + private boolean search = false; + private boolean getAll = false; /** * 对象字段 @@ -111,7 +111,7 @@ public class Table extends TreeItem { } public void setTableComment(String tableComment) { - this.tableComment = tableComment!=null?tableComment:""; + this.tableComment = tableComment != null ? tableComment : ""; } public List getFields() { @@ -130,59 +130,59 @@ public class Table extends TreeItem { this.dBhandle = dBhandle; } - public Boolean getCreate() { - return create || !dBhandle.isHasSysFields(); + public boolean getCreate() { + return create; } - public void setCreate(Boolean create) { + public void setCreate(boolean create) { this.create = create; } - public Boolean getDelete() { - return delete || !dBhandle.isHasSysFields(); + public boolean getDelete() { + return delete; } - public void setDelete(Boolean delete) { + public void setDelete(boolean delete) { this.delete = delete; } - public Boolean getUpdate() { - return update || !dBhandle.isHasSysFields(); + public boolean getUpdate() { + return update; } - public void setUpdate(Boolean update) { + public void setUpdate(boolean update) { this.update = update; } - public Boolean getFind() { - return find || !dBhandle.isHasSysFields(); + public boolean getFind() { + return find; } - public void setFind(Boolean find) { + public void setFind(boolean find) { this.find = find; } - public Boolean getGet() { - return get && dBhandle.isHasSysFields(); + public boolean getGet() { + return get; } - public void setGet(Boolean get) { + public void setGet(boolean get) { this.get = get; } - public Boolean getSearch() { - return search && dBhandle.isHasSysFields(); + public boolean getSearch() { + return search; } - public void setSearch(Boolean search) { + public void setSearch(boolean search) { this.search = search; } - public Boolean getGetAll() { - return getAll && dBhandle.isHasSysFields(); + public boolean getGetAll() { + return getAll; } - public void setGetAll(Boolean getAll) { + public void setGetAll(boolean getAll) { this.getAll = getAll; } } diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/tool/Dialog.java b/src/main/java/xyz/wbsite/dbtool/javafx/tool/Dialog.java index 61cf3f13..7365dfe6 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/tool/Dialog.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/tool/Dialog.java @@ -51,9 +51,9 @@ public class Dialog { }); VBox root = new VBox(); - root.setPadding(new Insets(20)); + root.setPadding(new Insets(10)); root.setAlignment(Pos.BASELINE_CENTER); - root.setSpacing(20); + root.setSpacing(10); root.getChildren().addAll(new Label(message), closeBtn); Scene scene = new Scene(root); popup.setScene(scene); @@ -84,10 +84,10 @@ public class Dialog { public static void showConfirmDialog(String message) { popup = new Stage(); - popup.setWidth(200); + popup.setWidth(250); popup.setHeight(160); popup.setAlwaysOnTop(true); - popup.initModality(Modality.APPLICATION_MODAL); + popup.initModality(Modality.WINDOW_MODAL); final Button closeBtn = new Button("确认"); closeBtn.setOnAction(new EventHandler() { @Override @@ -97,9 +97,9 @@ public class Dialog { }); VBox root = new VBox(); - root.setPadding(new Insets(20)); + root.setPadding(new Insets(10)); root.setAlignment(Pos.BASELINE_CENTER); - root.setSpacing(20); + root.setSpacing(10); Label label = new Label(message); root.getChildren().addAll(label, closeBtn); Scene scene = new Scene(root); @@ -111,7 +111,7 @@ public class Dialog { public static void showConfirmDialog(String message, EventHandler handler) { popup = new Stage(); popup.setAlwaysOnTop(true); - popup.setWidth(200); + popup.setWidth(250); popup.setHeight(160); popup.initModality(Modality.APPLICATION_MODAL); final Button okBtn = new Button("确认"); @@ -124,9 +124,9 @@ public class Dialog { }); VBox root = new VBox(); - root.setPadding(new Insets(20)); + root.setPadding(new Insets(10)); root.setAlignment(Pos.BASELINE_CENTER); - root.setSpacing(20); + root.setSpacing(10); Label label = new Label(message); root.getChildren().addAll(label, okBtn); Scene scene = new Scene(root); @@ -173,7 +173,7 @@ public class Dialog { VBox root = new VBox(); root.setPadding(new Insets(50, 80, 50, 80)); root.setAlignment(Pos.BASELINE_CENTER); - root.setSpacing(20); + root.setSpacing(10); Label label = new Label(message); root.getChildren().addAll(indicator, label); diff --git a/src/main/resources/modules/SpringBoot/java/mpr/mapper_nosys.ftl b/src/main/resources/modules/SpringBoot/java/mpr/mapper_nosys.ftl index ae72ad62..4d68cb55 100644 --- a/src/main/resources/modules/SpringBoot/java/mpr/mapper_nosys.ftl +++ b/src/main/resources/modules/SpringBoot/java/mpr/mapper_nosys.ftl @@ -31,6 +31,7 @@ FROM WHERE + 1 = 1 <#list table.fields as f> <#if f.isQuery> <#if dataBase == 'ORACLE'> diff --git a/src/main/resources/modules/SpringBoot/resources/application-dev.ftl b/src/main/resources/modules/SpringBoot/resources/application-dev.ftl index ed6f8e9a..f74dc4ac 100644 --- a/src/main/resources/modules/SpringBoot/resources/application-dev.ftl +++ b/src/main/resources/modules/SpringBoot/resources/application-dev.ftl @@ -3,7 +3,7 @@ server.port=8080 server.servlet.context-path=/ spring.mvc.static-path-pattern=/static/** spring.resources.static-locations=classpath:static/ -spring.application.name=${projectName} +spring.application.name=${projectName?default("SpringBoot")} spring.main.banner-mode=CONSOLE spring.devtools.restart.enabled=true <#if cloud> diff --git a/src/main/resources/modules/SpringBoot/test/application.properties b/src/main/resources/modules/SpringBoot/test/application.properties index f28d3e71..fc7159a4 100644 --- a/src/main/resources/modules/SpringBoot/test/application.properties +++ b/src/main/resources/modules/SpringBoot/test/application.properties @@ -1,25 +1,26 @@ -# 开发环境 +# 测试环境 server.port=8080 server.servlet.context-path=/ spring.mvc.static-path-pattern=/static/** spring.resources.static-locations=classpath:static/ -spring.application.name=SpringBoot +spring.application.name=${projectName?default("SpringBoot")} +spring.main.banner-mode=CONSOLE +spring.devtools.restart.enabled=true # 编码配置 spring.http.encoding.force=true spring.http.encoding.charset=UTF-8 spring.http.encoding.enabled=true server.tomcat.uri-encoding=UTF-8 # 根路径、欢迎页 -web.welcome.page = index -# 排除的不需要验证的URL -web.url.excluded = /static/**,/open/**,/api,/index,/,/login -web.url.authorization = /** -# 默认的登录URL -web.url.login = /login +web.welcome.page=/index.htm +# 需要验证授权, 既访问时组装Token +web.url.auth.included=/** +# 不需要验证授权, 或该请求有自己的验证机制 +web.url.auth.excluded=/favicon.ico,/static/**,/api,/login.htm # 日志配置 +logging.path=D:// +logging.levels=DEBUG logging.config=classpath:logback-config.xml -# 热部署生效 -spring.devtools.restart.enabled=true <#if dataBase == 'ORACLE'> # oracle spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver