mirror of
https://github.com/zfile-dev/zfile.git
synced 2025-04-19 05:34:52 +00:00
🎨 代码规范调整, 移除无效引用, 增加注释.
This commit is contained in:
@@ -16,4 +16,4 @@ public class DriveCacheKey {
|
||||
|
||||
private String key;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -40,4 +40,5 @@ public class MyTimedCache<K, V> extends TimedCache<K, V> {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,8 +3,6 @@ package im.zhaojun.zfile.config;
|
||||
import im.zhaojun.zfile.model.constant.StorageConfigConstant;
|
||||
import im.zhaojun.zfile.model.entity.StorageConfig;
|
||||
import im.zhaojun.zfile.service.StorageConfigService;
|
||||
import im.zhaojun.zfile.service.impl.OneDriveChinaServiceImpl;
|
||||
import im.zhaojun.zfile.service.impl.OneDriveServiceImpl;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
@@ -24,12 +22,6 @@ public class OneDriveConfig {
|
||||
@Resource
|
||||
private StorageConfigService storageConfigService;
|
||||
|
||||
@Resource
|
||||
private OneDriveServiceImpl oneDriveServiceImpl;
|
||||
|
||||
@Resource
|
||||
private OneDriveChinaServiceImpl oneDriveChinaServiceImpl;
|
||||
|
||||
/**
|
||||
* OneDrive 请求 RestTemplate, 会在请求头中添加 Bearer: Authorization {token} 信息, 用于 API 认证.
|
||||
*/
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/common")
|
||||
public class FIleParseController {
|
||||
public class FileParseController {
|
||||
|
||||
/**
|
||||
* 获取文件内容, 仅限用于 txt, md, ini 等普通文本文件.
|
||||
@@ -1,10 +1,8 @@
|
||||
package im.zhaojun.zfile.controller.install;
|
||||
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import im.zhaojun.zfile.controller.admin.AdminController;
|
||||
import im.zhaojun.zfile.model.dto.SystemConfigDTO;
|
||||
import im.zhaojun.zfile.model.support.ResultBean;
|
||||
import im.zhaojun.zfile.service.StorageConfigService;
|
||||
import im.zhaojun.zfile.service.SystemConfigService;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -23,12 +21,6 @@ public class InstallController {
|
||||
@Resource
|
||||
private SystemConfigService systemConfigService;
|
||||
|
||||
@Resource
|
||||
private StorageConfigService storageConfigService;
|
||||
|
||||
@Resource
|
||||
private AdminController adminController;
|
||||
|
||||
@GetMapping("/is-installed")
|
||||
public ResultBean isInstall() {
|
||||
if (!StringUtils.isEmpty(systemConfigService.getAdminUsername())) {
|
||||
|
||||
@@ -5,8 +5,6 @@ import im.zhaojun.zfile.model.entity.DriveConfig;
|
||||
import im.zhaojun.zfile.model.enums.StorageTypeEnum;
|
||||
import im.zhaojun.zfile.service.DriveConfigService;
|
||||
import im.zhaojun.zfile.service.base.AbstractOneDriveServiceBase;
|
||||
import im.zhaojun.zfile.service.impl.OneDriveChinaServiceImpl;
|
||||
import im.zhaojun.zfile.service.impl.OneDriveServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
@@ -25,12 +23,6 @@ import java.util.List;
|
||||
@Slf4j
|
||||
public class OneDriveTokenRefreshSchedule {
|
||||
|
||||
@Resource
|
||||
private OneDriveServiceImpl oneDriveServiceImpl;
|
||||
|
||||
@Resource
|
||||
private OneDriveChinaServiceImpl oneDriveChinaServiceImpl;
|
||||
|
||||
@Resource
|
||||
private DriveConfigService driveConfigService;
|
||||
|
||||
|
||||
@@ -121,7 +121,6 @@ public class DriveConfigService {
|
||||
* @return 驱动器对应的存储策略.
|
||||
*/
|
||||
public StorageTypeEnum findStorageTypeById(Integer id) {
|
||||
// return findById(id).getType();
|
||||
return driverConfigRepository.findById(id).get().getType();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import im.zhaojun.zfile.exception.InitializeDriveException;
|
||||
import im.zhaojun.zfile.model.dto.FileItemDTO;
|
||||
import im.zhaojun.zfile.model.entity.StorageConfig;
|
||||
import im.zhaojun.zfile.model.enums.StorageTypeEnum;
|
||||
import im.zhaojun.zfile.service.SystemConfigService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
@@ -18,6 +17,10 @@ import java.util.List;
|
||||
@Slf4j
|
||||
public abstract class AbstractBaseFileService implements BaseFileService {
|
||||
|
||||
|
||||
@Resource
|
||||
private ZFileCache zFileCache;
|
||||
|
||||
/**
|
||||
* 下载链接过期时间, 目前只在兼容 S3 协议的存储策略中使用到.
|
||||
*/
|
||||
@@ -29,23 +32,16 @@ public abstract class AbstractBaseFileService implements BaseFileService {
|
||||
*/
|
||||
protected boolean isInitialized = false;
|
||||
|
||||
|
||||
/**
|
||||
* 基路径
|
||||
*/
|
||||
protected String basePath;
|
||||
|
||||
/**
|
||||
* 驱动器 ID
|
||||
*/
|
||||
public Integer driveId;
|
||||
|
||||
@Resource
|
||||
private SystemConfigService systemConfigService;
|
||||
|
||||
@Resource
|
||||
private ZFileCache zFileCache;
|
||||
|
||||
|
||||
/***
|
||||
* 获取指定路径下的文件及文件夹, 默认缓存 60 分钟,每隔 30 分钟刷新一次.
|
||||
*
|
||||
@@ -70,14 +66,15 @@ public abstract class AbstractBaseFileService implements BaseFileService {
|
||||
|
||||
/**
|
||||
* 初始化方法, 启动时自动调用实现类的此方法进行初始化.
|
||||
*
|
||||
* @param driveId
|
||||
* 驱动器 ID
|
||||
*/
|
||||
public abstract void init(Integer driveId);
|
||||
|
||||
|
||||
/**
|
||||
* 测试是否连接成功, 会尝试取调用获取根路径的文件, 如果没有抛出异常, 则认为连接成功, 某些存储策略需要复写此方法.
|
||||
*
|
||||
* @return 连接结果
|
||||
*/
|
||||
protected void testConnection() {
|
||||
try {
|
||||
|
||||
@@ -176,8 +176,6 @@ public abstract class AbstractOneDriveServiceBase extends AbstractBaseFileServic
|
||||
|
||||
String fullPath = StringUtils.getFullPath(basePath, path);
|
||||
|
||||
String requestUrl;
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("driveId", driveId.toString());
|
||||
HttpEntity<Object> entity = new HttpEntity<>(headers);
|
||||
@@ -205,16 +203,41 @@ public abstract class AbstractOneDriveServiceBase extends AbstractBaseFileServic
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取 GraphEndPoint, 对于不同版本的 OneDrive, 此地址会不同.
|
||||
* @return Graph 连接点
|
||||
*/
|
||||
public abstract String getGraphEndPoint();
|
||||
|
||||
|
||||
/**
|
||||
* 获取 AuthenticateEndPoint, 对于不同版本的 OneDrive, 此地址会不同.
|
||||
* @return Authenticate 连接点
|
||||
*/
|
||||
public abstract String getAuthenticateEndPoint();
|
||||
|
||||
/**
|
||||
* 获取 Client ID.
|
||||
* @return Client Id
|
||||
*/
|
||||
public abstract String getClientId();
|
||||
|
||||
/**
|
||||
* 获取重定向地址.
|
||||
* @return 重定向地址
|
||||
*/
|
||||
public abstract String getRedirectUri();
|
||||
|
||||
/**
|
||||
* 获取 Client Secret 密钥.
|
||||
* @return Client Secret 密钥.
|
||||
*/
|
||||
public abstract String getClientSecret();
|
||||
|
||||
/**
|
||||
* 获取 API Scope.
|
||||
* @return Scope
|
||||
*/
|
||||
public abstract String getScope();
|
||||
|
||||
public void refreshOneDriveToken() {
|
||||
|
||||
@@ -15,8 +15,6 @@ import lombok.SneakyThrows;
|
||||
import org.apache.commons.net.ftp.FTP;
|
||||
import org.apache.commons.net.ftp.FTPClientConfig;
|
||||
import org.apache.commons.net.ftp.FTPFile;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -36,8 +34,6 @@ import java.util.Objects;
|
||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class FtpServiceImpl extends AbstractBaseFileService implements BaseFileService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(FtpServiceImpl.class);
|
||||
|
||||
@Resource
|
||||
private StorageConfigService storageConfigService;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user