From 04d7b453348aca4b12f97d60c70a8d8bb207b6e5 Mon Sep 17 00:00:00 2001
From: xiongxiaoyang <1179705413@qq.com>
Date: Sun, 28 May 2023 19:14:21 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E7=A7=BB=E9=99=A4=20FastDFS=20?=
=?UTF-8?q?=E6=A8=A1=E5=9D=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 3 +-
novel-admin/pom.xml | 4 +-
novel-front/pom.xml | 8 ---
.../java2nb/novel/FrontNovelApplication.java | 7 +--
.../service/impl/FastDfsFileServiceImpl.java | 60 -------------------
.../src/main/resources/application-dev.yml | 2 +-
.../main/resources/application-fastdfs.yml | 16 -----
.../src/main/resources/application-prod.yml | 4 +-
.../src/main/resources/application.yml | 2 +-
pom.xml | 1 -
10 files changed, 10 insertions(+), 97 deletions(-)
delete mode 100644 novel-front/src/main/java/com/java2nb/novel/service/impl/FastDfsFileServiceImpl.java
delete mode 100644 novel-front/src/main/resources/application-fastdfs.yml
diff --git a/README.md b/README.md
index 3f44f88..07a2bf7 100644
--- a/README.md
+++ b/README.md
@@ -50,8 +50,7 @@ novel-plus -- 父工程
| Spring Security | 安全框架
| Apache Shiro | 安全框架
| Redis | 缓存方案
-| Aliyun OSS | 阿里云对象存储服务(图片存储方式之一,一行配置即可切换)
-| FastDFS | 开源轻量级分布式文件系统(图片存储方式之一,一行配置即可切换)
+| Aliyun OSS | 阿里云对象存储服务(图片存储备选方案)
| Lombok | 简化对象封装工具
| Docker | 应用容器引擎
| MySQL | 数据库服务
diff --git a/novel-admin/pom.xml b/novel-admin/pom.xml
index d0cd8d3..5ffaaad 100644
--- a/novel-admin/pom.xml
+++ b/novel-admin/pom.xml
@@ -164,12 +164,12 @@
io.springfox
springfox-swagger2
- 2.10.5
+ 2.6.1
io.springfox
springfox-swagger-ui
- 2.10.5
+ 2.6.1
diff --git a/novel-front/pom.xml b/novel-front/pom.xml
index 8b602b4..ea9ace7 100644
--- a/novel-front/pom.xml
+++ b/novel-front/pom.xml
@@ -39,19 +39,11 @@
${commons-fileupload.version}
-
-
- com.github.tobato
- fastdfs-client
- ${fastdfs-client.version}
-
-
org.springframework.boot
spring-boot-starter-data-elasticsearch
-
com.alipay.sdk
alipay-sdk-java
diff --git a/novel-front/src/main/java/com/java2nb/novel/FrontNovelApplication.java b/novel-front/src/main/java/com/java2nb/novel/FrontNovelApplication.java
index e678515..78e0174 100644
--- a/novel-front/src/main/java/com/java2nb/novel/FrontNovelApplication.java
+++ b/novel-front/src/main/java/com/java2nb/novel/FrontNovelApplication.java
@@ -1,6 +1,5 @@
package com.java2nb.novel;
-import com.github.tobato.fastdfs.FdfsClientConfig;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.CommandLineRunner;
@@ -10,7 +9,6 @@ import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Import;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
@@ -27,7 +25,6 @@ import java.net.InetAddress;
@EnableCaching
@ServletComponentScan
@MapperScan(basePackages = {"com.java2nb.novel.mapper"})
-@Import(FdfsClientConfig.class)
@Slf4j
public class FrontNovelApplication {
@@ -38,7 +35,9 @@ public class FrontNovelApplication {
@Bean
public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
return args -> {
- log.info("项目启动啦,访问路径:{}", "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + ctx.getEnvironment().getProperty("server.port"));
+ log.info("项目启动啦,访问路径:{}",
+ "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + ctx.getEnvironment()
+ .getProperty("server.port"));
};
}
diff --git a/novel-front/src/main/java/com/java2nb/novel/service/impl/FastDfsFileServiceImpl.java b/novel-front/src/main/java/com/java2nb/novel/service/impl/FastDfsFileServiceImpl.java
deleted file mode 100644
index 9f43bd8..0000000
--- a/novel-front/src/main/java/com/java2nb/novel/service/impl/FastDfsFileServiceImpl.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package com.java2nb.novel.service.impl;
-
-import com.github.tobato.fastdfs.domain.StorePath;
-import com.github.tobato.fastdfs.service.FastFileStorageClient;
-import com.java2nb.novel.core.utils.Constants;
-import com.java2nb.novel.core.utils.FileUtil;
-import com.java2nb.novel.service.FileService;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.io.FilenameUtils;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.stereotype.Service;
-
-import java.io.File;
-import java.io.FileInputStream;
-
-/**
- * @author 11797
- */
-@Service
-@RequiredArgsConstructor
-@Slf4j
-@ConditionalOnProperty(prefix = "pic.save", name = "storage", havingValue = "fastDfs")
-public class FastDfsFileServiceImpl implements FileService {
-
- private final FastFileStorageClient storageClient;
-
- @Value("${fdfs.webUrl}")
- private String webUrl;
-
- @Override
- public String transFile(String picSrc, String picSavePath) {
-
- File file;
- String filePath = FileUtil.network2Local(picSrc, picSavePath, Constants.LOCAL_PIC_PREFIX);
- if (filePath.contains(Constants.LOCAL_PIC_PREFIX)) {
- file = new File(picSavePath + filePath);
- } else {
- //默认图片不存储
- return filePath;
- }
-
- try {
- FileInputStream inputStream = new FileInputStream(file);
- StorePath storePath = storageClient.uploadFile(inputStream, file.length(),
- FilenameUtils.getExtension(file.getName()), null);
- //这里额外加上LOCAL_PIC_PREFIX路径,表明该图片是个人资源,而不是爬虫爬取的网络资源,不需要再次进行转换,
- // 实际访问时,再通过nginx的rewite指令来重写路径,去掉LOCAL_PIC_PREFIX
- return webUrl+Constants.LOCAL_PIC_PREFIX+storePath.getFullPath();
- } catch (Exception e) {
- log.error(e.getMessage(), e);
- } finally {
- //删除
- file.delete();
- }
-
- return "/images/default.gif";
- }
-}
diff --git a/novel-front/src/main/resources/application-dev.yml b/novel-front/src/main/resources/application-dev.yml
index d209c49..f0dbf87 100644
--- a/novel-front/src/main/resources/application-dev.yml
+++ b/novel-front/src/main/resources/application-dev.yml
@@ -6,7 +6,7 @@ spring:
pic:
save:
type: 1 #图片保存方式, 1不保存,使用爬取的网络图片 ,2保存在自己的存储介质
- storage: local #存储介质,local:本地,OSS:阿里云对象存储,fastDfs:分布式文件系统
+ storage: local #存储介质,local:本地,OSS:阿里云对象存储
path: /Users/xiongxiaoyang/java/ #图片保存路径
diff --git a/novel-front/src/main/resources/application-fastdfs.yml b/novel-front/src/main/resources/application-fastdfs.yml
deleted file mode 100644
index 132db23..0000000
--- a/novel-front/src/main/resources/application-fastdfs.yml
+++ /dev/null
@@ -1,16 +0,0 @@
-#FastDfs的配置 ====================================
-#读取inputsream阻塞时间
-fdfs:
- connect-timeout: 600
- so-timeout: 1500
- #tracker地址
- trackerList: 127.0.0.1:22122
- #缩略图配置
- thumbImage:
- height: 150
- width: 150
- #通过nginx 访问地址
- webUrl: http://127.0.0.1/
- #获取连接池最大数量
- pool.max-total: 200
-
diff --git a/novel-front/src/main/resources/application-prod.yml b/novel-front/src/main/resources/application-prod.yml
index 2e83d60..6f89d8c 100644
--- a/novel-front/src/main/resources/application-prod.yml
+++ b/novel-front/src/main/resources/application-prod.yml
@@ -1,6 +1,6 @@
spring:
profiles:
- include: [common-prod]
+ include: [ common-prod ]
#静态文件路径配置
resources:
@@ -18,7 +18,7 @@ templates:
pic:
save:
type: 2 #图片保存方式, 1不保存,使用爬取的网络图片 ,2保存在自己的存储介质
- storage: local #存储介质,local:本地,OSS:阿里云对象存储,fastDfs:分布式文件系统
+ storage: local #存储介质,local:本地,OSS:阿里云对象存储
path: /var/pic #图片保存路径
diff --git a/novel-front/src/main/resources/application.yml b/novel-front/src/main/resources/application.yml
index bcf4d1e..5261537 100644
--- a/novel-front/src/main/resources/application.yml
+++ b/novel-front/src/main/resources/application.yml
@@ -4,7 +4,7 @@ server:
spring:
profiles:
active: dev
- include: website,alipay,oss,fastdfs
+ include: website,alipay,oss
jwt:
secret: novel!#20191230
diff --git a/pom.xml b/pom.xml
index 57b6ad0..9562dad 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,7 +44,6 @@
3.1.0
3.15.2
1.5
- 1.27.2
4.35.139.ALL
1.0.0