重命名 文件服务的 接口名称
This commit is contained in:
parent
60a71a3146
commit
7a5df92dfb
|
|
@ -1,12 +1,12 @@
|
||||||
package com.ruoyi.file.config;
|
package com.ruoyi.file.config;
|
||||||
|
|
||||||
import com.ruoyi.file.service.CephDfsServiceImpl;
|
import com.ruoyi.file.service.CephSysFileServiceImpl;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CephDfsServiceImpl
|
* @see CephSysFileServiceImpl
|
||||||
* @author dazer
|
* @author dazer
|
||||||
*/
|
*/
|
||||||
@RefreshScope
|
@RefreshScope
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ package com.ruoyi.file.config;
|
||||||
|
|
||||||
import com.github.tobato.fastdfs.FdfsClientConstants;
|
import com.github.tobato.fastdfs.FdfsClientConstants;
|
||||||
import com.github.tobato.fastdfs.domain.conn.PooledConnectionFactory;
|
import com.github.tobato.fastdfs.domain.conn.PooledConnectionFactory;
|
||||||
import com.ruoyi.file.service.FastDfsServiceImpl;
|
import com.ruoyi.file.service.FastSysFileServiceImpl;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
@ -10,7 +10,7 @@ import org.springframework.context.annotation.Configuration;
|
||||||
/**
|
/**
|
||||||
* 阿里 fastdfs 配置
|
* 阿里 fastdfs 配置
|
||||||
* @author dazer
|
* @author dazer
|
||||||
* @see FastDfsServiceImpl
|
* @see FastSysFileServiceImpl
|
||||||
* FastDFS配置 其他参数见:{@link PooledConnectionFactory}
|
* FastDFS配置 其他参数见:{@link PooledConnectionFactory}
|
||||||
*
|
*
|
||||||
* 使用: Docker部署FastDFS(附示例代码) https://www.cnblogs.com/cao-lei/p/13470695.html
|
* 使用: Docker部署FastDFS(附示例代码) https://www.cnblogs.com/cao-lei/p/13470695.html
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package com.ruoyi.file.config;
|
package com.ruoyi.file.config;
|
||||||
|
|
||||||
import com.ruoyi.file.service.MinioDfsServiceImpl;
|
import com.ruoyi.file.service.MinioSysFileServiceImpl;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|
@ -13,7 +13,7 @@ import org.springframework.stereotype.Component;
|
||||||
* Minio 配置信息
|
* Minio 配置信息
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
* @see MinioDfsServiceImpl 实现
|
* @see MinioSysFileServiceImpl 实现
|
||||||
*/
|
*/
|
||||||
@RefreshScope
|
@RefreshScope
|
||||||
@Component
|
@Component
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ package com.ruoyi.file.config;
|
||||||
|
|
||||||
import com.qiniu.storage.Region;
|
import com.qiniu.storage.Region;
|
||||||
import com.qiniu.storage.UploadManager;
|
import com.qiniu.storage.UploadManager;
|
||||||
import com.ruoyi.file.service.QiniuDfsServiceImpl;
|
import com.ruoyi.file.service.QiniuSysFileServiceImpl;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration;
|
||||||
* @see UploadManager 上传核心类
|
* @see UploadManager 上传核心类
|
||||||
* @see Region 区域 or endpoint 【可选】
|
* @see Region 区域 or endpoint 【可选】
|
||||||
* @see com.qiniu.storage.Configuration 配置类,可以配置 上传区域; 【可选】
|
* @see com.qiniu.storage.Configuration 配置类,可以配置 上传区域; 【可选】
|
||||||
* @see QiniuDfsServiceImpl 实现
|
* @see QiniuSysFileServiceImpl 实现
|
||||||
*/
|
*/
|
||||||
@RefreshScope
|
@RefreshScope
|
||||||
@Configuration
|
@Configuration
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
package com.ruoyi.file.controller;
|
package com.ruoyi.file.controller;
|
||||||
|
|
||||||
import com.ruoyi.file.service.IDfsService;
|
import com.ruoyi.file.service.ISysFileService;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.annotations.ApiParam;
|
import io.swagger.annotations.ApiParam;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
@ -27,7 +26,7 @@ public class SysFileController {
|
||||||
private static final Logger log = LoggerFactory.getLogger(SysFileController.class);
|
private static final Logger log = LoggerFactory.getLogger(SysFileController.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IDfsService dfsService;
|
private ISysFileService dfsService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件上传请求
|
* 文件上传请求
|
||||||
|
|
@ -90,4 +89,4 @@ public class SysFileController {
|
||||||
@ApiParam("需要访问的url,字段名:fileUrl,必填;不要带有?后面的参数") @RequestParam(value = "fileUrl") String fileUrl) {
|
@ApiParam("需要访问的url,字段名:fileUrl,必填;不要带有?后面的参数") @RequestParam(value = "fileUrl") String fileUrl) {
|
||||||
return R.ok(dfsService.presignedUrl(fileUrl), "获取成功");
|
return R.ok(dfsService.presignedUrl(fileUrl), "获取成功");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
*/
|
*/
|
||||||
@Primary
|
@Primary
|
||||||
@Service()
|
@Service()
|
||||||
public class AliyunOssDsfServiceImpl implements IDfsService {
|
public class AliyunOssDsfServiceImpl implements ISysFileService {
|
||||||
private static final Logger log = LoggerFactory.getLogger(AliyunOssDsfServiceImpl.class);
|
private static final Logger log = LoggerFactory.getLogger(AliyunOssDsfServiceImpl.class);
|
||||||
@Autowired
|
@Autowired
|
||||||
private AliyunOssConfig aliyunOssConfig;
|
private AliyunOssConfig aliyunOssConfig;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ import java.math.BigDecimal;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author dazer
|
* @author dazer
|
||||||
|
|
@ -41,8 +40,8 @@ import java.util.function.Consumer;
|
||||||
* 3:使用docker 搭建 ceph 开发环境,使用aws sdk 存储数据 https://blog.csdn.net/freewebsys/article/details/79553386
|
* 3:使用docker 搭建 ceph 开发环境,使用aws sdk 存储数据 https://blog.csdn.net/freewebsys/article/details/79553386
|
||||||
*/
|
*/
|
||||||
@Service()
|
@Service()
|
||||||
public class CephDfsServiceImpl implements IDfsService {
|
public class CephSysFileServiceImpl implements ISysFileService {
|
||||||
private static final Logger log = LoggerFactory.getLogger(CephDfsServiceImpl.class);
|
private static final Logger log = LoggerFactory.getLogger(CephSysFileServiceImpl.class);
|
||||||
@Autowired
|
@Autowired
|
||||||
private CephConfig cephConfig;
|
private CephConfig cephConfig;
|
||||||
|
|
||||||
|
|
@ -9,7 +9,6 @@ import org.csource.fastdfs.ProtoCommon;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Primary;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import com.github.tobato.fastdfs.domain.fdfs.StorePath;
|
import com.github.tobato.fastdfs.domain.fdfs.StorePath;
|
||||||
|
|
@ -23,9 +22,9 @@ import com.github.tobato.fastdfs.service.FastFileStorageClient;
|
||||||
*/
|
*/
|
||||||
//@Primary
|
//@Primary
|
||||||
@Service()
|
@Service()
|
||||||
public class FastDfsServiceImpl implements IDfsService
|
public class FastSysFileServiceImpl implements ISysFileService
|
||||||
{
|
{
|
||||||
private final Logger logger = LoggerFactory.getLogger(FastDfsServiceImpl.class);
|
private final Logger logger = LoggerFactory.getLogger(FastSysFileServiceImpl.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private FastFileStorageClient storageClient;
|
private FastFileStorageClient storageClient;
|
||||||
|
|
@ -34,7 +33,7 @@ public class FastDfsServiceImpl implements IDfsService
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FastDfs文件上传接口
|
* FastDfs文件上传接口
|
||||||
*
|
*
|
||||||
* @param file 上传的文件
|
* @param file 上传的文件
|
||||||
* @return 访问地址
|
* @return 访问地址
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
|
@ -17,7 +17,7 @@ import java.io.IOException;
|
||||||
* @author dazer
|
* @author dazer
|
||||||
*/
|
*/
|
||||||
@Service()
|
@Service()
|
||||||
public class FtpFileServiceImpl implements IDfsService {
|
public class FtpFileServiceImpl implements ISysFileService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private FtpConfig ftpConfig;
|
private FtpConfig ftpConfig;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import static com.ruoyi.file.utils.FileUploadUtils.*;
|
||||||
* 6: CEPH 分布式大数据文件存储系统 http://docs.ceph.org.cn/
|
* 6: CEPH 分布式大数据文件存储系统 http://docs.ceph.org.cn/
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public interface IDfsService
|
public interface ISysFileService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 允许上传文件存放的目录
|
* 允许上传文件存放的目录
|
||||||
|
|
@ -41,7 +41,7 @@ public interface IDfsService
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件上传接口
|
* 文件上传接口
|
||||||
*
|
*
|
||||||
* @param file 上传的文件
|
* @param file 上传的文件
|
||||||
* @return 访问地址
|
* @return 访问地址
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
|
@ -4,7 +4,6 @@ import cn.hutool.core.io.FileUtil;
|
||||||
import com.ruoyi.common.core.exception.CustomException;
|
import com.ruoyi.common.core.exception.CustomException;
|
||||||
import com.ruoyi.file.config.LocalFileConfig;
|
import com.ruoyi.file.config.LocalFileConfig;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.context.annotation.Primary;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import com.ruoyi.file.utils.FileUploadUtils;
|
import com.ruoyi.file.utils.FileUploadUtils;
|
||||||
|
|
@ -13,11 +12,11 @@ import java.io.File;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 本地文件存储
|
* 本地文件存储
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Service()
|
@Service()
|
||||||
public class LocalFileServiceImpl implements IDfsService
|
public class LocalFileServiceImpl implements ISysFileService
|
||||||
{
|
{
|
||||||
private final LocalFileConfig localFileConfig;
|
private final LocalFileConfig localFileConfig;
|
||||||
|
|
||||||
|
|
@ -27,7 +26,7 @@ public class LocalFileServiceImpl implements IDfsService
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 本地文件上传接口
|
* 本地文件上传接口
|
||||||
*
|
*
|
||||||
* @param file 上传的文件
|
* @param file 上传的文件
|
||||||
* @return 访问地址
|
* @return 访问地址
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,6 @@ import io.minio.http.Method;
|
||||||
import io.minio.messages.Item;
|
import io.minio.messages.Item;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
|
||||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
|
||||||
import org.springframework.context.annotation.Primary;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import com.ruoyi.file.config.MinioConfig;
|
import com.ruoyi.file.config.MinioConfig;
|
||||||
|
|
@ -24,7 +21,7 @@ import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minio 文件存储
|
* Minio 文件存储
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
* 官网博客: http://docs.minio.org.cn/docs/master/java-client-quickstart-guidec
|
* 官网博客: http://docs.minio.org.cn/docs/master/java-client-quickstart-guidec
|
||||||
* 在springboot中使用Minio8 https://springboot.io/t/topic/3109
|
* 在springboot中使用Minio8 https://springboot.io/t/topic/3109
|
||||||
|
|
@ -38,7 +35,7 @@ import java.util.function.Consumer;
|
||||||
*/
|
*/
|
||||||
//@Primary
|
//@Primary
|
||||||
@Service()
|
@Service()
|
||||||
public class MinioDfsServiceImpl implements IDfsService
|
public class MinioSysFileServiceImpl implements ISysFileService
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
private MinioConfig minioConfig;
|
private MinioConfig minioConfig;
|
||||||
|
|
@ -47,7 +44,7 @@ public class MinioDfsServiceImpl implements IDfsService
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 本地文件上传接口
|
* 本地文件上传接口
|
||||||
*
|
*
|
||||||
* @param file 上传的文件
|
* @param file 上传的文件
|
||||||
* @return 访问地址
|
* @return 访问地址
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
|
@ -16,7 +16,6 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Primary;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
|
@ -34,8 +33,8 @@ import java.io.InputStream;
|
||||||
*/
|
*/
|
||||||
//@Primary
|
//@Primary
|
||||||
@Service()
|
@Service()
|
||||||
public class QiniuDfsServiceImpl implements IDfsService {
|
public class QiniuSysFileServiceImpl implements ISysFileService {
|
||||||
private static final Logger log = LoggerFactory.getLogger(QiniuDfsServiceImpl.class);
|
private static final Logger log = LoggerFactory.getLogger(QiniuSysFileServiceImpl.class);
|
||||||
@Autowired
|
@Autowired
|
||||||
private QiniuKodoConfig qiniuKodoConfig;
|
private QiniuKodoConfig qiniuKodoConfig;
|
||||||
|
|
||||||
|
|
@ -9,7 +9,6 @@ import com.qcloud.cos.model.*;
|
||||||
import com.ruoyi.common.core.exception.CustomException;
|
import com.ruoyi.common.core.exception.CustomException;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.file.config.TencentCosConfig;
|
import com.ruoyi.file.config.TencentCosConfig;
|
||||||
import org.springframework.context.annotation.Primary;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
|
@ -25,7 +24,7 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
//@Primary
|
//@Primary
|
||||||
@Service()
|
@Service()
|
||||||
public class TencentCosServiceImpl implements IDfsService {
|
public class TencentCosServiceImpl implements ISysFileService {
|
||||||
private final COSClient cosClient;
|
private final COSClient cosClient;
|
||||||
private final TencentCosConfig config;
|
private final TencentCosConfig config;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue