diff --git a/conf/conf.txt b/conf/conf.txt index 0f9864a..70499d3 100644 --- a/conf/conf.txt +++ b/conf/conf.txt @@ -1,13 +1,3 @@ -# 是否开发模式 -isDev=true - ------------ arango conf ---------- -arango.host=101.132.161.85 -arango.port=8529 -arango.database=redbbs -arango.user=root -arango.password=lxgwzswhp0zj - ----------- file conf ---------- -file.upload_dir=D:/wk/_own/redbbs/root/file_pub/ -file.view_path=http://127.0.0.1/file_pub/ +file.upload_dir=${APP_HOME}/root/upload/ +file.view_path=http://127.0.0.1/upload/ diff --git a/pom.xml b/pom.xml index 3c27abd..8ed0c9e 100644 --- a/pom.xml +++ b/pom.xml @@ -37,6 +37,12 @@ lombok 1.18.22 + + junit + junit + 4.13.1 + compile + @@ -53,17 +59,66 @@ - redbbs + + lib/redbbs src org.apache.maven.plugins maven-compiler-plugin - 17 - 17 + 14 + 14 + + org.apache.maven.plugins + maven-dependency-plugin + 3.6.0 + + + + copy-dependencies + package + + copy-dependencies + + + ${project.build.directory}/lib + + + + + + + + org.apache.maven.plugins + maven-resources-plugin + 3.3.1 + + + copy-files + package + + copy-resources + + + ${project.build.directory}/conf + + + conf + + application.xml + conf.txt + persistence.xml + + + + + + + + \ No newline at end of file diff --git a/src/net/tccn/bbs/file/FileService.java b/src/net/tccn/bbs/file/FileService.java index 8eea394..bc33f11 100644 --- a/src/net/tccn/bbs/file/FileService.java +++ b/src/net/tccn/bbs/file/FileService.java @@ -10,7 +10,6 @@ import javax.annotation.Resource; import java.io.File; import java.io.IOException; import java.nio.file.Files; -import java.nio.file.StandardCopyOption; /** * Created by Lxy at 2017/10/3 13:48. @@ -19,9 +18,9 @@ import java.nio.file.StandardCopyOption; public class FileService extends BaseService { @Resource(name = "property.file.upload_dir") - private String dir = ""; + private String dir = "./root/upload/"; @Resource(name = "property.file.view_path") - private String view = ""; + private String view = "http://127.0.0.1/upload/"; private String format = "%1$tY%1$tm%1$td%1$tH%1$tM%1$tS"; @RestMapping(name = "upload", comment = "文件上传") @@ -30,12 +29,12 @@ public class FileService extends BaseService { String suffix = name.substring(name.lastIndexOf(".")); String path = String.format(format, System.currentTimeMillis()) + suffix; File destFile = new File(dir + path); - destFile.getParentFile().mkdir(); + destFile.getParentFile().mkdirs(); if (!tmpFile.renameTo(destFile)) { try { - Files.copy(tmpFile.toPath(), destFile.toPath(), StandardCopyOption.ATOMIC_MOVE); + Files.copy(tmpFile.toPath(), destFile.toPath()); } finally { - tmpFile.delete();//删除临时文件 + //tmpFile.delete();//删除临时文件 } } RetResult result = RetResult.success(); diff --git a/src/net/tccn/bbs/servlet/FileServlet.java b/src/net/tccn/bbs/servlet/FileServlet.java index ffed7f3..61f1954 100644 --- a/src/net/tccn/bbs/servlet/FileServlet.java +++ b/src/net/tccn/bbs/servlet/FileServlet.java @@ -2,6 +2,7 @@ package net.tccn.bbs.servlet; import net.tccn.bbs.base.BaseServlet; import org.redkale.net.http.*; +import org.redkale.util.Utility; import javax.annotation.Resource; import java.io.File; @@ -35,12 +36,12 @@ public class FileServlet extends BaseServlet { String name = part.getName(); String suffix = name.substring(name.lastIndexOf(".")); String path = String.format(format, System.currentTimeMillis()) + suffix; - File destFile = new File(dir + path); - destFile.getParentFile().mkdir(); + File destFile = new File(dir + Utility.todayYYMMDD() + "/" + path); + destFile.getParentFile().mkdirs(); part.save(destFile); - data.add(view + path); + data.add(view + Utility.todayYYMMDD() + "/" + path); } ret.put("data", data); diff --git a/tmp/excel/tmp_cp.xls b/tmp/excel/tmp_cp.xls deleted file mode 100644 index e69de29..0000000