mirror of
https://github.com/201206030/novel-plus.git
synced 2025-04-27 01:30:51 +00:00
feat: 移除 FastDFS 模块
This commit is contained in:
parent
24c80e381c
commit
04d7b45334
@ -50,8 +50,7 @@ novel-plus -- 父工程
|
|||||||
| Spring Security | 安全框架
|
| Spring Security | 安全框架
|
||||||
| Apache Shiro | 安全框架
|
| Apache Shiro | 安全框架
|
||||||
| Redis | 缓存方案
|
| Redis | 缓存方案
|
||||||
| Aliyun OSS | 阿里云对象存储服务(图片存储方式之一,一行配置即可切换)
|
| Aliyun OSS | 阿里云对象存储服务(图片存储备选方案)
|
||||||
| FastDFS | 开源轻量级分布式文件系统(图片存储方式之一,一行配置即可切换)
|
|
||||||
| Lombok | 简化对象封装工具
|
| Lombok | 简化对象封装工具
|
||||||
| Docker | 应用容器引擎
|
| Docker | 应用容器引擎
|
||||||
| MySQL | 数据库服务
|
| MySQL | 数据库服务
|
||||||
|
@ -164,12 +164,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.springfox</groupId>
|
<groupId>io.springfox</groupId>
|
||||||
<artifactId>springfox-swagger2</artifactId>
|
<artifactId>springfox-swagger2</artifactId>
|
||||||
<version>2.10.5</version>
|
<version>2.6.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.springfox</groupId>
|
<groupId>io.springfox</groupId>
|
||||||
<artifactId>springfox-swagger-ui</artifactId>
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
<version>2.10.5</version>
|
<version>2.6.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 添加redis支持-->
|
<!-- 添加redis支持-->
|
||||||
|
@ -39,19 +39,11 @@
|
|||||||
<version>${commons-fileupload.version}</version>
|
<version>${commons-fileupload.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--FastDfs-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.tobato</groupId>
|
|
||||||
<artifactId>fastdfs-client</artifactId>
|
|
||||||
<version>${fastdfs-client.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
|
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alipay.sdk</groupId>
|
<groupId>com.alipay.sdk</groupId>
|
||||||
<artifactId>alipay-sdk-java</artifactId>
|
<artifactId>alipay-sdk-java</artifactId>
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.java2nb.novel;
|
package com.java2nb.novel;
|
||||||
|
|
||||||
import com.github.tobato.fastdfs.FdfsClientConfig;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.boot.CommandLineRunner;
|
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.cache.annotation.EnableCaching;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Import;
|
|
||||||
import org.springframework.scheduling.TaskScheduler;
|
import org.springframework.scheduling.TaskScheduler;
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||||
@ -27,7 +25,6 @@ import java.net.InetAddress;
|
|||||||
@EnableCaching
|
@EnableCaching
|
||||||
@ServletComponentScan
|
@ServletComponentScan
|
||||||
@MapperScan(basePackages = {"com.java2nb.novel.mapper"})
|
@MapperScan(basePackages = {"com.java2nb.novel.mapper"})
|
||||||
@Import(FdfsClientConfig.class)
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class FrontNovelApplication {
|
public class FrontNovelApplication {
|
||||||
|
|
||||||
@ -38,7 +35,9 @@ public class FrontNovelApplication {
|
|||||||
@Bean
|
@Bean
|
||||||
public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
|
public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
|
||||||
return args -> {
|
return args -> {
|
||||||
log.info("项目启动啦,访问路径:{}", "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + ctx.getEnvironment().getProperty("server.port"));
|
log.info("项目启动啦,访问路径:{}",
|
||||||
|
"http://" + InetAddress.getLocalHost().getHostAddress() + ":" + ctx.getEnvironment()
|
||||||
|
.getProperty("server.port"));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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";
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,7 +6,7 @@ spring:
|
|||||||
pic:
|
pic:
|
||||||
save:
|
save:
|
||||||
type: 1 #图片保存方式, 1不保存,使用爬取的网络图片 ,2保存在自己的存储介质
|
type: 1 #图片保存方式, 1不保存,使用爬取的网络图片 ,2保存在自己的存储介质
|
||||||
storage: local #存储介质,local:本地,OSS:阿里云对象存储,fastDfs:分布式文件系统
|
storage: local #存储介质,local:本地,OSS:阿里云对象存储
|
||||||
path: /Users/xiongxiaoyang/java/ #图片保存路径
|
path: /Users/xiongxiaoyang/java/ #图片保存路径
|
||||||
|
|
||||||
|
|
||||||
|
@ -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
|
|
||||||
|
|
@ -18,7 +18,7 @@ templates:
|
|||||||
pic:
|
pic:
|
||||||
save:
|
save:
|
||||||
type: 2 #图片保存方式, 1不保存,使用爬取的网络图片 ,2保存在自己的存储介质
|
type: 2 #图片保存方式, 1不保存,使用爬取的网络图片 ,2保存在自己的存储介质
|
||||||
storage: local #存储介质,local:本地,OSS:阿里云对象存储,fastDfs:分布式文件系统
|
storage: local #存储介质,local:本地,OSS:阿里云对象存储
|
||||||
path: /var/pic #图片保存路径
|
path: /var/pic #图片保存路径
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ server:
|
|||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
active: dev
|
active: dev
|
||||||
include: website,alipay,oss,fastdfs
|
include: website,alipay,oss
|
||||||
|
|
||||||
jwt:
|
jwt:
|
||||||
secret: novel!#20191230
|
secret: novel!#20191230
|
||||||
|
1
pom.xml
1
pom.xml
@ -44,7 +44,6 @@
|
|||||||
<sharding.jdbc.version>3.1.0</sharding.jdbc.version>
|
<sharding.jdbc.version>3.1.0</sharding.jdbc.version>
|
||||||
<aliyun-sdk-oss.version>3.15.2</aliyun-sdk-oss.version>
|
<aliyun-sdk-oss.version>3.15.2</aliyun-sdk-oss.version>
|
||||||
<commons-fileupload.version>1.5</commons-fileupload.version>
|
<commons-fileupload.version>1.5</commons-fileupload.version>
|
||||||
<fastdfs-client.version>1.27.2</fastdfs-client.version>
|
|
||||||
<alipay-sdk-java.version>4.35.139.ALL</alipay-sdk-java.version>
|
<alipay-sdk-java.version>4.35.139.ALL</alipay-sdk-java.version>
|
||||||
<xxyopen.version>1.0.0</xxyopen.version>
|
<xxyopen.version>1.0.0</xxyopen.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user