!24 修改启动配置问题,合并闭源版wiki模块生成doc的代码
Merge pull request !24 from sh1yu/master
This commit is contained in:
@@ -29,8 +29,8 @@ public class ModuleMissingInterceptor implements HandlerInterceptor {
|
||||
|
||||
public ModuleMissingInterceptor(ZyplayerModuleKeeper zyplayerModuleKeeper){
|
||||
enableWiki= zyplayerModuleKeeper.ismoduleStarted(ZyplayerDocConfig.enableWiki.class);
|
||||
enableDb= zyplayerModuleKeeper.ismoduleStarted(ZyplayerDocConfig.enableWiki.class);
|
||||
enableApi= zyplayerModuleKeeper.ismoduleStarted(ZyplayerDocConfig.enableWiki.class);
|
||||
enableDb= zyplayerModuleKeeper.ismoduleStarted(ZyplayerDocConfig.enableDb.class);
|
||||
enableApi= zyplayerModuleKeeper.ismoduleStarted(ZyplayerDocConfig.enableApi.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,133 +1,124 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>zyplayer-doc-wiki</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>zyplayer-doc-wiki</name>
|
||||
<description>wiki文档工具</description>
|
||||
<url>https://gitee.com/zyplayer/zyplayer-doc/zyplayer-doc-wiki</url>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>zyplayer</id>
|
||||
<name>暮光:城中城</name>
|
||||
<email>806783409@qq.com</email>
|
||||
<roles>
|
||||
<role>Java Development Engineer</role>
|
||||
</roles>
|
||||
<timezone>2018-05-22 16:06:06</timezone>
|
||||
</developer>
|
||||
</developers>
|
||||
<artifactId>zyplayer-doc-wiki</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>zyplayer-doc-wiki</name>
|
||||
<description>wiki文档工具</description>
|
||||
<url>https://gitee.com/zyplayer/zyplayer-doc/zyplayer-doc-wiki</url>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>zyplayer</id>
|
||||
<name>暮光:城中城</name>
|
||||
<email>806783409@qq.com</email>
|
||||
<roles>
|
||||
<role>Java Development Engineer</role>
|
||||
</roles>
|
||||
<timezone>2018-05-22 16:06:06</timezone>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<parent>
|
||||
<groupId>com.zyplayer</groupId>
|
||||
<artifactId>zyplayer-doc</artifactId>
|
||||
<version>1.1.5</version>
|
||||
</parent>
|
||||
<parent>
|
||||
<groupId>com.zyplayer</groupId>
|
||||
<artifactId>zyplayer-doc</artifactId>
|
||||
<version>1.1.5</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zyplayer</groupId>
|
||||
<artifactId>zyplayer-doc-data</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zyplayer</groupId>
|
||||
<artifactId>zyplayer-doc-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>4.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>4.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml-schemas</artifactId>
|
||||
<version>4.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-scratchpad</artifactId>
|
||||
<version>4.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>ooxml-schemas</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zyplayer</groupId>
|
||||
<artifactId>zyplayer-doc-data</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zyplayer</groupId>
|
||||
<artifactId>zyplayer-doc-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.atlassian.commonmark</groupId>
|
||||
<artifactId>commonmark</artifactId>
|
||||
<version>0.10.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The Apache Software License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
</license>
|
||||
</licenses>
|
||||
<scm>
|
||||
<connection>scm:git@git.oschina.net:zyplayer/zyplayer-doc.git</connection>
|
||||
<developerConnection>scm:git@git.oschina.net:zyplayer/zyplayer-doc.git</developerConnection>
|
||||
<url>git@git.oschina.net:zyplayer/zyplayer-doc.git</url>
|
||||
</scm>
|
||||
<!--docx4j-->
|
||||
<dependency>
|
||||
<groupId>org.docx4j</groupId>
|
||||
<artifactId>docx4j-core</artifactId>
|
||||
<version>8.3.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.docx4j</groupId>
|
||||
<artifactId>docx4j-JAXB-ReferenceImpl</artifactId>
|
||||
<version>8.3.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.docx4j</groupId>
|
||||
<artifactId>docx4j-ImportXHTML</artifactId>
|
||||
<version>8.3.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.atlassian.commonmark</groupId>
|
||||
<artifactId>commonmark</artifactId>
|
||||
<version>0.10.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The Apache Software License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
</license>
|
||||
</licenses>
|
||||
<scm>
|
||||
<connection>scm:git@git.oschina.net:zyplayer/zyplayer-doc.git</connection>
|
||||
<developerConnection>scm:git@git.oschina.net:zyplayer/zyplayer-doc.git</developerConnection>
|
||||
<url>git@git.oschina.net:zyplayer/zyplayer-doc.git</url>
|
||||
</scm>
|
||||
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>snapshots</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>snapshots</id>
|
||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>snapshots</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>snapshots</id>
|
||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources/dist</directory>
|
||||
<targetPath>META-INF/resources/</targetPath>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
<excludes>
|
||||
<exclude>**/*.java</exclude>
|
||||
</excludes>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/webapp</directory>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources/dist</directory>
|
||||
<targetPath>META-INF/resources/</targetPath>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
<excludes>
|
||||
<exclude>**/*.java</exclude>
|
||||
</excludes>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/webapp</directory>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
@@ -27,8 +27,10 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.poifs.filesystem.DirectoryEntry;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
import org.docx4j.XmlUtils;
|
||||
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
|
||||
import org.docx4j.openpackaging.parts.WordprocessingML.AltChunkType;
|
||||
import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -37,6 +39,7 @@ import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -337,18 +340,29 @@ public class WikiPageController {
|
||||
return DocResponseJson.warn("文档内容为空,不能导出!");
|
||||
}
|
||||
try {
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(pageContent.getContent().getBytes("GBK"));
|
||||
POIFSFileSystem poifs = new POIFSFileSystem();
|
||||
DirectoryEntry directory = poifs.getRoot();
|
||||
directory.createDocument("WordDocument", bais);
|
||||
// 写入流
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
String content = pageContent.getContent();
|
||||
String fileName = URLEncoder.encode(wikiPageSel.getName(), "UTF-8");
|
||||
content = "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Strict//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n" +
|
||||
"<html lang=\"zh\">\n" +
|
||||
"<head>\n" +
|
||||
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n" +
|
||||
"<title>" + fileName + "</title>\n" +
|
||||
"</head>\n" +
|
||||
"<body>" +
|
||||
content +
|
||||
"</body>\n" +
|
||||
"</html>";
|
||||
// 写入流
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".docx");
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
poifs.writeFilesystem(outputStream);
|
||||
bais.close();
|
||||
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
|
||||
MainDocumentPart mdp = wordMLPackage.getMainDocumentPart();
|
||||
mdp.addAltChunk(AltChunkType.Xhtml, content.getBytes(StandardCharsets.UTF_8));
|
||||
mdp.convertAltChunks();
|
||||
XmlUtils.marshaltoString(wordMLPackage.getMainDocumentPart().getJaxbElement(), true, true);
|
||||
wordMLPackage.save(outputStream);
|
||||
outputStream.close();
|
||||
return DocResponseJson.ok();
|
||||
} catch (Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user