From 510e8486a81687004da17f7869132b03491eea6a Mon Sep 17 00:00:00 2001 From: "20932067@zju.edu.cn" Date: Thu, 18 Feb 2021 23:16:29 +0800 Subject: [PATCH] 11 --- hchyun-ui/src/api/system/download.js | 14 + hchyun-ui/src/api/system/file.js | 9 +- hchyun-ui/src/views/system/file/index.vue | 25 +- .../web/controller/system/FileController.java | 77 +++-- .../src/main/resources/application.yml | 19 ++ hchyun/hchyun-common/pom.xml | 7 + .../hchyun/common/config/HchYunConfig.java | 77 +++-- .../hchyun/common/utils/file/FileUtils.java | 84 ++---- .../hchyun/common/utils/ip/AddressUtils.java | 32 +- .../framework/config/SecurityConfig.java | 1 + .../web/exception/GlobalExceptionHandler.java | 38 +-- .../java/com/hchyun/system/dao/FileDao.java | 31 +- .../com/hchyun/system/dto/FileDownload.java | 29 ++ .../system/entity/{File.java => SysFile.java} | 13 +- .../hchyun/system/service/FileService.java | 24 +- .../system/service/impl/FileServiceImpl.java | 85 ++++-- .../com/hchyun/system/utils/FtpUtils.java | 278 ++++++++++++++++++ .../resources/mapper/system/FileMapper.xml | 8 +- 18 files changed, 617 insertions(+), 234 deletions(-) create mode 100644 hchyun-ui/src/api/system/download.js create mode 100644 hchyun/hchyun-system/src/main/java/com/hchyun/system/dto/FileDownload.java rename hchyun/hchyun-system/src/main/java/com/hchyun/system/entity/{File.java => SysFile.java} (96%) create mode 100644 hchyun/hchyun-system/src/main/java/com/hchyun/system/utils/FtpUtils.java diff --git a/hchyun-ui/src/api/system/download.js b/hchyun-ui/src/api/system/download.js new file mode 100644 index 0000000..c5a6040 --- /dev/null +++ b/hchyun-ui/src/api/system/download.js @@ -0,0 +1,14 @@ +import axios from "axios"; +import {getToken} from "@/utils/auth"; + +export function downloadFile(fileId){ + axios({ + method:'get', + url:process.env.VUE_APP_BASE_API+'/system/file/download/'+fileId, + headers:{ + token:'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改 + } + }).then(res=>{ + return res; + }) +} diff --git a/hchyun-ui/src/api/system/file.js b/hchyun-ui/src/api/system/file.js index 3551fc3..3e34978 100644 --- a/hchyun-ui/src/api/system/file.js +++ b/hchyun-ui/src/api/system/file.js @@ -62,5 +62,12 @@ export function getRoleAll(){ type:2 } }) - } + +export function downloadFile(fileId){ + return request({ + url:'/system/file/download/'+fileId, + method:'get' + }) +} + diff --git a/hchyun-ui/src/views/system/file/index.vue b/hchyun-ui/src/views/system/file/index.vue index 2b2e483..29d356f 100644 --- a/hchyun-ui/src/views/system/file/index.vue +++ b/hchyun-ui/src/views/system/file/index.vue @@ -152,6 +152,13 @@ v-hasPermi="['system:file:remove']" >删除 + 下载 + @@ -210,6 +217,7 @@