|
@@ -1,354 +1,354 @@
|
|
|
-
|
|
|
-import cn.hutool.core.date.DateUtil;
|
|
|
-import cn.hutool.core.io.FileUtil;
|
|
|
-import cn.hutool.core.text.StrBuilder;
|
|
|
-import cn.hutool.core.util.RandomUtil;
|
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
-import com.dayou.BaseApplication;
|
|
|
-import com.power.doc.builder.DocBuilderTemplate;
|
|
|
-import com.power.doc.builder.HtmlApiDocBuilder;
|
|
|
-import com.power.doc.builder.ProjectDocConfigBuilder;
|
|
|
-import com.power.doc.model.*;
|
|
|
-import com.power.doc.template.IDocBuildTemplate;
|
|
|
-import com.power.doc.template.SpringBootDocBuildTemplate;
|
|
|
-import com.power.doc.utils.BeetlTemplateUtil;
|
|
|
-import com.thoughtworks.qdox.JavaProjectBuilder;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.beetl.core.Template;
|
|
|
-import org.jsoup.Jsoup;
|
|
|
-import org.jsoup.nodes.Document;
|
|
|
-import org.jsoup.nodes.Element;
|
|
|
-import org.junit.runner.RunWith;
|
|
|
-import org.springframework.boot.test.context.SpringBootTest;
|
|
|
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
|
-import org.springframework.test.context.junit4.SpringRunner;
|
|
|
-
|
|
|
-import java.io.File;
|
|
|
-import java.io.IOException;
|
|
|
-import java.nio.file.StandardCopyOption;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-import static com.power.doc.constants.DocGlobalConstants.*;
|
|
|
-
|
|
|
-/**
|
|
|
- * spring环境测试和用于文档生成
|
|
|
- *
|
|
|
- * @author wucl
|
|
|
- * @version 1.0
|
|
|
- * @date 2020/8/21 10:15
|
|
|
- */
|
|
|
-@Slf4j
|
|
|
-@SpringBootTest(classes = BaseApplication.class)
|
|
|
-@RunWith(SpringJUnit4ClassRunner.class)
|
|
|
-public class Test {
|
|
|
- private static String INDEX_HTML = "index.html";
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成文档
|
|
|
- */
|
|
|
- @org.junit.Test
|
|
|
- public void genHTMLDoc() throws IOException, InterruptedException {
|
|
|
- doHtmlGen();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成SDK文档
|
|
|
- */
|
|
|
- @org.junit.Test
|
|
|
- public void genSdkDoc() throws InterruptedException {
|
|
|
- // generateSdkDoc();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成API接口列表
|
|
|
- */
|
|
|
- @org.junit.Test
|
|
|
- public void genApiList() throws IOException, InterruptedException {
|
|
|
- //doHtmlGen();
|
|
|
- }
|
|
|
-
|
|
|
- private void doHtmlGen() throws IOException, InterruptedException {
|
|
|
- String base = new File("").getAbsolutePath().split("\\\\biz-base")[0];
|
|
|
- ApiConfig config = new ApiConfig();
|
|
|
- String serverUrl = "http://127.0.0.1:8088/api";
|
|
|
- config.setServerUrl(serverUrl);
|
|
|
-
|
|
|
- //设置不为严格模式
|
|
|
- config.setStrict(false);
|
|
|
-
|
|
|
- config.setAllInOne(true);
|
|
|
- config.setProjectName("DY-API");
|
|
|
- RevisionLog relog = new RevisionLog();
|
|
|
- relog.setAuthor("WUCL");
|
|
|
- relog.setRemarks("四川大友主营业务平台接口文档");
|
|
|
- relog.setRevisionTime(DateUtil.now());
|
|
|
- relog.setVersion("v2_app");
|
|
|
- relog.setStatus("进行中");
|
|
|
-
|
|
|
- config.setRevisionLogs(relog);
|
|
|
-
|
|
|
- // 源代码路径
|
|
|
- config.setOutPath(base + "\\biz-base\\src\\main\\resources\\static\\doc");
|
|
|
-
|
|
|
- // 设置接口包扫描路径过滤,如果不配置则Smart-doc默认扫描所有的接口类 配置多个报名有英文逗号隔开
|
|
|
- config.setPackageFilters("com.dayou.controller");
|
|
|
-
|
|
|
- // 多模块时源代码路径
|
|
|
- SourceCodePath paths = new SourceCodePath();
|
|
|
- paths.setPath(base + "\\biz-base\\src\\main\\java");
|
|
|
- SourceCodePath paths1 = new SourceCodePath();
|
|
|
- paths1.setPath(base + "\\common\\src\\main\\java");
|
|
|
- SourceCodePath paths2 = new SourceCodePath();
|
|
|
- paths2.setPath(base + "\\domain\\src\\main\\java");
|
|
|
- SourceCodePath paths3 = new SourceCodePath();
|
|
|
- paths3.setPath(base + "\\service\\src\\main\\java");
|
|
|
-
|
|
|
-
|
|
|
- config.setSourceCodePaths(paths, paths1, paths2, paths3);
|
|
|
-
|
|
|
- System.out.println("文档努力扫描生成中 请稍等..");
|
|
|
-
|
|
|
- //生成HTML5文件
|
|
|
- HtmlApiDocBuilder.buildApiDoc(config);
|
|
|
-
|
|
|
- Thread.sleep(1000);
|
|
|
-
|
|
|
- //生成变更日志
|
|
|
- genChangeLog();
|
|
|
-
|
|
|
- System.out.println("生成html5 文档成功");
|
|
|
- System.out.println("生成changelog 成功");
|
|
|
- }
|
|
|
-
|
|
|
- private void generateApiList() {
|
|
|
- String base = new File("").getAbsolutePath().split("\\\\biz-base")[0];
|
|
|
- SourceCodePath paths = new SourceCodePath();
|
|
|
- paths.setPath(base + "\\biz-base\\src\\main\\java");
|
|
|
- }
|
|
|
- private static void genChangeLog() throws IOException {
|
|
|
- String base = new File("").getAbsolutePath().split("\\\\biz-base")[0];
|
|
|
- List<String> changeList = FileUtil.readLines(new File(base + "\\biz-base\\src\\main\\resources\\doc_changelog.txt"), "utf-8");
|
|
|
- String id = "changelog";
|
|
|
- String temple = "<div id=\"" + id + "\" style=\"margin-left: 60px\" > <h1 >变更记录<p style=\"color:green;font-size:15px;\">文档更新时间:%s</p></h1> <ul>%s</ul> </div>";
|
|
|
- StrBuilder strBuilder = new StrBuilder();
|
|
|
- for (int i = 0; i < changeList.size(); i++) {
|
|
|
- String text = changeList.get(i);
|
|
|
- if (StrUtil.isBlank(text) || StrUtil.isBlank(text.trim())) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- strBuilder.append("<li style=\"color:#9f1717;font-size:22px;\" >");
|
|
|
- strBuilder.append(text.trim());
|
|
|
- strBuilder.append("</li>");
|
|
|
- }
|
|
|
-
|
|
|
- temple = String.format(temple, DateUtil.now(), strBuilder.toString());
|
|
|
-
|
|
|
- String pathname = base + "\\biz-base\\src\\main\\resources\\static\\doc\\index.html";
|
|
|
- File file = new File(pathname);
|
|
|
- Document doc = Jsoup.parse(file, "UTF-8");
|
|
|
- Element changelogDiv = doc.getElementById(id);
|
|
|
- if (changelogDiv != null) {
|
|
|
- changelogDiv.remove();
|
|
|
- }
|
|
|
- Element header = doc.getElementById("header");
|
|
|
- header.before(temple);
|
|
|
- String html = doc.html();
|
|
|
- String[] split = html.split("</body>");
|
|
|
- // 插入 debug js
|
|
|
- String debugHtml = split[0] + "<script src=\"./debug.js\"></script>\n" +
|
|
|
- " <style type=\"text/css\">\n" +
|
|
|
- " </style>" + "</body> " + split[1];
|
|
|
- String tmp = base + "\\doc_temp" + RandomUtil.randomString(32) + ".html";
|
|
|
- File tmpFile = FileUtil.writeString(debugHtml, tmp, "utf-8");
|
|
|
- FileUtil.copyFile(tmpFile, file, StandardCopyOption.REPLACE_EXISTING);
|
|
|
- tmpFile.delete();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- private String handlePath(String path) {
|
|
|
- if (path.endsWith("/")) {
|
|
|
- return StringUtils.removeEnd(path, "/");
|
|
|
- }
|
|
|
- return path;
|
|
|
- }
|
|
|
-
|
|
|
- private boolean checkSkip(ApiDoc doc) {
|
|
|
- List<ApiMethodDoc> methodDocs = doc.getList();
|
|
|
- if (methodDocs == null || methodDocs.isEmpty()) {
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- if (methodDocs.get(0).getPath().contains("/sdk")) {
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- private String handleModuleName(String desc, String controllerName) {
|
|
|
- if (StringUtils.isNotBlank(desc)) {
|
|
|
- return StringUtils.deleteWhitespace(desc).replaceAll("前端控制器", "管理")
|
|
|
- .replaceAll("<p>", "")
|
|
|
- .replaceAll("</p>", "")
|
|
|
- .replaceAll(",", ",");
|
|
|
- } else {
|
|
|
- return controllerName;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private String handleMethodName(String desc, String methodName) {
|
|
|
- if (StringUtils.isNotBlank(desc)) {
|
|
|
- return StringUtils.deleteWhitespace(desc)
|
|
|
- .replaceAll("<p>", "")
|
|
|
- .replaceAll("</p>", "")
|
|
|
- .replaceAll(",", ",");
|
|
|
- } else {
|
|
|
- switch (methodName) {
|
|
|
- case "page":
|
|
|
- return "分页查询";
|
|
|
- case "detail":
|
|
|
- return "详情查询";
|
|
|
- case "save":
|
|
|
- return "新增";
|
|
|
- case "update":
|
|
|
- return "编辑";
|
|
|
- case "delete":
|
|
|
- return "删除";
|
|
|
- case "simpleAll":
|
|
|
- return "下拉列表";
|
|
|
- case "importTemplate":
|
|
|
- return "导入模板下载";
|
|
|
- case "importExcel":
|
|
|
- return "导入";
|
|
|
- case "export":
|
|
|
- return "导出";
|
|
|
- case "batchAdd":
|
|
|
- return "批量新增";
|
|
|
- default:
|
|
|
- return methodName;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private ApiConfig getBaseConfig() {
|
|
|
- String base = new File("").getAbsolutePath().split("\\\\biz-base")[0];
|
|
|
- ApiConfig config = new ApiConfig();
|
|
|
- String serverUrl = "http://127.0.0.1:8088/api";
|
|
|
- config.setServerUrl(serverUrl);
|
|
|
-
|
|
|
- //设置不为严格模式
|
|
|
- config.setStrict(false);
|
|
|
-
|
|
|
- config.setAllInOne(true);
|
|
|
- config.setProjectName("DY-API");
|
|
|
- RevisionLog relog = new RevisionLog();
|
|
|
- relog.setAuthor("WUCL");
|
|
|
- relog.setRemarks("四川大友主营业务平台接口文档");
|
|
|
- relog.setRevisionTime(DateUtil.now());
|
|
|
- relog.setVersion("v4");
|
|
|
- relog.setStatus("进行中");
|
|
|
-
|
|
|
- config.setRevisionLogs(relog);
|
|
|
-
|
|
|
- // 源代码路径
|
|
|
- config.setOutPath(base + "\\biz-base\\src\\main\\resources\\static\\doc");
|
|
|
-
|
|
|
- // 设置接口包扫描路径过滤,如果不配置则Smart-doc默认扫描所有的接口类 配置多个报名有英文逗号隔开
|
|
|
- config.setPackageFilters("com.dayou.controller");
|
|
|
-
|
|
|
- return config;
|
|
|
- }
|
|
|
-
|
|
|
- private void generateSdkDoc() throws InterruptedException {
|
|
|
- String base = new File("").getAbsolutePath().split("\\\\biz-base")[0];
|
|
|
- ApiConfig config = new ApiConfig();
|
|
|
- String serverUrl = "http://119.27.160.97:8534/api/sdk";
|
|
|
- config.setServerUrl(serverUrl);
|
|
|
-
|
|
|
- //设置不为严格模式
|
|
|
- config.setStrict(false);
|
|
|
-
|
|
|
- config.setAllInOne(true);
|
|
|
- config.setProjectName("学校API");
|
|
|
- RevisionLog relog = new RevisionLog();
|
|
|
- relog.setAuthor("xysy");
|
|
|
- relog.setRemarks("学校4期接口文档");
|
|
|
- relog.setRevisionTime(DateUtil.now());
|
|
|
- relog.setVersion("v4");
|
|
|
- relog.setStatus("进行中");
|
|
|
-
|
|
|
- config.setRevisionLogs(relog);
|
|
|
-
|
|
|
- // 源代码路径
|
|
|
- config.setOutPath(base + "\\biz-base\\src\\main\\resources\\static\\doc\\sdk");
|
|
|
-
|
|
|
- // 设置接口包扫描路径过滤,如果不配置则Smart-doc默认扫描所有的接口类 配置多个报名有英文逗号隔开
|
|
|
- config.setPackageFilters("com.dayou.controller");
|
|
|
-
|
|
|
- // 多模块时源代码路径
|
|
|
- SourceCodePath paths = new SourceCodePath();
|
|
|
- paths.setPath(base + "\\biz-base\\src\\main\\java");
|
|
|
- SourceCodePath paths1 = new SourceCodePath();
|
|
|
- paths1.setPath(base + "\\common\\src\\main\\java");
|
|
|
- SourceCodePath paths2 = new SourceCodePath();
|
|
|
- paths2.setPath(base + "\\domain\\src\\main\\java");
|
|
|
- SourceCodePath paths3 = new SourceCodePath();
|
|
|
- paths3.setPath(base + "\\service\\src\\main\\java");
|
|
|
-
|
|
|
- SourceCodePath pathsUis = new SourceCodePath();
|
|
|
- pathsUis.setPath(base + "\\biz-custom\\biz-uis\\src\\main\\java");
|
|
|
-
|
|
|
- config.setSourceCodePaths(paths, paths1, paths2, paths3, pathsUis);
|
|
|
-
|
|
|
- System.out.println("文档努力扫描生成中 请稍等..");
|
|
|
-
|
|
|
- //生成HTML5文件
|
|
|
- buildSdkApiDoc(config);
|
|
|
-
|
|
|
- Thread.sleep(1000);
|
|
|
-
|
|
|
- System.out.println("生成html5 文档成功");
|
|
|
- }
|
|
|
-
|
|
|
- private void buildSdkApiDoc(ApiConfig config) {
|
|
|
- JavaProjectBuilder javaProjectBuilder = new JavaProjectBuilder();
|
|
|
- buildSdkApiDoc(config, javaProjectBuilder);
|
|
|
- }
|
|
|
-
|
|
|
- private void buildSdkApiDoc(ApiConfig config, JavaProjectBuilder javaProjectBuilder) {
|
|
|
- DocBuilderTemplate builderTemplate = new DocBuilderTemplate();
|
|
|
- builderTemplate.checkAndInit(config);
|
|
|
- config.setParamsDataToTree(false);
|
|
|
- ProjectDocConfigBuilder configBuilder = new ProjectDocConfigBuilder(config, javaProjectBuilder);
|
|
|
- IDocBuildTemplate docBuildTemplate = new SpringBootDocBuildTemplate();
|
|
|
- List<ApiDoc> initApiDoc = docBuildTemplate.getApiData(configBuilder);
|
|
|
- //TODO: 这里可以过滤处理对外开放的api接口列表
|
|
|
- List<ApiDoc> apiDocList = new ArrayList<>();
|
|
|
- if (initApiDoc != null && !initApiDoc.isEmpty()) {
|
|
|
- for (ApiDoc doc : initApiDoc) {
|
|
|
- if (checkSkip(doc)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- doc.setDesc(handleModuleName(doc.getDesc(), doc.getName()));
|
|
|
- List<ApiMethodDoc> methodDocs = doc.getList();
|
|
|
- if (methodDocs != null && !methodDocs.isEmpty()) {
|
|
|
- for (ApiMethodDoc methodDoc : methodDocs) {
|
|
|
- methodDoc.setDesc(handleMethodName(methodDoc.getDesc(), methodDoc.getName()));
|
|
|
- }
|
|
|
- }
|
|
|
- apiDocList.add(doc);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- Template indexCssTemplate = BeetlTemplateUtil.getByName(ALL_IN_ONE_CSS);
|
|
|
- com.power.common.util.FileUtil.nioWriteFile(indexCssTemplate.render(), config.getOutPath() + FILE_SEPARATOR + ALL_IN_ONE_CSS);
|
|
|
- if (StringUtils.isNotEmpty(config.getAllInOneDocFileName())) {
|
|
|
- INDEX_HTML = config.getAllInOneDocFileName();
|
|
|
- }
|
|
|
- builderTemplate.buildAllInOne(apiDocList, config, javaProjectBuilder, ALL_IN_ONE_HTML_TPL, INDEX_HTML);
|
|
|
- }
|
|
|
-}
|
|
|
+//
|
|
|
+//import cn.hutool.core.date.DateUtil;
|
|
|
+//import cn.hutool.core.io.FileUtil;
|
|
|
+//import cn.hutool.core.text.StrBuilder;
|
|
|
+//import cn.hutool.core.util.RandomUtil;
|
|
|
+//import cn.hutool.core.util.StrUtil;
|
|
|
+//import com.dayou.BaseApplication;
|
|
|
+//import com.power.doc.builder.DocBuilderTemplate;
|
|
|
+//import com.power.doc.builder.HtmlApiDocBuilder;
|
|
|
+//import com.power.doc.builder.ProjectDocConfigBuilder;
|
|
|
+//import com.power.doc.model.*;
|
|
|
+//import com.power.doc.template.IDocBuildTemplate;
|
|
|
+//import com.power.doc.template.SpringBootDocBuildTemplate;
|
|
|
+//import com.power.doc.utils.BeetlTemplateUtil;
|
|
|
+//import com.thoughtworks.qdox.JavaProjectBuilder;
|
|
|
+//import lombok.extern.slf4j.Slf4j;
|
|
|
+//import org.apache.commons.lang3.StringUtils;
|
|
|
+//import org.beetl.core.Template;
|
|
|
+//import org.jsoup.Jsoup;
|
|
|
+//import org.jsoup.nodes.Document;
|
|
|
+//import org.jsoup.nodes.Element;
|
|
|
+//import org.junit.runner.RunWith;
|
|
|
+//import org.springframework.boot.test.context.SpringBootTest;
|
|
|
+//import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
|
+//import org.springframework.test.context.junit4.SpringRunner;
|
|
|
+//
|
|
|
+//import java.io.File;
|
|
|
+//import java.io.IOException;
|
|
|
+//import java.nio.file.StandardCopyOption;
|
|
|
+//import java.util.ArrayList;
|
|
|
+//import java.util.List;
|
|
|
+//
|
|
|
+//import static com.power.doc.constants.DocGlobalConstants.*;
|
|
|
+//
|
|
|
+///**
|
|
|
+// * spring环境测试和用于文档生成
|
|
|
+// *
|
|
|
+// * @author wucl
|
|
|
+// * @version 1.0
|
|
|
+// * @date 2020/8/21 10:15
|
|
|
+// */
|
|
|
+//@Slf4j
|
|
|
+//@SpringBootTest(classes = BaseApplication.class)
|
|
|
+//@RunWith(SpringJUnit4ClassRunner.class)
|
|
|
+//public class Test {
|
|
|
+// private static String INDEX_HTML = "index.html";
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 生成文档
|
|
|
+// */
|
|
|
+// @org.junit.Test
|
|
|
+// public void genHTMLDoc() throws IOException, InterruptedException {
|
|
|
+// doHtmlGen();
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 生成SDK文档
|
|
|
+// */
|
|
|
+// @org.junit.Test
|
|
|
+// public void genSdkDoc() throws InterruptedException {
|
|
|
+// // generateSdkDoc();
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 生成API接口列表
|
|
|
+// */
|
|
|
+// @org.junit.Test
|
|
|
+// public void genApiList() throws IOException, InterruptedException {
|
|
|
+// //doHtmlGen();
|
|
|
+// }
|
|
|
+//
|
|
|
+// private void doHtmlGen() throws IOException, InterruptedException {
|
|
|
+// String base = new File("").getAbsolutePath().split("\\\\biz-base")[0];
|
|
|
+// ApiConfig config = new ApiConfig();
|
|
|
+// String serverUrl = "http://127.0.0.1:8088/api";
|
|
|
+// config.setServerUrl(serverUrl);
|
|
|
+//
|
|
|
+// //设置不为严格模式
|
|
|
+// config.setStrict(false);
|
|
|
+//
|
|
|
+// config.setAllInOne(true);
|
|
|
+// config.setProjectName("DY-API");
|
|
|
+// RevisionLog relog = new RevisionLog();
|
|
|
+// relog.setAuthor("WUCL");
|
|
|
+// relog.setRemarks("四川大友主营业务平台接口文档");
|
|
|
+// relog.setRevisionTime(DateUtil.now());
|
|
|
+// relog.setVersion("v2_app");
|
|
|
+// relog.setStatus("进行中");
|
|
|
+//
|
|
|
+// config.setRevisionLogs(relog);
|
|
|
+//
|
|
|
+// // 源代码路径
|
|
|
+// config.setOutPath(base + "\\biz-base\\src\\main\\resources\\static\\doc");
|
|
|
+//
|
|
|
+// // 设置接口包扫描路径过滤,如果不配置则Smart-doc默认扫描所有的接口类 配置多个报名有英文逗号隔开
|
|
|
+// config.setPackageFilters("com.dayou.controller");
|
|
|
+//
|
|
|
+// // 多模块时源代码路径
|
|
|
+// SourceCodePath paths = new SourceCodePath();
|
|
|
+// paths.setPath(base + "\\biz-base\\src\\main\\java");
|
|
|
+// SourceCodePath paths1 = new SourceCodePath();
|
|
|
+// paths1.setPath(base + "\\common\\src\\main\\java");
|
|
|
+// SourceCodePath paths2 = new SourceCodePath();
|
|
|
+// paths2.setPath(base + "\\domain\\src\\main\\java");
|
|
|
+// SourceCodePath paths3 = new SourceCodePath();
|
|
|
+// paths3.setPath(base + "\\service\\src\\main\\java");
|
|
|
+//
|
|
|
+//
|
|
|
+// config.setSourceCodePaths(paths, paths1, paths2, paths3);
|
|
|
+//
|
|
|
+// System.out.println("文档努力扫描生成中 请稍等..");
|
|
|
+//
|
|
|
+// //生成HTML5文件
|
|
|
+// HtmlApiDocBuilder.buildApiDoc(config);
|
|
|
+//
|
|
|
+// Thread.sleep(1000);
|
|
|
+//
|
|
|
+// //生成变更日志
|
|
|
+// genChangeLog();
|
|
|
+//
|
|
|
+// System.out.println("生成html5 文档成功");
|
|
|
+// System.out.println("生成changelog 成功");
|
|
|
+// }
|
|
|
+//
|
|
|
+// private void generateApiList() {
|
|
|
+// String base = new File("").getAbsolutePath().split("\\\\biz-base")[0];
|
|
|
+// SourceCodePath paths = new SourceCodePath();
|
|
|
+// paths.setPath(base + "\\biz-base\\src\\main\\java");
|
|
|
+// }
|
|
|
+// private static void genChangeLog() throws IOException {
|
|
|
+// String base = new File("").getAbsolutePath().split("\\\\biz-base")[0];
|
|
|
+// List<String> changeList = FileUtil.readLines(new File(base + "\\biz-base\\src\\main\\resources\\doc_changelog.txt"), "utf-8");
|
|
|
+// String id = "changelog";
|
|
|
+// String temple = "<div id=\"" + id + "\" style=\"margin-left: 60px\" > <h1 >变更记录<p style=\"color:green;font-size:15px;\">文档更新时间:%s</p></h1> <ul>%s</ul> </div>";
|
|
|
+// StrBuilder strBuilder = new StrBuilder();
|
|
|
+// for (int i = 0; i < changeList.size(); i++) {
|
|
|
+// String text = changeList.get(i);
|
|
|
+// if (StrUtil.isBlank(text) || StrUtil.isBlank(text.trim())) {
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+// strBuilder.append("<li style=\"color:#9f1717;font-size:22px;\" >");
|
|
|
+// strBuilder.append(text.trim());
|
|
|
+// strBuilder.append("</li>");
|
|
|
+// }
|
|
|
+//
|
|
|
+// temple = String.format(temple, DateUtil.now(), strBuilder.toString());
|
|
|
+//
|
|
|
+// String pathname = base + "\\biz-base\\src\\main\\resources\\static\\doc\\index.html";
|
|
|
+// File file = new File(pathname);
|
|
|
+// Document doc = Jsoup.parse(file, "UTF-8");
|
|
|
+// Element changelogDiv = doc.getElementById(id);
|
|
|
+// if (changelogDiv != null) {
|
|
|
+// changelogDiv.remove();
|
|
|
+// }
|
|
|
+// Element header = doc.getElementById("header");
|
|
|
+// header.before(temple);
|
|
|
+// String html = doc.html();
|
|
|
+// String[] split = html.split("</body>");
|
|
|
+// // 插入 debug js
|
|
|
+// String debugHtml = split[0] + "<script src=\"./debug.js\"></script>\n" +
|
|
|
+// " <style type=\"text/css\">\n" +
|
|
|
+// " </style>" + "</body> " + split[1];
|
|
|
+// String tmp = base + "\\doc_temp" + RandomUtil.randomString(32) + ".html";
|
|
|
+// File tmpFile = FileUtil.writeString(debugHtml, tmp, "utf-8");
|
|
|
+// FileUtil.copyFile(tmpFile, file, StandardCopyOption.REPLACE_EXISTING);
|
|
|
+// tmpFile.delete();
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// private String handlePath(String path) {
|
|
|
+// if (path.endsWith("/")) {
|
|
|
+// return StringUtils.removeEnd(path, "/");
|
|
|
+// }
|
|
|
+// return path;
|
|
|
+// }
|
|
|
+//
|
|
|
+// private boolean checkSkip(ApiDoc doc) {
|
|
|
+// List<ApiMethodDoc> methodDocs = doc.getList();
|
|
|
+// if (methodDocs == null || methodDocs.isEmpty()) {
|
|
|
+// return true;
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (methodDocs.get(0).getPath().contains("/sdk")) {
|
|
|
+// return true;
|
|
|
+// }
|
|
|
+//
|
|
|
+// return false;
|
|
|
+// }
|
|
|
+//
|
|
|
+// private String handleModuleName(String desc, String controllerName) {
|
|
|
+// if (StringUtils.isNotBlank(desc)) {
|
|
|
+// return StringUtils.deleteWhitespace(desc).replaceAll("前端控制器", "管理")
|
|
|
+// .replaceAll("<p>", "")
|
|
|
+// .replaceAll("</p>", "")
|
|
|
+// .replaceAll(",", ",");
|
|
|
+// } else {
|
|
|
+// return controllerName;
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// private String handleMethodName(String desc, String methodName) {
|
|
|
+// if (StringUtils.isNotBlank(desc)) {
|
|
|
+// return StringUtils.deleteWhitespace(desc)
|
|
|
+// .replaceAll("<p>", "")
|
|
|
+// .replaceAll("</p>", "")
|
|
|
+// .replaceAll(",", ",");
|
|
|
+// } else {
|
|
|
+// switch (methodName) {
|
|
|
+// case "page":
|
|
|
+// return "分页查询";
|
|
|
+// case "detail":
|
|
|
+// return "详情查询";
|
|
|
+// case "save":
|
|
|
+// return "新增";
|
|
|
+// case "update":
|
|
|
+// return "编辑";
|
|
|
+// case "delete":
|
|
|
+// return "删除";
|
|
|
+// case "simpleAll":
|
|
|
+// return "下拉列表";
|
|
|
+// case "importTemplate":
|
|
|
+// return "导入模板下载";
|
|
|
+// case "importExcel":
|
|
|
+// return "导入";
|
|
|
+// case "export":
|
|
|
+// return "导出";
|
|
|
+// case "batchAdd":
|
|
|
+// return "批量新增";
|
|
|
+// default:
|
|
|
+// return methodName;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// private ApiConfig getBaseConfig() {
|
|
|
+// String base = new File("").getAbsolutePath().split("\\\\biz-base")[0];
|
|
|
+// ApiConfig config = new ApiConfig();
|
|
|
+// String serverUrl = "http://127.0.0.1:8088/api";
|
|
|
+// config.setServerUrl(serverUrl);
|
|
|
+//
|
|
|
+// //设置不为严格模式
|
|
|
+// config.setStrict(false);
|
|
|
+//
|
|
|
+// config.setAllInOne(true);
|
|
|
+// config.setProjectName("DY-API");
|
|
|
+// RevisionLog relog = new RevisionLog();
|
|
|
+// relog.setAuthor("WUCL");
|
|
|
+// relog.setRemarks("四川大友主营业务平台接口文档");
|
|
|
+// relog.setRevisionTime(DateUtil.now());
|
|
|
+// relog.setVersion("v4");
|
|
|
+// relog.setStatus("进行中");
|
|
|
+//
|
|
|
+// config.setRevisionLogs(relog);
|
|
|
+//
|
|
|
+// // 源代码路径
|
|
|
+// config.setOutPath(base + "\\biz-base\\src\\main\\resources\\static\\doc");
|
|
|
+//
|
|
|
+// // 设置接口包扫描路径过滤,如果不配置则Smart-doc默认扫描所有的接口类 配置多个报名有英文逗号隔开
|
|
|
+// config.setPackageFilters("com.dayou.controller");
|
|
|
+//
|
|
|
+// return config;
|
|
|
+// }
|
|
|
+//
|
|
|
+// private void generateSdkDoc() throws InterruptedException {
|
|
|
+// String base = new File("").getAbsolutePath().split("\\\\biz-base")[0];
|
|
|
+// ApiConfig config = new ApiConfig();
|
|
|
+// String serverUrl = "http://119.27.160.97:8534/api/sdk";
|
|
|
+// config.setServerUrl(serverUrl);
|
|
|
+//
|
|
|
+// //设置不为严格模式
|
|
|
+// config.setStrict(false);
|
|
|
+//
|
|
|
+// config.setAllInOne(true);
|
|
|
+// config.setProjectName("学校API");
|
|
|
+// RevisionLog relog = new RevisionLog();
|
|
|
+// relog.setAuthor("xysy");
|
|
|
+// relog.setRemarks("学校4期接口文档");
|
|
|
+// relog.setRevisionTime(DateUtil.now());
|
|
|
+// relog.setVersion("v4");
|
|
|
+// relog.setStatus("进行中");
|
|
|
+//
|
|
|
+// config.setRevisionLogs(relog);
|
|
|
+//
|
|
|
+// // 源代码路径
|
|
|
+// config.setOutPath(base + "\\biz-base\\src\\main\\resources\\static\\doc\\sdk");
|
|
|
+//
|
|
|
+// // 设置接口包扫描路径过滤,如果不配置则Smart-doc默认扫描所有的接口类 配置多个报名有英文逗号隔开
|
|
|
+// config.setPackageFilters("com.dayou.controller");
|
|
|
+//
|
|
|
+// // 多模块时源代码路径
|
|
|
+// SourceCodePath paths = new SourceCodePath();
|
|
|
+// paths.setPath(base + "\\biz-base\\src\\main\\java");
|
|
|
+// SourceCodePath paths1 = new SourceCodePath();
|
|
|
+// paths1.setPath(base + "\\common\\src\\main\\java");
|
|
|
+// SourceCodePath paths2 = new SourceCodePath();
|
|
|
+// paths2.setPath(base + "\\domain\\src\\main\\java");
|
|
|
+// SourceCodePath paths3 = new SourceCodePath();
|
|
|
+// paths3.setPath(base + "\\service\\src\\main\\java");
|
|
|
+//
|
|
|
+// SourceCodePath pathsUis = new SourceCodePath();
|
|
|
+// pathsUis.setPath(base + "\\biz-custom\\biz-uis\\src\\main\\java");
|
|
|
+//
|
|
|
+// config.setSourceCodePaths(paths, paths1, paths2, paths3, pathsUis);
|
|
|
+//
|
|
|
+// System.out.println("文档努力扫描生成中 请稍等..");
|
|
|
+//
|
|
|
+// //生成HTML5文件
|
|
|
+// buildSdkApiDoc(config);
|
|
|
+//
|
|
|
+// Thread.sleep(1000);
|
|
|
+//
|
|
|
+// System.out.println("生成html5 文档成功");
|
|
|
+// }
|
|
|
+//
|
|
|
+// private void buildSdkApiDoc(ApiConfig config) {
|
|
|
+// JavaProjectBuilder javaProjectBuilder = new JavaProjectBuilder();
|
|
|
+// buildSdkApiDoc(config, javaProjectBuilder);
|
|
|
+// }
|
|
|
+//
|
|
|
+// private void buildSdkApiDoc(ApiConfig config, JavaProjectBuilder javaProjectBuilder) {
|
|
|
+// DocBuilderTemplate builderTemplate = new DocBuilderTemplate();
|
|
|
+// builderTemplate.checkAndInit(config);
|
|
|
+// config.setParamsDataToTree(false);
|
|
|
+// ProjectDocConfigBuilder configBuilder = new ProjectDocConfigBuilder(config, javaProjectBuilder);
|
|
|
+// IDocBuildTemplate docBuildTemplate = new SpringBootDocBuildTemplate();
|
|
|
+// List<ApiDoc> initApiDoc = docBuildTemplate.getApiData(configBuilder);
|
|
|
+// //TODO: 这里可以过滤处理对外开放的api接口列表
|
|
|
+// List<ApiDoc> apiDocList = new ArrayList<>();
|
|
|
+// if (initApiDoc != null && !initApiDoc.isEmpty()) {
|
|
|
+// for (ApiDoc doc : initApiDoc) {
|
|
|
+// if (checkSkip(doc)) {
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+//
|
|
|
+// doc.setDesc(handleModuleName(doc.getDesc(), doc.getName()));
|
|
|
+// List<ApiMethodDoc> methodDocs = doc.getList();
|
|
|
+// if (methodDocs != null && !methodDocs.isEmpty()) {
|
|
|
+// for (ApiMethodDoc methodDoc : methodDocs) {
|
|
|
+// methodDoc.setDesc(handleMethodName(methodDoc.getDesc(), methodDoc.getName()));
|
|
|
+// }
|
|
|
+// }
|
|
|
+// apiDocList.add(doc);
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// Template indexCssTemplate = BeetlTemplateUtil.getByName(ALL_IN_ONE_CSS);
|
|
|
+// com.power.common.util.FileUtil.nioWriteFile(indexCssTemplate.render(), config.getOutPath() + FILE_SEPARATOR + ALL_IN_ONE_CSS);
|
|
|
+// if (StringUtils.isNotEmpty(config.getAllInOneDocFileName())) {
|
|
|
+// INDEX_HTML = config.getAllInOneDocFileName();
|
|
|
+// }
|
|
|
+// builderTemplate.buildAllInOne(apiDocList, config, javaProjectBuilder, ALL_IN_ONE_HTML_TPL, INDEX_HTML);
|
|
|
+// }
|
|
|
+//}
|