瀏覽代碼

删掉无用属性

zhouhao 7 年之前
父節點
當前提交
7d1c2b29d0

+ 4 - 18
hsweb-system/hsweb-system-file/hsweb-system-file-controller/src/main/java/org/hswebframework/web/controller/file/FileController.java

@@ -47,20 +47,6 @@ import java.util.stream.Stream;
 @AccessLogger("文件")
 public class FileController {
 
-    private String staticFilePath = "./static";
-
-    private String staticLocation = "/";
-
-    @Value("${hsweb.web.upload.staticFilePath:./static}")
-    public void setStaticFilePath(String staticFilePath) {
-        this.staticFilePath = staticFilePath;
-    }
-
-    @Value("${hsweb.web.upload.staticLocation:/}")
-    public void setStaticLocation(String staticLocation) {
-        this.staticLocation = staticLocation;
-    }
-
     private FileService fileService;
 
     private FileInfoService fileInfoService;
@@ -147,7 +133,7 @@ public class FileController {
      * 通过文件ID下载已经上传的文件,支持断点下载
      * 如: http://host:port/file/download/aSk2a/file.zip 将下载 ID为aSk2a的文件.并命名为file.zip
      *
-     * @param id       要下载资源文件的id
+     * @param idOrMd5  要下载资源文件的id或者md5值
      * @param name     自定义文件名,该文件名不能存在非法字符.如果此参数为空(null).将使用文件上传时的文件名
      * @param response {@link javax.servlet.http.HttpServletResponse}
      * @param request  {@link javax.servlet.http.HttpServletRequest}
@@ -158,11 +144,11 @@ public class FileController {
     @GetMapping(value = "/download/{id}")
     @AccessLogger("下载文件")
     @Authorize(action = "download")
-    public void downLoad(@PathVariable("id") String id,
+    public void downLoad(@PathVariable("id") String idOrMd5,
                          @RequestParam(value = "name", required = false) String name,
                          HttpServletResponse response, HttpServletRequest request)
             throws IOException {
-        FileInfoEntity fileInfo = fileInfoService.selectByPk(id);
+        FileInfoEntity fileInfo = fileInfoService.selectByIdOrMd5(idOrMd5);
         if (fileInfo == null || fileInfo.getStatus() != 1) {
             throw new NotFoundException("文件不存在");
         }
@@ -201,7 +187,7 @@ public class FileController {
             String contentRange = "bytes " + skip + "-" + (fSize - 1) + "/" + fSize;
             response.setHeader("Content-Range", contentRange);
         }
-        fileService.writeFile(id, response.getOutputStream(), skip);
+        fileService.writeFile(idOrMd5, response.getOutputStream(), skip);
     }
 
     /**