Former-commit-id: 3a3d7961b8b3dbe9bc32406bc44333a772a19058
master
王兵 4 years ago
parent 692def124d
commit 54ee1fb0b9

@ -147,74 +147,52 @@ public class OptionDocController {
return;
}
// File ajaxPath = Tool.createPath(actionPath.get(0), "ajax");
// for (File file : ajaxPath.listFiles()) {
// String module = file.getName();
// for (File tar : file.listFiles()) {
// try {
// String target = tar.getName().replaceAll("Ajax$", "").replaceAll(".java", "");
// DocClassReader docClassReader = new DocClassReader(tar);
//
// for (ApiMethod apiMethod : docClassReader.getMethodList()) {
// Doc doc = new Doc();
// doc.setType("ajax");
// doc.setModule(module);
// doc.setTarget(target);
// doc.setRequest(apiMethod.getRequest());
// doc.setResponse(apiMethod.getResponse());
// doc.setMethod(apiMethod.getMethod());
//
// List<File> reqFiles = Tool.findRequest(moduleFile, apiMethod.getRequest() + ".java");
// if (reqFiles.size() == 0) {
// doc.setError(doc.getError() + "未找到请求");
// } else if (reqFiles.size() > 1) {
// doc.setError(doc.getError() + "找到多个请求");
// } else {
// DocRequestReader docRequestReader = new DocRequestReader("ajax", reqFiles.get(0));
//
// //查找依赖ent
// List<String> entities = findEntities(reqFiles.get(0));
// for (String entity : entities) {
// System.out.println();
//// doc.getDepEnt().add(entity);
// }
//
// //查找依赖req
// List<String> reqss = findEntities(reqFiles.get(0));
// for (String string : reqss) {
//// doc.getDepReq().add(string);
// }
// }
//
// List<File> rspfiles = Tool.findResponse(moduleFile, apiMethod.getResponse() + ".java");
// if (rspfiles.size() == 0) {
// doc.setError(doc.getError() + "未找到响应");
// } else if (rspfiles.size() > 1) {
// doc.setError(doc.getError() + "找到多个响应");
// } else {
// DocRequestReader docRequestReader = new DocRequestReader("ajax", reqFiles.get(0));
//
// //查找依赖ent
// List<String> entities = findEntities(rspfiles.get(0));
// for (String entity : entities) {
// System.out.println();
// }
//
// //查找依赖req
// List<String> reqss = findEntities(rspfiles.get(0));
// for (String string : reqss) {
// System.out.println("");
// }
// }
//
// doc.setCheck(true);
// data.add(doc);
// }
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
File ajaxPath = Tool.createPath(actionPath.get(0), "ajax");
for (File file : ajaxPath.listFiles()) {
String module = file.getName();
for (File tar : file.listFiles()) {
try {
String target = tar.getName().replaceAll("Ajax$", "").replaceAll(".java", "");
DocClassReader docClassReader = new DocClassReader(tar);
for (ApiMethod apiMethod : docClassReader.getMethodList()) {
Doc doc = new Doc();
doc.setType("ajax");
doc.setModule(module);
doc.setTarget(target);
doc.setRequest(apiMethod.getRequest());
doc.setResponse(apiMethod.getResponse());
doc.setMethod(apiMethod.getMethod());
List<File> reqFiles = Tool.findRequest(moduleFile, apiMethod.getRequest() + ".java");
if (reqFiles.size() == 0) {
doc.setError(doc.getError() + "未找到请求");
} else if (reqFiles.size() > 1) {
doc.setError(doc.getError() + "找到多个请求");
} else {
DocRequestReader docRequestReader = new DocRequestReader(reqFiles.get(0));
doc.setTitle(docRequestReader.getClassNote());
doc.setReqParams(docRequestReader.getFieldDocList());
}
List<File> rspfiles = Tool.findResponse(moduleFile, apiMethod.getResponse() + ".java");
if (rspfiles.size() == 0) {
doc.setError(doc.getError() + "未找到响应");
} else if (rspfiles.size() > 1) {
doc.setError(doc.getError() + "找到多个响应");
} else {
DocResponseReader docResponseReader = new DocResponseReader(rspfiles.get(0));
doc.setRspParams(docResponseReader.getFieldDocList());
}
doc.setCheck(true);
data.add(doc);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
File apiPath = Tool.createPath(actionPath.get(0), "api");
for (File file : apiPath.listFiles()) {

@ -20,17 +20,14 @@ public class DocCallable implements Callable {
private File module;
private File docFile;
private List<Doc> ajaxDocList;
private List<Doc> apiDocList;
private List<Doc> docList;
private Tool tool = new Tool();
File docModule;
private FreeMarkerManager freeMarkerManager;
public DocCallable(File module, File docFile, List<Doc> docList) {
this.module = module;
this.docFile = docFile;
this.ajaxDocList = docList;
this.apiDocList = docList;
this.docList = docList;
this.freeMarkerManager = ManagerFactory.getFreeMarkerManager();
}
@ -57,25 +54,6 @@ public class DocCallable implements Callable {
}
}
List<Doc> ajaxList = new ArrayList<>();
List<Doc> apiList = new ArrayList<>();
for (Doc doc : ajaxDocList) {
if (doc.isCheck()) {
if ("ajax".equals(doc.getType().toLowerCase())) {
ajaxList.add(doc);
}
if ("api".equals(doc.getType().toLowerCase())) {
apiList.add(doc);
}
}
}
if (ajaxList.size() > 0) {
File ajax = Tool.createFile(this.docFile, "index.html");
HashMap<String, Object> ctx = new HashMap<String, Object>();
ctx.put("ajaxList", ajaxList);
freeMarkerManager.outputTemp(ajax, "Doc/data.json", ctx);
}
File js = Tool.createPath(this.docFile, "js");
File css = Tool.createPath(this.docFile, "css");
@ -84,12 +62,10 @@ public class DocCallable implements Callable {
Tool.outputResource("Doc/css/index.css", Tool.createFile(css, "index.css"));
Tool.outputResource("Doc/index.html", Tool.createFile(this.docFile, "index.html"));
if (apiList.size() > 0) {
File api = Tool.createFile(js, "index.js");
HashMap<String, Object> ctx = new HashMap<String, Object>();
ctx.put("apiList", apiList);
freeMarkerManager.outputTemp(api, "Doc/js/index.js", ctx);
}
File api = Tool.createFile(js, "index.js");
HashMap<String, Object> ctx = new HashMap<String, Object>();
ctx.put("docList", docList);
freeMarkerManager.outputTemp(api, "Doc/js/index.js", ctx);
System.out.println("finish");
return true;

@ -44,6 +44,7 @@ html, body, #app {
margin-top: 70px;
width: 240px;
position: fixed;
overflow: auto;
}
.side ul li a {
@ -72,29 +73,31 @@ html, body, #app {
position: fixed;
overflow: auto;
padding-bottom: 50px;
padding-left: 20px;
}
.api {
width: 700px;
border: 1px dashed #cfcfcf;
}
.api h3 {
background: #eef0f4;
padding: 10px;
font-size: 18px;
border-bottom: 1px dashed #cfcfcf;
}
.api h5 {
padding: 5px;
padding: 10px;
color: #3e3e3e;
font-weight: normal;
margin: 10px 0;
}
.api .wrapper {
padding: 16px;
background: #eef0f4;
padding: 20px 20px 20px 20px;
background: #f9f9f9;
border-bottom: 1px dashed #cfcfcf;
border-top: 1px dashed #cfcfcf;
}
.api .wrapper a {
@ -123,8 +126,8 @@ table tr th, table tr td {
border: 1px solid #ddd;
word-break: normal !important;
vertical-align: middle;
height: 40px;
line-height: 40px;
height: 30px;
line-height: 30px;
}
table tr {

@ -4,10 +4,10 @@ var app = new Vue({
searchKey: '',
select: {},
data: [
<#list apiList as item>
<#list docList as item>
{
"title": "${item.title?default('')}",
"type": "ajax",
"type": "${item.type}",
"module": "${item.module?default('')}",
"target": "${item.target?default('')}",
"method": "${item.method?default('')}",

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save

Powered by TurnKey Linux.