From 9551520ee37178a5f89dc29b17642a715774be70 Mon Sep 17 00:00:00 2001 From: "20932067@zju.edu.cn" Date: Thu, 13 May 2021 20:19:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BB=A5=E5=8F=8A=E4=BF=AE=E6=94=B9=E6=84=8F?= =?UTF-8?q?=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/common/CommonController.java | 7 ++--- .../src/main/resources/application-druid.yml | 10 ++++--- .../src/main/resources/application.yml | 26 ++++++++++++------- .../com/hchyun/system/utils/FtpUtils.java | 10 +++++++ 分布式文件管理系统修改.txt | 8 ++++++ 5 files changed, 46 insertions(+), 15 deletions(-) create mode 100644 分布式文件管理系统修改.txt diff --git a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/common/CommonController.java b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/common/CommonController.java index ea4bcfb..d397246 100644 --- a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/common/CommonController.java +++ b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/common/CommonController.java @@ -3,6 +3,7 @@ package com.hchyun.web.controller.common; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import com.hchyun.system.utils.FtpUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -42,7 +43,7 @@ public class CommonController { // if (!FileUtils.isValidFilename(fileName)) { // throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 " , fileName)); // } - String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1); + String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf(".")); String filePath = HchYunConfig.getDownloadPath() + fileName; response.setCharacterEncoding("utf-8"); @@ -68,11 +69,11 @@ public class CommonController { String filePath = HchYunConfig.getUploadPath(); // 上传并返回新文件名称 String fileName = FileUploadUtils.upload(filePath, file); - String url = serverConfig.getUrl() + fileName; + String url = FtpUtils.getApiurl() + fileName; +// String url = serverConfig.getUrl() + fileName; AjaxResult ajax = AjaxResult.success(); ajax.put("fileName", fileName); ajax.put("url", url); - ajax.put("addres", "/test"); return ajax; } catch (Exception e) { return AjaxResult.error(e.getMessage()); diff --git a/hchyun/hchyun-admin/src/main/resources/application-druid.yml b/hchyun/hchyun-admin/src/main/resources/application-druid.yml index 1ab9e7c..41b55d8 100644 --- a/hchyun/hchyun-admin/src/main/resources/application-druid.yml +++ b/hchyun/hchyun-admin/src/main/resources/application-druid.yml @@ -6,9 +6,13 @@ spring: druid: # 主库数据源 master: - url: jdbc:mysql://114.215.82.135:3306/hcybase?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - username: hcybase - password: hcybase@2020 +# url: jdbc:mysql://114.215.82.135:3306/hcybase?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 +# username: hcybase +# password: hcybase@2020 + url: jdbc:mysql://13.75.92.40:3306/gen?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 +# url: jdbc:mysql://10.0.0.4:3306/gen?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: gen + password: zcsbKxPseM8LhFdT # 从库数据源 slave: # 从数据源开关/默认关闭 diff --git a/hchyun/hchyun-admin/src/main/resources/application.yml b/hchyun/hchyun-admin/src/main/resources/application.yml index ce80e3d..5d7739e 100644 --- a/hchyun/hchyun-admin/src/main/resources/application.yml +++ b/hchyun/hchyun-admin/src/main/resources/application.yml @@ -9,24 +9,30 @@ hchyun: # 实例演示开关 demoEnabled: true # 文件路径 示例( Windows配置D:/hchyun/uploadPath,Linux配置(宝塔) /www/wwwroot/hchyun/uploadPath) - profile: F:/hchyun/uploadPath +# profile: /www/wwwroot/gen/uploadPath + profile: D:/gen/uploadPath # 获取ip地址开关 - addressEnabled: false + addressEnabled: true # 验证码类型 math 数组计算 char 字符验证 captchaType: math ftp: # ftp服务器ip地址 - ftpAddress: 114.215.82.135 +# ftpAddress: 114.215.82.135 + ftpAddress: 13.75.92.40 # 端口号 ftpPort: 21 # 用户名 - ftpUsername: hcyftp +# ftpUsername: hcyftp + ftpUsername: genfile # 密码 - ftpPassword: hcyftp@2020 +# ftpPassword: hcyftp@2020 + ftpPassword: xanTPWM7jC4XpcWx # 字符集编码 encoding: UTF-8 # 资源域名末尾以/结尾 - resources: http://download.hchyun.com + resources: https://download.odliken.top + #后端部署域名 + apiurl: https://apig.odliken.top # 公开目录 pubfiles: pubfiles # 保护目录 @@ -80,11 +86,13 @@ spring: # redis 配置 redis: # 地址 - host: 114.215.82.135 +# host: 114.215.82.135 +# host: 127.0.0.1 + host: 13.70.28.14 # 端口,默认为6379 - port: 6378 + port: 6379 # 密码 - password: hcy@2020 + password: 926425 # 连接超时时间 timeout: 10s lettuce: diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/utils/FtpUtils.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/utils/FtpUtils.java index e7b6ad7..18f46a8 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/utils/FtpUtils.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/utils/FtpUtils.java @@ -56,8 +56,18 @@ public class FtpUtils { private static String encoding; //静态资源域名 private static String resources; + //后端部署域名 + private static String apiurl; + public static String getApiurl() { + return apiurl; + } + + public void setApiurl(String apiurl) { + FtpUtils.apiurl = apiurl; + } + public static String getAvatarDir() { return pubfiles + "avatar"; } diff --git a/分布式文件管理系统修改.txt b/分布式文件管理系统修改.txt new file mode 100644 index 0000000..d4e4523 --- /dev/null +++ b/分布式文件管理系统修改.txt @@ -0,0 +1,8 @@ +文件上传: +文件通过上传接口上传到后端 后端通过ftp存放到公共临时文件存放中心,返回临时文件中的静态资源路径 +点击提交时:后端通过ftp从临时文件资源中心获取到文件,在通过ftp上传到文件资源中心并删除临时文件中心中的文件 +下载: +点击下载,系统通过ftp从文件资源中心获取到文件流,通过ftp存放在临时文件中,并返回当前文件在临时文件中心的网络静态资源路径,前端再一次发送请求到, +1.后端通过网络资源获取到网络文件并返回给前端 +2.通过js直接获取网络资源 +最后都需要连接零时资源中心的ftp删除文件 \ No newline at end of file