From 473dfffe50109a10113b0145c2ba7cddeb716e4e Mon Sep 17 00:00:00 2001 From: wangbing Date: Thu, 28 Feb 2019 17:21:55 +0800 Subject: [PATCH] =?UTF-8?q?SpringBoot=20Cloud=20=E5=88=86=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dbtool/javafx/manger/ProjectManager.java | 5 +++- .../manger/callable/SpringBootCallable.java | 6 ++++- src/main/resources/fxml/generateOption.fxml | 9 ++++--- src/main/resources/modules/SpringBoot/pom.ftl | 2 ++ .../SpringBoot/resources/application-dev.ftl | 2 ++ .../SpringBoot/resources/application-prod.ftl | 2 ++ .../resources/templates/screen/index.ftl | 24 ++++++++++++------- 7 files changed, 35 insertions(+), 15 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 dc4e0a8a..f7386ce5 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/manger/ProjectManager.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/ProjectManager.java @@ -254,7 +254,10 @@ public class ProjectManager { Callable callback = null; switch (option) { case "SpringBoot": - callback = new SpringBootCallable(path, dataBase, project, option); + callback = new SpringBootCallable(path, dataBase, project, option, false); + break; + case "SpringBoot+Cloud": + callback = new SpringBootCallable(path, dataBase, project, "SpringBoot", true); break; case "SpringMVC_Mybatis": // callback = new SpringMVCMybatisCallable(path, dataBase, project, option); 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 6c4de0df..db395257 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 @@ -24,14 +24,16 @@ public class SpringBootCallable implements Callable { private DataBase dataBase; private Project project; private String option; + private boolean cloud; private FreeMarkerManager freeMarkerManager; - public SpringBootCallable(String root, DataBase dataBase, Project project, String option) { + public SpringBootCallable(String root, DataBase dataBase, Project project, String option,boolean cloud) { this.root = root; this.dataBase = dataBase; this.project = project; this.option = option; + this.cloud = cloud; this.freeMarkerManager = ManagerFactory.getFreeMarkerManager(); } @@ -162,6 +164,7 @@ public class SpringBootCallable implements Callable { ctx.put("projectName", project.getProjectName()); ctx.put("basePackage", project.getProjectBasePackage()); ctx.put("dataBase", dataBase.toString()); + ctx.put("cloud", cloud); File file = new File(root.getAbsolutePath(), "pom.xml"); @@ -522,6 +525,7 @@ public class SpringBootCallable implements Callable { ctx.put("dBmapper", dBmapper); ctx.put("date", new Date()); ctx.put("projectName", project.getProjectName()); + ctx.put("cloud", cloud); freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), "start-dev.bat"), option + "/resources/start-dev.bat", ctx); freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), "start-prod.bat"), option + "/resources/start-prod.bat", ctx); freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), "application-dev.properties"), option + "/resources/application-dev.ftl", ctx); diff --git a/src/main/resources/fxml/generateOption.fxml b/src/main/resources/fxml/generateOption.fxml index 50cfb1e8..ba9bf489 100644 --- a/src/main/resources/fxml/generateOption.fxml +++ b/src/main/resources/fxml/generateOption.fxml @@ -1,7 +1,5 @@ - - - + - diff --git a/src/main/resources/modules/SpringBoot/pom.ftl b/src/main/resources/modules/SpringBoot/pom.ftl index cfa524d0..aa3cb871 100644 --- a/src/main/resources/modules/SpringBoot/pom.ftl +++ b/src/main/resources/modules/SpringBoot/pom.ftl @@ -56,6 +56,7 @@ spring-boot-starter-freemarker +<#if cloud> org.springframework.cloud @@ -71,6 +72,7 @@ org.springframework.cloud spring-cloud-starter-openfeign + org.springframework.boot diff --git a/src/main/resources/modules/SpringBoot/resources/application-dev.ftl b/src/main/resources/modules/SpringBoot/resources/application-dev.ftl index 718cfdd1..463acca4 100644 --- a/src/main/resources/modules/SpringBoot/resources/application-dev.ftl +++ b/src/main/resources/modules/SpringBoot/resources/application-dev.ftl @@ -4,7 +4,9 @@ server.servlet.context-path=/ spring.mvc.static-path-pattern=/static/** spring.resources.static-locations=classpath:static/ spring.application.name=${projectName} +<#if cloud> eureka.client.serviceUrl.defaultZone=http://localhost:18080/eureka/ + # 编码配置 spring.http.encoding.force=true spring.http.encoding.charset=UTF-8 diff --git a/src/main/resources/modules/SpringBoot/resources/application-prod.ftl b/src/main/resources/modules/SpringBoot/resources/application-prod.ftl index cc209e52..dd4d2da2 100644 --- a/src/main/resources/modules/SpringBoot/resources/application-prod.ftl +++ b/src/main/resources/modules/SpringBoot/resources/application-prod.ftl @@ -5,7 +5,9 @@ spring.mvc.static-path-pattern=/static/** spring.resources.static-locations=classpath:static/ spring.application.name=${projectName} spring.main.banner-mode=off +<#if cloud> eureka.client.serviceUrl.defaultZone=http://localhost:18080/eureka/ + # 编码配置 spring.http.encoding.force=true spring.http.encoding.charset=UTF-8 diff --git a/src/main/resources/modules/SpringBoot/resources/templates/screen/index.ftl b/src/main/resources/modules/SpringBoot/resources/templates/screen/index.ftl index c69a00d0..bfcc1287 100644 --- a/src/main/resources/modules/SpringBoot/resources/templates/screen/index.ftl +++ b/src/main/resources/modules/SpringBoot/resources/templates/screen/index.ftl @@ -5328,13 +5328,13 @@

-    ajax.example({}).then(function (response) {
-        if (response.errors.length > 0) {
-            nav.e(response.errors[0].message);
-        } else {
-            nav.i("Ajax调用成功!");
-        }
-    })
+ajax.example({}).then(function (response) {
+    if (response.errors.length > 0) {
+        nav.e(response.errors[0].message);
+    } else {
+        nav.i("Ajax调用成功!");
+    }
+})
                     
@@ -5367,7 +5367,15 @@

-
+ajax.fileUpload(req.file).then(function (response) {
+    if (response.errors.length > 0) {
+        req.onError();
+        nav.e(response.errors[0].message);
+    } else {
+        req.onSuccess();
+        nav.i("文件上传成功!");
+    }
+})