From fe4729845f61bf8056625e5e902907855993e704 Mon Sep 17 00:00:00 2001 From: wangbing <1919101440@qq.com> Date: Thu, 12 Dec 2019 23:48:07 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: 8b466082d199ce5f8eea016fed5ea1b8627677f7 --- .../javafx/manger/callable/ApiCallable.java | 64 +++++++++++-------- .../resources/modules/Java_api/AESUtil.java | 2 +- .../resources/modules/Java_api/ApiClient.java | 2 +- .../resources/modules/Java_api/ApiEntity.java | 2 +- .../modules/Java_api/ApiFindRequest.java | 2 +- .../modules/Java_api/ApiFindResponse.java | 2 +- .../modules/Java_api/ApiRequest.java | 2 +- .../modules/Java_api/ApiResponse.java | 2 +- .../modules/Java_api/ApiSearchRequest.java | 2 +- .../resources/modules/Java_api/ApiTest.java | 4 +- .../modules/Java_api/Base64Util.java | 2 +- .../modules/Java_api/DownloadUtil.java | 2 +- .../resources/modules/Java_api/Error.java | 2 +- .../resources/modules/Java_api/ErrorType.java | 2 +- .../resources/modules/Java_api/MD5Util.java | 2 +- src/main/resources/modules/Java_api/Main.java | 2 +- .../modules/Java_api/MapperUtil.java | 2 +- .../modules/Java_api/ProgressRequestBody.java | 2 +- .../resources/modules/Java_api/RSAUtil.java | 2 +- .../resources/modules/Java_api/SortType.java | 2 +- .../modules/Java_api/StringUtils.java | 2 +- .../modules/Java_api/ValidationUtil.java | 2 +- .../modules/Java_api/module/ent/entity.java | 4 +- .../modules/Java_api/module/req/request.java | 12 ++-- .../modules/Java_api/module/rsp/response.java | 8 +-- 25 files changed, 71 insertions(+), 61 deletions(-) diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/ApiCallable.java b/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/ApiCallable.java index 8ece910a..dc1126cd 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/ApiCallable.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/ApiCallable.java @@ -27,6 +27,7 @@ public class ApiCallable implements Callable { private List domainList; private Tool tool = new Tool(); File domain; + File frame; File testdomain; private FreeMarkerManager freeMarkerManager; @@ -65,8 +66,8 @@ public class ApiCallable implements Callable { sbtest.append(s1 + File.separator); } - domain = new File(sbmain.toString()); - domain.mkdirs(); + domain = Tool.createPath(sbmain.toString(),"module"); + frame = Tool.createPath(sbmain.toString(),"frame"); testdomain = new File(sbtest.toString()); testdomain.mkdirs(); @@ -102,77 +103,77 @@ public class ApiCallable implements Callable { HashMap ctx = new HashMap(); ctx.put("domain", String.join(".", domainList)); { - File file = new File(domain, "ApiEntity.java"); + File file = new File(frame, "ApiEntity.java"); freeMarkerManager.outputTemp(file, "/Java_api/ApiEntity.java", ctx); } { - File file = new File(domain, "AESUtil.java"); + File file = new File(frame, "AESUtil.java"); freeMarkerManager.outputTemp(file, "/Java_api/AESUtil.java", ctx); } { - File file = new File(domain, "ApiClient.java"); + File file = new File(frame, "ApiClient.java"); freeMarkerManager.outputTemp(file, "/Java_api/ApiClient.java", ctx); } { - File file = new File(domain, "ApiRequest.java"); + File file = new File(frame, "ApiRequest.java"); freeMarkerManager.outputTemp(file, "/Java_api/ApiRequest.java", ctx); } { - File file = new File(domain, "ApiFindRequest.java"); + File file = new File(frame, "ApiFindRequest.java"); freeMarkerManager.outputTemp(file, "/Java_api/ApiFindRequest.java", ctx); } { - File file = new File(domain, "ApiSearchRequest.java"); + File file = new File(frame, "ApiSearchRequest.java"); freeMarkerManager.outputTemp(file, "/Java_api/ApiSearchRequest.java", ctx); } { - File file = new File(domain, "ApiResponse.java"); + File file = new File(frame, "ApiResponse.java"); freeMarkerManager.outputTemp(file, "/Java_api/ApiResponse.java", ctx); } { - File file = new File(domain, "ApiFindResponse.java"); + File file = new File(frame, "ApiFindResponse.java"); freeMarkerManager.outputTemp(file, "/Java_api/ApiFindResponse.java", ctx); } { - File file = new File(domain, "Base64Util.java"); + File file = new File(frame, "Base64Util.java"); freeMarkerManager.outputTemp(file, "/Java_api/Base64Util.java", ctx); } { - File file = new File(domain, "DownloadUtil.java"); + File file = new File(frame, "DownloadUtil.java"); freeMarkerManager.outputTemp(file, "/Java_api/DownloadUtil.java", ctx); } { - File file = new File(domain, "Error.java"); + File file = new File(frame, "Error.java"); freeMarkerManager.outputTemp(file, "/Java_api/Error.java", ctx); } { - File file = new File(domain, "ErrorType.java"); + File file = new File(frame, "ErrorType.java"); freeMarkerManager.outputTemp(file, "/Java_api/ErrorType.java", ctx); } { - File file = new File(domain, "MapperUtil.java"); + File file = new File(frame, "MapperUtil.java"); freeMarkerManager.outputTemp(file, "/Java_api/MapperUtil.java", ctx); } { - File file = new File(domain, "MD5Util.java"); + File file = new File(frame, "MD5Util.java"); freeMarkerManager.outputTemp(file, "/Java_api/MD5Util.java", ctx); } { - File file = new File(domain, "RSAUtil.java"); + File file = new File(frame, "RSAUtil.java"); freeMarkerManager.outputTemp(file, "/Java_api/RSAUtil.java", ctx); } { - File file = new File(domain, "ProgressRequestBody.java"); + File file = new File(frame, "ProgressRequestBody.java"); freeMarkerManager.outputTemp(file, "/Java_api/ProgressRequestBody.java", ctx); } { - File file = new File(domain, "SortType.java"); + File file = new File(frame, "SortType.java"); freeMarkerManager.outputTemp(file, "/Java_api/SortType.java", ctx); } { - File file = new File(domain, "StringUtils.java"); + File file = new File(frame, "StringUtils.java"); freeMarkerManager.outputTemp(file, "/Java_api/StringUtils.java", ctx); } @@ -215,20 +216,29 @@ public class ApiCallable implements Callable { } List entNames = new ArrayList<>(); - for (String s : reader.getDeptEntList()) { - Pattern compile = Pattern.compile("(.*\\.ent)\\.(.*)"); - Matcher matcher = compile.matcher(s); + for (String entName : reader.getDeptEntList()) { + if (entName.matches("(.*\\.ent)\\.(.*)")){ + Pattern compile = Pattern.compile("(.*\\.ent)\\.(.*)"); + Matcher matcher = compile.matcher(entName); - if (matcher.find()) { - String EntName = matcher.group(2); - entNames.add(EntName); + if (matcher.find()) { + String EntName = matcher.group(2); + entNames.add(EntName); - List files = Tool.findEntity(this.module, EntName + ".java"); + List files = Tool.findEntity(this.module, EntName + ".java"); + for (File file : files) { + EntityReader entReader = new EntityReader(file); + generateEntity(entReader); + } + } + }else { + List files = Tool.findEntity(this.module, entName + ".java"); for (File file : files) { EntityReader entReader = new EntityReader(file); generateEntity(entReader); } } + } List reqNames = new ArrayList<>(); diff --git a/src/main/resources/modules/Java_api/AESUtil.java b/src/main/resources/modules/Java_api/AESUtil.java index 79d32685..ef8f473b 100644 --- a/src/main/resources/modules/Java_api/AESUtil.java +++ b/src/main/resources/modules/Java_api/AESUtil.java @@ -1,4 +1,4 @@ -package ${domain}; +package ${domain}.frame; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; diff --git a/src/main/resources/modules/Java_api/ApiClient.java b/src/main/resources/modules/Java_api/ApiClient.java index b254552d..940ae1c7 100644 --- a/src/main/resources/modules/Java_api/ApiClient.java +++ b/src/main/resources/modules/Java_api/ApiClient.java @@ -1,4 +1,4 @@ -package ${domain}; +package ${domain}.frame; import okhttp3.*; diff --git a/src/main/resources/modules/Java_api/ApiEntity.java b/src/main/resources/modules/Java_api/ApiEntity.java index b6113f77..71b9cda2 100644 --- a/src/main/resources/modules/Java_api/ApiEntity.java +++ b/src/main/resources/modules/Java_api/ApiEntity.java @@ -1,4 +1,4 @@ -package ${domain}; +package ${domain}.frame; import java.util.Date; diff --git a/src/main/resources/modules/Java_api/ApiFindRequest.java b/src/main/resources/modules/Java_api/ApiFindRequest.java index 7404deb4..b597a023 100644 --- a/src/main/resources/modules/Java_api/ApiFindRequest.java +++ b/src/main/resources/modules/Java_api/ApiFindRequest.java @@ -1,4 +1,4 @@ -package ${domain}; +package ${domain}.frame; /** * ApiFindRequest - 基类 diff --git a/src/main/resources/modules/Java_api/ApiFindResponse.java b/src/main/resources/modules/Java_api/ApiFindResponse.java index 3232f14f..227bdac4 100644 --- a/src/main/resources/modules/Java_api/ApiFindResponse.java +++ b/src/main/resources/modules/Java_api/ApiFindResponse.java @@ -1,4 +1,4 @@ -package ${domain}; +package ${domain}.frame; import java.util.List; diff --git a/src/main/resources/modules/Java_api/ApiRequest.java b/src/main/resources/modules/Java_api/ApiRequest.java index a6383c4e..b0b3e665 100644 --- a/src/main/resources/modules/Java_api/ApiRequest.java +++ b/src/main/resources/modules/Java_api/ApiRequest.java @@ -1,4 +1,4 @@ -package ${domain}; +package ${domain}.frame; /** * ApiRequest - 基类 diff --git a/src/main/resources/modules/Java_api/ApiResponse.java b/src/main/resources/modules/Java_api/ApiResponse.java index 3c77a15a..02c33052 100644 --- a/src/main/resources/modules/Java_api/ApiResponse.java +++ b/src/main/resources/modules/Java_api/ApiResponse.java @@ -1,4 +1,4 @@ -package ${domain}; +package ${domain}.frame; import java.io.Serializable; import java.util.ArrayList; diff --git a/src/main/resources/modules/Java_api/ApiSearchRequest.java b/src/main/resources/modules/Java_api/ApiSearchRequest.java index 1813d43d..d27c53d0 100644 --- a/src/main/resources/modules/Java_api/ApiSearchRequest.java +++ b/src/main/resources/modules/Java_api/ApiSearchRequest.java @@ -1,4 +1,4 @@ -package ${domain}; +package ${domain}.frame; /** * ApiSearchRequest - 基类 diff --git a/src/main/resources/modules/Java_api/ApiTest.java b/src/main/resources/modules/Java_api/ApiTest.java index 86586124..0811eebe 100644 --- a/src/main/resources/modules/Java_api/ApiTest.java +++ b/src/main/resources/modules/Java_api/ApiTest.java @@ -1,8 +1,8 @@ package ${domain}; <#list modules as module> -import ${domain}.${module}.req.*; -import ${domain}.${module}.rsp.*; +import ${domain}.module.${module}.req.*; +import ${domain}.module.${module}.rsp.*; import org.junit.Assert; import org.junit.Before; diff --git a/src/main/resources/modules/Java_api/Base64Util.java b/src/main/resources/modules/Java_api/Base64Util.java index a53c970d..7350cd12 100644 --- a/src/main/resources/modules/Java_api/Base64Util.java +++ b/src/main/resources/modules/Java_api/Base64Util.java @@ -1,4 +1,4 @@ -package ${domain}; +package ${domain}.frame; import java.util.Arrays; diff --git a/src/main/resources/modules/Java_api/DownloadUtil.java b/src/main/resources/modules/Java_api/DownloadUtil.java index 78d5194a..63f5d4bd 100644 --- a/src/main/resources/modules/Java_api/DownloadUtil.java +++ b/src/main/resources/modules/Java_api/DownloadUtil.java @@ -1,4 +1,4 @@ -package ${domain}; +package ${domain}.frame; import okhttp3.*; diff --git a/src/main/resources/modules/Java_api/Error.java b/src/main/resources/modules/Java_api/Error.java index d020fd5c..e47ae079 100644 --- a/src/main/resources/modules/Java_api/Error.java +++ b/src/main/resources/modules/Java_api/Error.java @@ -1,4 +1,4 @@ -package ${domain}; +package ${domain}.frame; public class Error { private ErrorType type; diff --git a/src/main/resources/modules/Java_api/ErrorType.java b/src/main/resources/modules/Java_api/ErrorType.java index 32a1d873..5c9b77d2 100644 --- a/src/main/resources/modules/Java_api/ErrorType.java +++ b/src/main/resources/modules/Java_api/ErrorType.java @@ -1,4 +1,4 @@ -package ${domain}; +package ${domain}.frame; public enum ErrorType { BUSINESS_ERROR, diff --git a/src/main/resources/modules/Java_api/MD5Util.java b/src/main/resources/modules/Java_api/MD5Util.java index fc2c7a7f..548ac561 100644 --- a/src/main/resources/modules/Java_api/MD5Util.java +++ b/src/main/resources/modules/Java_api/MD5Util.java @@ -1,4 +1,4 @@ -package ${domain}; +package ${domain}.frame; import com.fasterxml.jackson.core.TreeNode; import java.security.MessageDigest; diff --git a/src/main/resources/modules/Java_api/Main.java b/src/main/resources/modules/Java_api/Main.java index 76e71588..61d9d7d6 100644 --- a/src/main/resources/modules/Java_api/Main.java +++ b/src/main/resources/modules/Java_api/Main.java @@ -1,4 +1,4 @@ -package ${domain}; +package ${domain}.frame; import com.alibaba.fastjson.JSON; import com.wb.api.auth.request.LoginRequest; diff --git a/src/main/resources/modules/Java_api/MapperUtil.java b/src/main/resources/modules/Java_api/MapperUtil.java index 2ea0ff96..31a3edaa 100644 --- a/src/main/resources/modules/Java_api/MapperUtil.java +++ b/src/main/resources/modules/Java_api/MapperUtil.java @@ -1,4 +1,4 @@ -package ${domain}; +package ${domain}.frame; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonProcessingException; diff --git a/src/main/resources/modules/Java_api/ProgressRequestBody.java b/src/main/resources/modules/Java_api/ProgressRequestBody.java index 1814d2f5..0a770c97 100644 --- a/src/main/resources/modules/Java_api/ProgressRequestBody.java +++ b/src/main/resources/modules/Java_api/ProgressRequestBody.java @@ -1,4 +1,4 @@ -package ${domain}; +package ${domain}.frame; import okhttp3.MediaType; import okhttp3.MultipartBody; diff --git a/src/main/resources/modules/Java_api/RSAUtil.java b/src/main/resources/modules/Java_api/RSAUtil.java index 8d80350c..7b22fa09 100644 --- a/src/main/resources/modules/Java_api/RSAUtil.java +++ b/src/main/resources/modules/Java_api/RSAUtil.java @@ -1,4 +1,4 @@ -package ${domain}; +package ${domain}.frame; import javax.crypto.Cipher; import java.io.ByteArrayOutputStream; diff --git a/src/main/resources/modules/Java_api/SortType.java b/src/main/resources/modules/Java_api/SortType.java index 6f972aa5..f75803b4 100644 --- a/src/main/resources/modules/Java_api/SortType.java +++ b/src/main/resources/modules/Java_api/SortType.java @@ -1,4 +1,4 @@ -package ${domain}; +package ${domain}.frame; /** * SortType - 排序方式 diff --git a/src/main/resources/modules/Java_api/StringUtils.java b/src/main/resources/modules/Java_api/StringUtils.java index a28ac93e..76de6383 100644 --- a/src/main/resources/modules/Java_api/StringUtils.java +++ b/src/main/resources/modules/Java_api/StringUtils.java @@ -1,4 +1,4 @@ -package ${domain}; +package ${domain}.frame; public class StringUtils { private StringUtils() { diff --git a/src/main/resources/modules/Java_api/ValidationUtil.java b/src/main/resources/modules/Java_api/ValidationUtil.java index 69b8f4f2..9539147f 100644 --- a/src/main/resources/modules/Java_api/ValidationUtil.java +++ b/src/main/resources/modules/Java_api/ValidationUtil.java @@ -1,4 +1,4 @@ -package ${domain}; +package ${domain}.frame; import javax.validation.ConstraintViolation; import javax.validation.Validation; diff --git a/src/main/resources/modules/Java_api/module/ent/entity.java b/src/main/resources/modules/Java_api/module/ent/entity.java index 6462063b..eaeb5b00 100644 --- a/src/main/resources/modules/Java_api/module/ent/entity.java +++ b/src/main/resources/modules/Java_api/module/ent/entity.java @@ -1,9 +1,9 @@ -package ${domain}.${module}.ent; +package ${domain}.module.${module}.ent; <#list importList as i> ${i} -import ${domain}.ApiEntity; +import ${domain}.frame.ApiEntity; <#list annotation as i> ${i} diff --git a/src/main/resources/modules/Java_api/module/req/request.java b/src/main/resources/modules/Java_api/module/req/request.java index 168dd22c..4748338b 100644 --- a/src/main/resources/modules/Java_api/module/req/request.java +++ b/src/main/resources/modules/Java_api/module/req/request.java @@ -1,19 +1,19 @@ -package ${domain}.${module}.req; +package ${domain}.module.${module}.req; <#list importList as i> ${i} <#list entNames as entName> -import ${domain}.${module}.ent.${entName}; +import ${domain}.module.${module}.ent.${entName}; <#if !isTempReq> -import ${domain}.${module}.rsp.${rspClassName}; +import ${domain}.module.${module}.rsp.${rspClassName}; -import ${domain}.ApiRequest; +import ${domain}.frame.ApiRequest; <#if findOrSearchflag=='1'> -import ${domain}.ApiFindRequest; +import ${domain}.frame.ApiFindRequest; <#elseif findOrSearchflag=='2'> -import ${domain}.ApiSearchRequest; +import ${domain}.frame.ApiSearchRequest; <#list annotation as i> diff --git a/src/main/resources/modules/Java_api/module/rsp/response.java b/src/main/resources/modules/Java_api/module/rsp/response.java index 533ad451..ecfd6e8c 100644 --- a/src/main/resources/modules/Java_api/module/rsp/response.java +++ b/src/main/resources/modules/Java_api/module/rsp/response.java @@ -1,15 +1,15 @@ -package ${domain}.${module}.rsp; +package ${domain}.module.${module}.rsp; <#list importList as i> ${i} <#list entNames as entName> -import ${domain}.${module}.ent.${entName}; +import ${domain}.module.${module}.ent.${entName}; <#if hasList> -import ${domain}.ApiFindResponse; +import ${domain}.frame.ApiFindResponse; <#else> -import ${domain}.ApiResponse; +import ${domain}.frame.ApiResponse; <#list annotation as i>