mirror of
https://github.com/201206030/novel-plus.git
synced 2025-06-24 04:46:37 +00:00
feat: 移除 FastDFS 模块
This commit is contained in:
@ -39,19 +39,11 @@
|
||||
<version>${commons-fileupload.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--FastDfs-->
|
||||
<dependency>
|
||||
<groupId>com.github.tobato</groupId>
|
||||
<artifactId>fastdfs-client</artifactId>
|
||||
<version>${fastdfs-client.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alipay.sdk</groupId>
|
||||
<artifactId>alipay-sdk-java</artifactId>
|
||||
|
@ -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"));
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
save:
|
||||
type: 1 #图片保存方式, 1不保存,使用爬取的网络图片 ,2保存在自己的存储介质
|
||||
storage: local #存储介质,local:本地,OSS:阿里云对象存储,fastDfs:分布式文件系统
|
||||
storage: local #存储介质,local:本地,OSS:阿里云对象存储
|
||||
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
|
||||
|
@ -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 #图片保存路径
|
||||
|
||||
|
||||
|
@ -4,7 +4,7 @@ server:
|
||||
spring:
|
||||
profiles:
|
||||
active: dev
|
||||
include: website,alipay,oss,fastdfs
|
||||
include: website,alipay,oss
|
||||
|
||||
jwt:
|
||||
secret: novel!#20191230
|
||||
|
Reference in New Issue
Block a user