Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue spring boot #94

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
target
classes
/src/main/webapp/dcpic/
/src/main/resources/static/
dwfile
# eclipse ignore
.settings/
.project
Expand Down Expand Up @@ -50,3 +52,4 @@ Thumbs.db

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
.dat
94 changes: 63 additions & 31 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,43 @@
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>net.diaowen</groupId>
<artifactId>dwsurvey-oss</artifactId>
<version>v.4.1</version>
<packaging>war</packaging>
<artifactId>dwsurvey-oss-vue</artifactId>
<version>v.5.0.1-Alpha</version>
<packaging>jar</packaging>
<name>dwsurvey</name>
<description>DWSurvey project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>

<repositories>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>DWSurveyRepostiory</id>
<name>DWSurveyRepostiory</name>
<url>https://maven.aliyun.com/repository/public</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<!--war 模式添加-->
<dependency>
<!--添加tomcat依赖模块.-->
<!--<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>

<!--jar模式开启热部署,便于修改后自动发布,生产环境推荐关掉此项配置-->
<!--<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>-->

<!-- 添加servlet依赖模块 -->
Expand All @@ -53,11 +58,7 @@
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<!-- 使用jsp引擎,springboot内置tomcat没有此依赖 -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>

<dependency>
<groupId>org.tuckey</groupId>
<artifactId>urlrewritefilter</artifactId>
Expand All @@ -71,7 +72,6 @@


<!-- 项目JAR包-->

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
Expand Down Expand Up @@ -138,20 +138,48 @@
<version>1.7.1</version>
</dependency>


<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.2.2</version>
</dependency>


<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.0.1</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.5</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient-cache</artifactId>
<version>4.5.2</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore-nio</artifactId>
<version>4.4.5</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.2</version>
</dependency>

<!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
<dependency>
<groupId>commons-logging</groupId>
Expand All @@ -178,8 +206,6 @@
<version>2.6</version>
</dependency>



<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
Expand All @@ -200,7 +226,6 @@
<version>1.7.2</version>
</dependency>


<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
Expand All @@ -218,7 +243,6 @@
<version>2.1.0</version>
</dependency>


<dependency>
<groupId>net.sf.dozer</groupId>
<artifactId>dozer</artifactId>
Expand All @@ -232,15 +256,21 @@
<classifier>jdk15</classifier>
</dependency>

<!-- 冲突去掉 -->
<!--
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.0</version>
</dependency>
-->
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20210307</version>
</dependency>



<!-- https://mvnrepository.com/artifact/com.octo.captcha/jcaptcha-all -->
<dependency>
<groupId>com.octo.captcha</groupId>
Expand All @@ -261,7 +291,6 @@
<version>0.7.2</version>
</dependency>


<!-- https://mvnrepository.com/artifact/antlr/antlr -->
<dependency>
<groupId>antlr</groupId>
Expand All @@ -275,7 +304,6 @@
<version>3.0.1</version>
</dependency>


<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
Expand All @@ -289,7 +317,6 @@
<version>2.4</version>
</dependency>


<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
Expand All @@ -303,11 +330,16 @@
<version>1.3.1</version>
</dependency>

<!-- https://mvnrepository.com/artifact/eu.bitwalker/UserAgentUtils -->
<dependency>
<groupId>eu.bitwalker</groupId>
<artifactId>UserAgentUtils</artifactId>
<version>1.21</version>
</dependency>

</dependencies>

<build>
<finalName>dwsurvey</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
Expand Down
51 changes: 45 additions & 6 deletions src/main/java/com/baidu/ueditor/ConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.Map;

import com.fasterxml.jackson.core.JsonParser;
import net.diaowen.dwsurvey.config.DWSurveyConfig;
import org.json.JSONArray;
import org.json.JSONObject;

Expand Down Expand Up @@ -51,7 +52,8 @@ private ConfigManager ( String rootPath, String contextPath, String uri, String

this.initEnv();
this.jsonConfig.put("userId",userId);

// 修改resource路径 = DWSURVEY_WEB_RESOURCE_URL
resetUrlPrefix();
}

