!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){
|
public ModuleMissingInterceptor(ZyplayerModuleKeeper zyplayerModuleKeeper){
|
||||||
enableWiki= zyplayerModuleKeeper.ismoduleStarted(ZyplayerDocConfig.enableWiki.class);
|
enableWiki= zyplayerModuleKeeper.ismoduleStarted(ZyplayerDocConfig.enableWiki.class);
|
||||||
enableDb= zyplayerModuleKeeper.ismoduleStarted(ZyplayerDocConfig.enableWiki.class);
|
enableDb= zyplayerModuleKeeper.ismoduleStarted(ZyplayerDocConfig.enableDb.class);
|
||||||
enableApi= zyplayerModuleKeeper.ismoduleStarted(ZyplayerDocConfig.enableWiki.class);
|
enableApi= zyplayerModuleKeeper.ismoduleStarted(ZyplayerDocConfig.enableApi.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,133 +1,124 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
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">
|
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<artifactId>zyplayer-doc-wiki</artifactId>
|
<artifactId>zyplayer-doc-wiki</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>zyplayer-doc-wiki</name>
|
<name>zyplayer-doc-wiki</name>
|
||||||
<description>wiki文档工具</description>
|
<description>wiki文档工具</description>
|
||||||
<url>https://gitee.com/zyplayer/zyplayer-doc/zyplayer-doc-wiki</url>
|
<url>https://gitee.com/zyplayer/zyplayer-doc/zyplayer-doc-wiki</url>
|
||||||
<developers>
|
<developers>
|
||||||
<developer>
|
<developer>
|
||||||
<id>zyplayer</id>
|
<id>zyplayer</id>
|
||||||
<name>暮光:城中城</name>
|
<name>暮光:城中城</name>
|
||||||
<email>806783409@qq.com</email>
|
<email>806783409@qq.com</email>
|
||||||
<roles>
|
<roles>
|
||||||
<role>Java Development Engineer</role>
|
<role>Java Development Engineer</role>
|
||||||
</roles>
|
</roles>
|
||||||
<timezone>2018-05-22 16:06:06</timezone>
|
<timezone>2018-05-22 16:06:06</timezone>
|
||||||
</developer>
|
</developer>
|
||||||
</developers>
|
</developers>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.zyplayer</groupId>
|
<groupId>com.zyplayer</groupId>
|
||||||
<artifactId>zyplayer-doc</artifactId>
|
<artifactId>zyplayer-doc</artifactId>
|
||||||
<version>1.1.5</version>
|
<version>1.1.5</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter</artifactId>
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.zyplayer</groupId>
|
<groupId>com.zyplayer</groupId>
|
||||||
<artifactId>zyplayer-doc-data</artifactId>
|
<artifactId>zyplayer-doc-data</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.zyplayer</groupId>
|
<groupId>com.zyplayer</groupId>
|
||||||
<artifactId>zyplayer-doc-core</artifactId>
|
<artifactId>zyplayer-doc-core</artifactId>
|
||||||
</dependency>
|
</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>
|
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<!--docx4j-->
|
||||||
<groupId>com.atlassian.commonmark</groupId>
|
<dependency>
|
||||||
<artifactId>commonmark</artifactId>
|
<groupId>org.docx4j</groupId>
|
||||||
<version>0.10.0</version>
|
<artifactId>docx4j-core</artifactId>
|
||||||
</dependency>
|
<version>8.3.9</version>
|
||||||
</dependencies>
|
</dependency>
|
||||||
<licenses>
|
<dependency>
|
||||||
<license>
|
<groupId>org.docx4j</groupId>
|
||||||
<name>The Apache Software License, Version 2.0</name>
|
<artifactId>docx4j-JAXB-ReferenceImpl</artifactId>
|
||||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
<version>8.3.9</version>
|
||||||
</license>
|
</dependency>
|
||||||
</licenses>
|
<dependency>
|
||||||
<scm>
|
<groupId>org.docx4j</groupId>
|
||||||
<connection>scm:git@git.oschina.net:zyplayer/zyplayer-doc.git</connection>
|
<artifactId>docx4j-ImportXHTML</artifactId>
|
||||||
<developerConnection>scm:git@git.oschina.net:zyplayer/zyplayer-doc.git</developerConnection>
|
<version>8.3.8</version>
|
||||||
<url>git@git.oschina.net:zyplayer/zyplayer-doc.git</url>
|
</dependency>
|
||||||
</scm>
|
<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>
|
<distributionManagement>
|
||||||
<snapshotRepository>
|
<snapshotRepository>
|
||||||
<id>snapshots</id>
|
<id>snapshots</id>
|
||||||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
||||||
</snapshotRepository>
|
</snapshotRepository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>snapshots</id>
|
<id>snapshots</id>
|
||||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</distributionManagement>
|
</distributionManagement>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
<directory>src/main/resources/dist</directory>
|
<directory>src/main/resources/dist</directory>
|
||||||
<targetPath>META-INF/resources/</targetPath>
|
<targetPath>META-INF/resources/</targetPath>
|
||||||
</resource>
|
</resource>
|
||||||
<resource>
|
<resource>
|
||||||
<directory>src/main/java</directory>
|
<directory>src/main/java</directory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>**/*</include>
|
<include>**/*</include>
|
||||||
</includes>
|
</includes>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>**/*.java</exclude>
|
<exclude>**/*.java</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
<filtering>false</filtering>
|
<filtering>false</filtering>
|
||||||
</resource>
|
</resource>
|
||||||
<resource>
|
<resource>
|
||||||
<directory>src/main/webapp</directory>
|
<directory>src/main/webapp</directory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>**/*</include>
|
<include>**/*</include>
|
||||||
</includes>
|
</includes>
|
||||||
<filtering>false</filtering>
|
<filtering>false</filtering>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -27,8 +27,10 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.poi.poifs.filesystem.DirectoryEntry;
|
import org.docx4j.XmlUtils;
|
||||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
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.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@@ -37,6 +39,7 @@ import javax.servlet.ServletOutputStream;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -337,18 +340,29 @@ public class WikiPageController {
|
|||||||
return DocResponseJson.warn("文档内容为空,不能导出!");
|
return DocResponseJson.warn("文档内容为空,不能导出!");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
ByteArrayInputStream bais = new ByteArrayInputStream(pageContent.getContent().getBytes("GBK"));
|
String content = pageContent.getContent();
|
||||||
POIFSFileSystem poifs = new POIFSFileSystem();
|
|
||||||
DirectoryEntry directory = poifs.getRoot();
|
|
||||||
directory.createDocument("WordDocument", bais);
|
|
||||||
// 写入流
|
|
||||||
response.setContentType("application/vnd.ms-excel");
|
|
||||||
response.setCharacterEncoding("utf-8");
|
|
||||||
String fileName = URLEncoder.encode(wikiPageSel.getName(), "UTF-8");
|
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");
|
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".docx");
|
||||||
ServletOutputStream outputStream = response.getOutputStream();
|
ServletOutputStream outputStream = response.getOutputStream();
|
||||||
poifs.writeFilesystem(outputStream);
|
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
|
||||||
bais.close();
|
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();
|
outputStream.close();
|
||||||
return DocResponseJson.ok();
|
return DocResponseJson.ok();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user