|
|
@ -14,6 +14,7 @@ import java.io.File;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.concurrent.Callable;
|
|
|
|
import java.util.concurrent.Callable;
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
import java.util.regex.Matcher;
|
|
|
@ -26,7 +27,8 @@ public class ApiCallable implements Callable {
|
|
|
|
private List<Api> apiList;
|
|
|
|
private List<Api> apiList;
|
|
|
|
private List<String> domainList;
|
|
|
|
private List<String> domainList;
|
|
|
|
private Tool tool = new Tool();
|
|
|
|
private Tool tool = new Tool();
|
|
|
|
|
|
|
|
File domain;
|
|
|
|
|
|
|
|
File testdomain;
|
|
|
|
private FreeMarkerManager freeMarkerManager;
|
|
|
|
private FreeMarkerManager freeMarkerManager;
|
|
|
|
|
|
|
|
|
|
|
|
public ApiCallable(File module, File apiFile, List<String> domainList, List<Api> apiList) {
|
|
|
|
public ApiCallable(File module, File apiFile, List<String> domainList, List<Api> apiList) {
|
|
|
@ -46,8 +48,6 @@ public class ApiCallable implements Callable {
|
|
|
|
|
|
|
|
|
|
|
|
AbstractDBmapper dBmapper = ProjectManager.dBmapper;
|
|
|
|
AbstractDBmapper dBmapper = ProjectManager.dBmapper;
|
|
|
|
|
|
|
|
|
|
|
|
File domain;
|
|
|
|
|
|
|
|
File testdomain;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StringBuffer sbmain = new StringBuffer("");
|
|
|
|
StringBuffer sbmain = new StringBuffer("");
|
|
|
|
sbmain.append(this.apiFile.getPath() + File.separator);
|
|
|
|
sbmain.append(this.apiFile.getPath() + File.separator);
|
|
|
@ -82,180 +82,11 @@ public class ApiCallable implements Callable {
|
|
|
|
File entity = new File(apiModule, "ent");
|
|
|
|
File entity = new File(apiModule, "ent");
|
|
|
|
entity.mkdirs();
|
|
|
|
entity.mkdirs();
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
//region 生成request
|
|
|
|
|
|
|
|
RequestReader requestReader = new RequestReader(api.getRequestFile());
|
|
|
|
RequestReader requestReader = new RequestReader(api.getRequestFile());
|
|
|
|
for (int i = 0; i < requestReader.getImportList().size(); i++) {
|
|
|
|
generateRequest(requestReader);
|
|
|
|
String s = requestReader.getImportList().get(i);
|
|
|
|
|
|
|
|
if (s.contains(".module.entity.")) {
|
|
|
|
|
|
|
|
requestReader.getImportList().set(i, s);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> entNames = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (String s : requestReader.getDeptEntList()) {
|
|
|
|
|
|
|
|
Pattern compile = Pattern.compile("(.*\\.ent)\\.(.*)");
|
|
|
|
|
|
|
|
Matcher matcher = compile.matcher(s);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (matcher.find()) {
|
|
|
|
|
|
|
|
String Package = matcher.group(1);
|
|
|
|
|
|
|
|
String EntName = matcher.group(2);
|
|
|
|
|
|
|
|
entNames.add(EntName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<File> files = Tool.find(this.module, EntName + ".java");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (File file : files) {
|
|
|
|
|
|
|
|
EntityReader entReader = new EntityReader(file);
|
|
|
|
|
|
|
|
if (Package.equals(entReader.getModuleName())) {
|
|
|
|
|
|
|
|
HashMap<String, Object> ctx = new HashMap<String, Object>();
|
|
|
|
|
|
|
|
ctx.put("package", "package " + entReader.getDomainName() + "." + entReader.getModuleName() + "." + "req;");
|
|
|
|
|
|
|
|
ctx.put("domain", entReader.getDomainName());
|
|
|
|
|
|
|
|
ctx.put("module", entReader.getModuleName());
|
|
|
|
|
|
|
|
ctx.put("importList", entReader.getImportList());
|
|
|
|
|
|
|
|
ctx.put("annotation", entReader.getNotesList());
|
|
|
|
|
|
|
|
ctx.put("className", entReader.getClassName().replaceAll("Entity", ""));
|
|
|
|
|
|
|
|
ctx.put("body", entReader.getBody());
|
|
|
|
|
|
|
|
ctx.put("tool", tool);
|
|
|
|
|
|
|
|
File EntFile = new File(entity.getAbsolutePath(), EntName + ".java");
|
|
|
|
|
|
|
|
freeMarkerManager.outputTemp(EntFile, "Java_api/module/ent/entity.java", ctx);
|
|
|
|
|
|
|
|
System.out.println("生成文件" + EntName + "成功");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (String reqName : requestReader.getDeptReqList()) {
|
|
|
|
|
|
|
|
List<File> files = Tool.find(this.module, reqName + ".java");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (File file : files) {
|
|
|
|
|
|
|
|
RequestReader reqReader = new RequestReader(file);
|
|
|
|
|
|
|
|
if (requestReader.getModuleName().equals(reqReader.getModuleName())) {
|
|
|
|
|
|
|
|
boolean isTempReq = true;
|
|
|
|
|
|
|
|
for (Api api1 : apiList) {
|
|
|
|
|
|
|
|
if (api1.isCheck() && api1.getRequest().equals(reqName) && api1.getModule().equals(api.getModule())) {
|
|
|
|
|
|
|
|
isTempReq = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isTempReq){
|
|
|
|
|
|
|
|
HashMap<String, Object> ctx = new HashMap<String, Object>();
|
|
|
|
|
|
|
|
ctx.put("package", "package " + reqReader.getDomainName() + "." + reqReader.getModuleName() + "." + "req;");
|
|
|
|
|
|
|
|
ctx.put("domain", reqReader.getDomainName());
|
|
|
|
|
|
|
|
ctx.put("module", reqReader.getModuleName());
|
|
|
|
|
|
|
|
ctx.put("target", api.getTarget());
|
|
|
|
|
|
|
|
ctx.put("method", api.getMethod());
|
|
|
|
|
|
|
|
ctx.put("isTempReq", isTempReq);
|
|
|
|
|
|
|
|
ctx.put("importList", reqReader.getImportList());
|
|
|
|
|
|
|
|
ctx.put("entNames", entNames);
|
|
|
|
|
|
|
|
ctx.put("annotation", reqReader.getNotesList());
|
|
|
|
|
|
|
|
ctx.put("className", reqReader.getClassName().replaceAll("Request", ""));
|
|
|
|
|
|
|
|
ctx.put("body", reqReader.getBody());
|
|
|
|
|
|
|
|
ctx.put("tool", tool);
|
|
|
|
|
|
|
|
ctx.put("hasList", reqReader.isHasList());
|
|
|
|
|
|
|
|
ctx.put("findOrSearchflag", reqReader.getFindOrSearchflag());
|
|
|
|
|
|
|
|
File reqfile = new File(apiRequest.getAbsolutePath(), reqName + ".java");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
freeMarkerManager.outputTemp(reqfile, "Java_api/module/req/request.java", ctx);
|
|
|
|
|
|
|
|
System.out.println("生成文件" + reqfile.getName() + "成功");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
HashMap<String, Object> ctx = new HashMap<String, Object>();
|
|
|
|
|
|
|
|
ctx.put("package", "package " + requestReader.getDomainName() + "." + requestReader.getModuleName() + "." + "request;");
|
|
|
|
|
|
|
|
ctx.put("domain", requestReader.getDomainName());
|
|
|
|
|
|
|
|
ctx.put("module", requestReader.getModuleName());
|
|
|
|
|
|
|
|
ctx.put("target", api.getTarget());
|
|
|
|
|
|
|
|
ctx.put("method", api.getMethod());
|
|
|
|
|
|
|
|
ctx.put("isTempReq", false);
|
|
|
|
|
|
|
|
ctx.put("importList", requestReader.getImportList());
|
|
|
|
|
|
|
|
ctx.put("entNames", entNames);
|
|
|
|
|
|
|
|
ctx.put("annotation", requestReader.getNotesList());
|
|
|
|
|
|
|
|
ctx.put("className", requestReader.getClassName().replaceAll("Request", ""));
|
|
|
|
|
|
|
|
ctx.put("body", requestReader.getBody());
|
|
|
|
|
|
|
|
ctx.put("tool", tool);
|
|
|
|
|
|
|
|
ctx.put("hasList", requestReader.isHasList());
|
|
|
|
|
|
|
|
ctx.put("findOrSearchflag", requestReader.getFindOrSearchflag());
|
|
|
|
|
|
|
|
File file = new File(apiRequest.getAbsolutePath(), api.getRequestFile().getName());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
freeMarkerManager.outputTemp(file, "Java_api/module/req/request.java", ctx);
|
|
|
|
|
|
|
|
System.out.println("生成文件" + file.getName() + "成功");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//endregion
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
//region 生成response
|
|
|
|
|
|
|
|
ResponseReader responseReader = new ResponseReader(api.getResponseFile());
|
|
|
|
ResponseReader responseReader = new ResponseReader(api.getResponseFile());
|
|
|
|
for (int i = 0; i < responseReader.getImportList().size(); i++) {
|
|
|
|
generateResponse(responseReader);
|
|
|
|
String import_ = responseReader.getImportList().get(i);
|
|
|
|
|
|
|
|
if (import_.contains(".module.entity.")) {
|
|
|
|
|
|
|
|
responseReader.getImportList().set(i, import_);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> entNames = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (String s : responseReader.getDeptEntList()) {
|
|
|
|
|
|
|
|
Pattern compile = Pattern.compile("(.*\\.ent)\\.(.*)");
|
|
|
|
|
|
|
|
Matcher matcher = compile.matcher(s);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (matcher.find()) {
|
|
|
|
|
|
|
|
String Package = matcher.group(1);
|
|
|
|
|
|
|
|
String EntName = matcher.group(2);
|
|
|
|
|
|
|
|
entNames.add(EntName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<File> files = Tool.find(this.module, EntName + ".java");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (File file : files) {
|
|
|
|
|
|
|
|
EntityReader entReader = new EntityReader(file);
|
|
|
|
|
|
|
|
if (Package.equals(entReader.getModuleName())) {
|
|
|
|
|
|
|
|
HashMap<String, Object> ctx = new HashMap<String, Object>();
|
|
|
|
|
|
|
|
ctx.put("package", "package " + entReader.getDomainName() + "." + entReader.getModuleName() + "." + "request;");
|
|
|
|
|
|
|
|
ctx.put("domain", entReader.getDomainName());
|
|
|
|
|
|
|
|
ctx.put("module", entReader.getModuleName());
|
|
|
|
|
|
|
|
ctx.put("importList", entReader.getImportList());
|
|
|
|
|
|
|
|
ctx.put("annotation", entReader.getNotesList());
|
|
|
|
|
|
|
|
ctx.put("className", entReader.getClassName().replaceAll("Entity", ""));
|
|
|
|
|
|
|
|
ctx.put("body", entReader.getBody());
|
|
|
|
|
|
|
|
ctx.put("tool", tool);
|
|
|
|
|
|
|
|
File EntFile = new File(entity.getAbsolutePath(), EntName + ".java");
|
|
|
|
|
|
|
|
freeMarkerManager.outputTemp(EntFile, "Java_api/module/ent/entity.java", ctx);
|
|
|
|
|
|
|
|
System.out.println("生成文件" + EntName + "成功");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
HashMap<String, Object> ctx = new HashMap<String, Object>();
|
|
|
|
|
|
|
|
ctx.put("package", "package " + responseReader.getDomainName() + "." + responseReader.getModuleName() + "." + "request;");
|
|
|
|
|
|
|
|
ctx.put("domain", responseReader.getDomainName());
|
|
|
|
|
|
|
|
ctx.put("module", responseReader.getModuleName());
|
|
|
|
|
|
|
|
ctx.put("importList", responseReader.getImportList());
|
|
|
|
|
|
|
|
ctx.put("entNames", entNames);
|
|
|
|
|
|
|
|
ctx.put("annotation", responseReader.getNotesList());
|
|
|
|
|
|
|
|
ctx.put("className", responseReader.getClassName().replaceAll("Response", ""));
|
|
|
|
|
|
|
|
ctx.put("body", responseReader.getBody());
|
|
|
|
|
|
|
|
ctx.put("tool", tool);
|
|
|
|
|
|
|
|
ctx.put("hasList", responseReader.isHasList());
|
|
|
|
|
|
|
|
ctx.put("Tclass", responseReader.getTclass());
|
|
|
|
|
|
|
|
File file = new File(apiResponse.getAbsolutePath(), api.getResponseFile().getName().replaceAll("Request", "Response"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
freeMarkerManager.outputTemp(file, "Java_api/module/rsp/response.java", ctx);
|
|
|
|
|
|
|
|
System.out.println("生成文件" + api.getResponseFile().getName() + "成功");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//endregion
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -359,6 +190,12 @@ public class ApiCallable implements Callable {
|
|
|
|
HashMap<String, Object> ctx = new HashMap<String, Object>();
|
|
|
|
HashMap<String, Object> ctx = new HashMap<String, Object>();
|
|
|
|
ctx.put("tool", tool);
|
|
|
|
ctx.put("tool", tool);
|
|
|
|
ctx.put("domain", String.join(".", domainList));
|
|
|
|
ctx.put("domain", String.join(".", domainList));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HashSet<String> hashSet = new HashSet<>();
|
|
|
|
|
|
|
|
for (Api api : apiList) {
|
|
|
|
|
|
|
|
hashSet.add(api.getModule());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx.put("modules", hashSet);
|
|
|
|
ctx.put("apiList", apiList);
|
|
|
|
ctx.put("apiList", apiList);
|
|
|
|
freeMarkerManager.outputTemp(new File(testdomain.getAbsolutePath(), "ApiTest.java"), "Java_api/ApiTest.java", ctx);
|
|
|
|
freeMarkerManager.outputTemp(new File(testdomain.getAbsolutePath(), "ApiTest.java"), "Java_api/ApiTest.java", ctx);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -366,4 +203,150 @@ public class ApiCallable implements Callable {
|
|
|
|
System.out.println("finish");
|
|
|
|
System.out.println("finish");
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void generateRequest(RequestReader reader) {
|
|
|
|
|
|
|
|
String reqName = reader.getClassName();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查找是否存在对应的Api,有则为公开的请求方法
|
|
|
|
|
|
|
|
Api api = null;
|
|
|
|
|
|
|
|
for (Api api1 : apiList) {
|
|
|
|
|
|
|
|
if (api1.isCheck() && api1.getRequest().equals(reqName)) {
|
|
|
|
|
|
|
|
api = api1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> entNames = new ArrayList<>();
|
|
|
|
|
|
|
|
for (String s : reader.getDeptEntList()) {
|
|
|
|
|
|
|
|
Pattern compile = Pattern.compile("(.*\\.ent)\\.(.*)");
|
|
|
|
|
|
|
|
Matcher matcher = compile.matcher(s);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (matcher.find()) {
|
|
|
|
|
|
|
|
String Package = matcher.group(1);
|
|
|
|
|
|
|
|
String EntName = matcher.group(2);
|
|
|
|
|
|
|
|
entNames.add(EntName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<File> files = Tool.findEntity(this.module, EntName + ".java");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (File file : files) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
EntityReader entReader = new EntityReader(file);
|
|
|
|
|
|
|
|
generateEntity(entReader);
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> reqNames = new ArrayList<>();
|
|
|
|
|
|
|
|
for (String depReqName : reader.getDeptReqList()) {
|
|
|
|
|
|
|
|
Pattern compile = Pattern.compile("(.*\\.req)\\.(.*)");
|
|
|
|
|
|
|
|
Matcher matcher = compile.matcher(depReqName);
|
|
|
|
|
|
|
|
if (matcher.find()) {
|
|
|
|
|
|
|
|
String Package = matcher.group(1);
|
|
|
|
|
|
|
|
String ReqName = matcher.group(2);
|
|
|
|
|
|
|
|
entNames.add(depReqName);
|
|
|
|
|
|
|
|
List<File> files = Tool.findRequest(this.module, depReqName + ".java");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (File file : files) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
RequestReader reqReader = new RequestReader(file);
|
|
|
|
|
|
|
|
generateRequest(reqReader);
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
HashMap<String, Object> ctx = new HashMap<String, Object>();
|
|
|
|
|
|
|
|
ctx.put("domain", reader.getDomainName());
|
|
|
|
|
|
|
|
ctx.put("module", reader.getModuleName());
|
|
|
|
|
|
|
|
ctx.put("isTempReq", api == null);
|
|
|
|
|
|
|
|
if (api != null) {
|
|
|
|
|
|
|
|
ctx.put("target", api.getTarget());
|
|
|
|
|
|
|
|
ctx.put("method", api.getMethod());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
ctx.put("target", "");
|
|
|
|
|
|
|
|
ctx.put("method", "");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx.put("importList", reader.getImportList());
|
|
|
|
|
|
|
|
ctx.put("entNames", entNames);
|
|
|
|
|
|
|
|
ctx.put("reqNames", reqNames);
|
|
|
|
|
|
|
|
ctx.put("annotation", reader.getNotesList());
|
|
|
|
|
|
|
|
ctx.put("className", reader.getClassName());
|
|
|
|
|
|
|
|
ctx.put("rspClassName", reader.getClassName().replaceAll("Request", "Response"));
|
|
|
|
|
|
|
|
ctx.put("body", reader.getBody());
|
|
|
|
|
|
|
|
ctx.put("tool", tool);
|
|
|
|
|
|
|
|
ctx.put("hasList", reader.isHasList());
|
|
|
|
|
|
|
|
ctx.put("findOrSearchflag", reader.getFindOrSearchflag());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
File req = Tool.createPath(domain.getAbsolutePath(), reader.getModuleName(), "req");
|
|
|
|
|
|
|
|
File file = new File(req, reader.getClassName() + ".java");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
freeMarkerManager.outputTemp(file, "Java_api/module/req/request.java", ctx);
|
|
|
|
|
|
|
|
System.out.println("生成文件" + file.getName() + "成功");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void generateResponse(ResponseReader reader) {
|
|
|
|
|
|
|
|
List<String> entNames = new ArrayList<>();
|
|
|
|
|
|
|
|
for (String s : reader.getDeptEntList()) {
|
|
|
|
|
|
|
|
Pattern compile = Pattern.compile("(.*\\.ent)\\.(.*)");
|
|
|
|
|
|
|
|
Matcher matcher = compile.matcher(s);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (matcher.find()) {
|
|
|
|
|
|
|
|
String Package = matcher.group(1);
|
|
|
|
|
|
|
|
String EntName = matcher.group(2);
|
|
|
|
|
|
|
|
entNames.add(EntName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<File> files = Tool.findEntity(this.module, EntName + ".java");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (File file : files) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
EntityReader entReader = new EntityReader(file);
|
|
|
|
|
|
|
|
generateEntity(entReader);
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
HashMap<String, Object> ctx = new HashMap<String, Object>();
|
|
|
|
|
|
|
|
ctx.put("domain", reader.getDomainName());
|
|
|
|
|
|
|
|
ctx.put("module", reader.getModuleName());
|
|
|
|
|
|
|
|
ctx.put("importList", reader.getImportList());
|
|
|
|
|
|
|
|
ctx.put("entNames", entNames);
|
|
|
|
|
|
|
|
ctx.put("annotation", reader.getNotesList());
|
|
|
|
|
|
|
|
ctx.put("className", reader.getClassName());
|
|
|
|
|
|
|
|
ctx.put("body", reader.getBody());
|
|
|
|
|
|
|
|
ctx.put("tool", tool);
|
|
|
|
|
|
|
|
ctx.put("hasList", reader.isHasList());
|
|
|
|
|
|
|
|
ctx.put("Tclass", reader.getTclass());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
File rsp = Tool.createPath(domain.getAbsolutePath(), reader.getModuleName(), "rsp");
|
|
|
|
|
|
|
|
File file = new File(rsp, reader.getClassName() + ".java");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
freeMarkerManager.outputTemp(file, "Java_api/module/rsp/response.java", ctx);
|
|
|
|
|
|
|
|
System.out.println("生成文件" + reader.getClassName() + "成功");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void generateEntity(EntityReader reader) {
|
|
|
|
|
|
|
|
HashMap<String, Object> ctx = new HashMap<String, Object>();
|
|
|
|
|
|
|
|
ctx.put("domain", reader.getDomainName());
|
|
|
|
|
|
|
|
ctx.put("module", reader.getModuleName());
|
|
|
|
|
|
|
|
ctx.put("importList", reader.getImportList());
|
|
|
|
|
|
|
|
ctx.put("annotation", reader.getNotesList());
|
|
|
|
|
|
|
|
ctx.put("className", reader.getClassName());
|
|
|
|
|
|
|
|
ctx.put("body", reader.getBody());
|
|
|
|
|
|
|
|
ctx.put("tool", tool);
|
|
|
|
|
|
|
|
File ent = Tool.createPath(domain.getAbsolutePath(), reader.getModuleName(), "ent");
|
|
|
|
|
|
|
|
File EntFile = new File(ent, reader.getClassName() + ".java");
|
|
|
|
|
|
|
|
freeMarkerManager.outputTemp(EntFile, "Java_api/module/ent/entity.java", ctx);
|
|
|
|
|
|
|
|
System.out.println("生成文件" + reader.getClassName() + "成功");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|