/**
Expand Down Expand Up @@ -167,8 +169,10 @@ private void initEnv () throws FileNotFoundException, IOException {
}

this.parentPath = file.getParent();
// String configContent = this.filter(this.getClass().getClassLoader().getResourceAsStream("static/ueditor/config.json"));
String configContent = this.readFile( this.getConfigPath() );
// String configContent = this.filter(this.getClass().getClassLoader().getResourceAsStream("static/ueditor/config.json"));
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("conf/ue/config.json");
String configContent = this.readFile(inputStream);
// String configContent = this.readFile( this.getConfigPath() );
try{
JSONObject jsonConfig = new JSONObject( configContent );
this.jsonConfig = jsonConfig;
Expand All @@ -179,10 +183,7 @@ private void initEnv () throws FileNotFoundException, IOException {
}

private String getConfigPath () {
// return this.parentPath + File.separator + ConfigManager.configFileName;
try{
// File confFile = ResourceUtils.getFile("classpath:conf/ue/config.json");
// String path = confFile.getPath();
ClassPathResource classPathResource = new ClassPathResource("conf/ue/config.json");
String path = classPathResource.getURI().getPath();
return path;
Expand Down Expand Up @@ -230,11 +231,49 @@ private String readFile ( String path ) throws IOException {

}

private String readFile ( InputStream inputStream ) throws IOException {

StringBuilder builder = new StringBuilder();

try {

InputStreamReader reader = new InputStreamReader( inputStream, "UTF-8" );
BufferedReader bfReader = new BufferedReader( reader );

String tmpContent = null;

while ( ( tmpContent = bfReader.readLine() ) != null ) {
builder.append( tmpContent );
}

bfReader.close();

} catch ( UnsupportedEncodingException e ) {
// 忽略
}

return this.filter( builder.toString() );

}

// 过滤输入字符串, 剔除多行注释以及替换掉反斜杠
private String filter ( String input ) {

return input.replaceAll( "/\\*[\\s\\S]*?\\*/", "" );

}

private void resetUrlPrefix(){
String preFixUrl = DWSurveyConfig.DWSURVEY_WEB_RESOURCE_URL;
System.out.println("preFixUrl:"+preFixUrl);
this.jsonConfig.put("imageUrlPrefix", preFixUrl);
this.jsonConfig.put("scrawlUrlPrefix", preFixUrl);
this.jsonConfig.put("snapscreenUrlPrefix", preFixUrl);
this.jsonConfig.put("catcherUrlPrefix", preFixUrl);
this.jsonConfig.put("videoUrlPrefix", preFixUrl);
this.jsonConfig.put("fileUrlPrefix", preFixUrl);
this.jsonConfig.put("imageManagerUrlPrefix", preFixUrl);
this.jsonConfig.put("fileManagerUrlPrefix", preFixUrl);
}

}
13 changes: 4 additions & 9 deletions src/main/java/com/baidu/ueditor/upload/Base64Uploader.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,14 @@

import java.util.Map;

import net.diaowen.common.plugs.file.FileMagic;
import net.diaowen.common.plugs.file.FileMagicUtils;
import org.apache.commons.codec.binary.Base64;

public final class Base64Uploader {

public static State save(String content, Map<String, Object> conf) {

byte[] data = decode(content);

FileMagic fileMagic = FileMagic.valueOf(data);
System.out.println("Base64Uploader - fileMagic:"+fileMagic.getFileType());

long maxSize = ((Long) conf.get("maxSize")).longValue();

if (!validSize(data, maxSize)) {
Expand All @@ -31,7 +26,7 @@ public static State save(String content, Map<String, Object> conf) {

String savePath = PathFormat.parse((String) conf.get("savePath"),
(String) conf.get("filename"));

savePath = savePath + suffix;
String physicalPath = (String) conf.get("rootPath") + savePath;

Expand All @@ -53,5 +48,5 @@ private static byte[] decode(String content) {
private static boolean validSize(byte[] data, long length) {
return data.length <= length;
}

}
}
Loading