From 47f606673362df38eac72ea3ffb5bc3a72c4cfa4 Mon Sep 17 00:00:00 2001
From: zhaojun <873019219@qq.com>
Date: Tue, 20 Sep 2022 18:12:01 +0800
Subject: [PATCH] =?UTF-8?q?:hammer:=20=E9=87=8D=E6=9E=84=E4=BB=A3=E7=A0=81?=
=?UTF-8?q?=EF=BC=8C=E5=B0=86=E6=8D=90=E8=B5=A0=E7=89=88=E5=B7=B2=E9=AA=8C?=
=?UTF-8?q?=E8=AF=81=E7=9A=84=E5=8A=9F=E8=83=BD=E5=90=88=E5=B9=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 7 +-
.../im/zhaojun/zfile/ZfileApplication.java | 8 +-
.../admin/controller/CacheController.java | 108 ----
.../link/DownloadLogManagerController.java | 150 ------
.../link/ShortLinkManagerController.java | 143 -----
.../controller/login/LoginController.java | 1 -
.../ForbidFileOperationException.java | 22 -
.../zfile/admin/mapper/DownloadLogMapper.java | 15 -
.../model/dto/StorageSourceCacheKey.java | 21 -
.../admin/model/param/IStorageParam.java | 5 -
.../admin/model/verify/VerifyResult.java | 56 --
.../admin/service/DownloadLogService.java | 17 -
.../admin/service/FilterConfigService.java | 219 --------
.../admin/service/PasswordConfigService.java | 159 ------
.../admin/service/ReadmeConfigService.java | 114 ----
.../service/StorageSourceConfigService.java | 119 -----
.../admin/service/StorageSourceService.java | 503 ------------------
.../zfile/common/cache/MyTimedCache.java | 61 ---
.../zfile/common/cache/ZFileCache.java | 257 ---------
.../common/config/FlywayDbInitializer.java | 1 -
.../common/config/Knife4jConfiguration.java | 1 -
.../common/config/MybatisEnumTypeHandler.java | 173 ------
.../zfile/common/config/SaTokenConfigure.java | 1 -
.../DisableProxyDownloadException.java | 10 -
.../common/exception/FileAccessException.java | 31 --
.../common/exception/FileUploadException.java | 27 -
.../common/exception/GlobalException.java | 1 -
.../IllegalDownloadLinkException.java | 21 -
.../InitializeStorageSourceException.java | 30 --
.../exception/InstallSystemException.java | 30 --
.../exception/InvalidShortLinkException.java | 29 -
.../InvalidStorageSourceException.java | 29 -
.../NotAllowedDownloadException.java | 29 -
.../NotEnabledStorageSourceException.java | 29 -
.../exception/NotExistFileException.java | 30 --
.../common/exception/PreviewException.java | 29 -
.../exception/RefreshCacheException.java | 29 -
.../common/exception/TextParseException.java | 30 --
.../exception/UnSupportedOperation.java | 29 -
.../file/StorageSourceException.java | 37 --
.../file/operator/DownloadFileException.java | 24 -
.../file/operator/GetFileInfoException.java | 35 --
.../operator/ProxyDownloadFileException.java | 24 -
.../zhaojun/zfile/common/util/AjaxJson.java | 1 -
.../core/CommonResultControllerAdvice.java | 67 +++
.../core/config/FlywayDbInitializer.java | 1 +
.../config/JacksonEnumDeserializer.java | 2 +-
.../core/config/Knife4jConfiguration.java | 1 +
.../config/MyBatisPlusConfig.java | 2 +-
.../config/RestTemplateConfig.java | 8 +-
.../zfile/core/config/SaTokenConfigure.java | 1 +
.../zfile/core/config/SpringCacheConfig.java | 27 +
.../config/StringToEnumConverterFactory.java | 2 +-
.../{common => core}/config/WebMvcConfig.java | 10 +-
.../config/ZFileProperties.java | 4 +-
.../zfile/core/constant/MdcConstant.java | 16 +
.../constant/ZFileConstant.java | 28 +-
.../controller}/FrontIndexController.java | 2 +-
.../controller/LogController.java | 4 +-
.../IllegalDownloadLinkException.java | 14 +
.../exception/InstallSystemException.java | 14 +
.../exception/InvalidShortLinkException.java | 14 +
.../exception/LoginVerifyException.java | 4 +-
.../exception/PasswordVerifyException.java | 2 +-
.../core/exception/PreviewException.java | 14 +
.../core/exception/ServiceException.java | 42 ++
.../StorageSourceAutoConfigCorsException.java | 4 +-
.../exception/StorageSourceException.java | 60 +++
...eSourceNotSupportProxyUploadException.java | 4 +-
.../StorageSourceRefreshTokenException.java | 6 +-
.../core/exception/TextParseException.java | 17 +
.../core/exception/ZFileRuntimeException.java | 15 +
.../file/InvalidStorageSourceException.java | 25 +
.../InitializeStorageSourceException.java | 21 +
.../DisableProxyDownloadException.java | 24 +
.../StorageSourceFileOperatorException.java | 18 +
.../handler/GlobalExceptionHandler.java | 1 +
.../HttpResponseStatusErrorException.java | 12 +
.../{common => core}/filter/CorsFilter.java | 2 +-
.../zhaojun/zfile/core/filter/MDCFilter.java | 41 ++
.../core/model/request/PageQueryRequest.java | 24 +
.../im/zhaojun/zfile/core/util/AjaxJson.java | 1 +
.../{common => core}/util/ClassUtils.java | 2 +-
.../im/zhaojun/zfile/core/util/CodeMsg.java | 76 +++
.../util/EnumConvertUtils.java | 2 +-
.../{common => core}/util/FileComparator.java | 6 +-
.../util/FileResponseUtil.java | 3 +-
.../zfile/{common => core}/util/HttpUtil.java | 11 +-
.../util/NaturalOrderComparator.java | 2 +-
.../zfile/core/util/PatternMatcherUtils.java | 72 +++
.../util/PlaceholderUtils.java | 8 +-
.../util/ProxyDownloadUrlUtils.java | 30 +-
.../{common => core}/util/RequestHolder.java | 2 +-
.../{common => core}/util/SizeToStrUtils.java | 2 +-
.../{common => core}/util/StringUtils.java | 14 +-
.../im/zhaojun/zfile/core/util/UrlUtils.java | 34 ++
.../validation/StringListValue.java | 2 +-
.../StringListValueConstraintValidator.java | 2 +-
.../home/aspect/FileListCacheAspect.java | 66 ---
.../zfile/home/controller/FileController.java | 1 -
.../zfile/home/controller/SiteController.java | 158 ------
.../home/convert/StorageSourceConvert.java | 55 --
.../zfile/home/model/dto/CacheInfoDTO.java | 32 --
.../home/model/request/UserLoginRequest.java | 1 -
.../service/base/RefreshTokenService.java | 12 -
.../constant/SystemConfigConstant.java | 2 +-
.../config/controller}/InstallController.java | 15 +-
.../config/controller}/SettingController.java | 18 +-
.../config/controller/SiteController.java | 80 +++
.../config}/mapper/SystemConfigMapper.java | 4 +-
.../config}/model/dto/SystemConfigDTO.java | 11 +-
.../config}/model/entity/SystemConfig.java | 4 +-
.../model/enums/FileClickModeEnum.java | 2 +-
.../model/request/InstallSystemRequest.java | 2 +-
.../request}/UpdateLinkSettingRequest.java | 7 +-
.../UpdateSecuritySettingRequest.java | 4 +-
.../request}/UpdateSiteSettingRequest.java | 2 +-
.../UpdateUserNameAndPasswordRequest.java | 2 +-
.../request}/UpdateViewSettingRequest.java | 4 +-
.../model/request/UpdateWebDAVRequest.java | 26 +
.../model/result/SiteConfigResult.java | 6 +-
.../config}/service/SystemConfigService.java | 189 +++----
.../StorageSourceFilterController.java | 12 +-
.../filter}/mapper/FilterConfigMapper.java | 4 +-
.../filter}/model/entity/FilterConfig.java | 4 +-
.../enums/FilterConfigHiddenModeEnum.java | 2 +-
.../filter/service/FilterConfigService.java | 229 ++++++++
.../link}/aspect/RefererCheckAspect.java | 12 +-
.../link}/controller/ShortLinkController.java | 65 +--
.../ShortLinkManagerController.java | 132 +++++
.../link}/convert/ShortLinkConvert.java | 8 +-
.../link}/mapper/ShortLinkMapper.java | 16 +-
.../link}/model/entity/ShortLink.java | 4 +-
.../link}/model/enums/RefererTypeEnum.java | 2 +-
.../model/request}/BatchDeleteRequest.java | 2 +-
.../request/BatchGenerateLinkRequest.java | 2 +-
.../request}/QueryDownloadLogRequest.java | 20 +-
.../request/QueryShortLinkLogRequest.java | 30 ++
.../link/model/request}/ShortLinkResult.java | 4 +-
.../model/request/ShortLinkSearchRequest.java | 2 +-
.../result/BatchGenerateLinkResponse.java | 2 +-
.../link}/service/ShortLinkService.java | 142 ++---
.../DownloadLogManagerController.java | 116 ++++
.../log}/convert/DownloadLogConvert.java | 8 +-
.../module/log/mapper/DownloadLogMapper.java | 23 +
.../log/model/dto/DownloadTopFileDTO.java | 26 +
.../log/model/dto/DownloadTopIpDTO.java | 19 +
.../log/model/dto/DownloadTopRefererDTO.java | 19 +
.../log}/model/entity/DownloadLog.java | 5 +-
.../model/request/DownloadTopInfoRequest.java | 2 +-
.../log/model/result}/DownloadLogResult.java | 21 +-
.../log/service/DownloadLogService.java | 45 ++
.../login/controller/LoginController.java | 1 +
.../model/enums/LoginVerifyModeEnum.java | 2 +-
...fyLoginTwoFactorAuthenticatorRequest.java} | 4 +-
.../LoginTwoFactorAuthenticatorResult.java} | 4 +-
.../model/result}/LoginVerifyImgResult.java | 2 +-
.../login/request/UserLoginRequest.java | 1 +
.../login/service}/ImgVerifyCodeService.java | 6 +-
.../TwoFactorAuthenticatorVerifyService.java} | 28 +-
.../StorageSourcePasswordController.java | 12 +-
.../mapper/PasswordConfigMapper.java | 4 +-
.../password/model/dto/VerifyResultDTO.java | 56 ++
.../model/entity/PasswordConfig.java | 2 +-
.../service/PasswordConfigService.java | 208 ++++++++
.../StorageSourceReadmeController.java | 12 +-
.../readme}/mapper/ReadmeConfigMapper.java | 4 +-
.../readme}/model/entity/ReadmeConfig.java | 4 +-
.../model/enums/ReadmeDisplayModeEnum.java | 2 +-
.../readme/service/ReadmeConfigService.java | 212 ++++++++
.../storage/annotation/CheckPassword.java | 37 ++
.../storage}/annotation/RefererCheck.java | 2 +-
.../storage}/annotation/StorageParamItem.java | 4 +-
.../annotation/StorageParamSelect.java | 6 +-
.../annotation/StorageParamSelectOption.java | 2 +-
.../impl/EncodingStorageParamSelect.java | 10 +-
.../storage/aspect/CheckPasswordAspect.java | 92 ++++
.../aspect/FileOperatorCheckAspect.java | 33 +-
.../FileOperatorExceptionWrapperAspect.java | 139 +++++
.../storage}/chain/FileChain.java | 12 +-
.../storage}/chain/FileContext.java | 6 +-
.../FileAccessPermissionVerifyCommand.java | 22 +-
.../chain/command/FileHiddenCommand.java | 28 +-
.../chain/command/FileSortCommand.java | 10 +-
.../command/FileUrlAddVersionCommand.java | 6 +-
.../command/FolderPasswordVerifyCommand.java | 28 +-
.../constant/StorageConfigConstant.java | 2 +-
.../context/StorageSourceContext.java | 304 +++++------
.../base}/StorageMetaDataController.java | 10 +-
.../base}/StorageSourceController.java | 47 +-
.../GoogleDriveCallbackController.java} | 18 +-
.../callback/OneDriveCallbackController.java | 20 +-
.../controller/file/FileController.java | 1 +
.../file}/FileOperatorController.java | 105 +++-
.../controller/file}/FileParseController.java | 15 +-
.../helper/GoogleDriveHelperController.java} | 18 +-
.../helper}/S3HelperController.java | 8 +-
.../helper}/SharePointHelperController.java | 38 +-
.../proxy}/ProxyDownloadController.java | 25 +-
.../proxy}/ProxyUploadController.java | 18 +-
.../storage/convert/StorageSourceConvert.java | 75 +++
.../storage}/filter/DownloadLinkFilter.java | 39 +-
.../mapper/StorageSourceConfigMapper.java | 20 +-
.../storage}/mapper/StorageSourceMapper.java | 6 +-
.../storage/model/bo}/AuthModel.java | 2 +-
.../model/bo/RefreshTokenCacheBO.java} | 12 +-
.../model/bo}/StorageSourceParamDef.java | 6 +-
.../storage/model/bo}/UploadSignParam.java | 2 +-
.../dto/FileOperatorTypeDefaultValueDTO.java | 19 +
.../storage/model/dto/OAuth2TokenDTO.java} | 12 +-
.../model/dto/StorageSourceAllParamDTO.java} | 4 +-
.../storage}/model/dto/StorageSourceDTO.java | 8 +-
.../storage}/model/entity/StorageSource.java | 11 +-
.../model/entity/StorageSourceConfig.java | 6 +-
.../model/enums/FileOperatorTypeEnum.java | 20 +-
.../storage}/model/enums/FileTypeEnum.java | 2 +-
.../storage}/model/enums/SearchModeEnum.java | 2 +-
.../model/enums/StorageParamTypeEnum.java | 2 +-
.../storage}/model/enums/StorageTypeEnum.java | 2 +-
.../storage}/model/param/AliyunParam.java | 2 +-
.../storage}/model/param/FtpParam.java | 8 +-
.../model/param/GoogleDriveParam.java | 4 +-
.../storage}/model/param/HuaweiParam.java | 2 +-
.../storage/model/param/IStorageParam.java | 7 +
.../storage}/model/param/LocalParam.java | 4 +-
.../model/param/MicrosoftDriveParam.java | 4 +-
.../storage}/model/param/MinIOParam.java | 4 +-
.../model/param/OneDriveChinaParam.java | 4 +-
.../storage}/model/param/OneDriveParam.java | 2 +-
.../model/param/ProxyDownloadParam.java | 2 +-
.../model/param/ProxyTransferParam.java | 6 +-
.../model/param/ProxyUploadParam.java | 2 +-
.../storage}/model/param/QiniuParam.java | 2 +-
.../storage}/model/param/S3BaseParam.java | 9 +-
.../storage}/model/param/S3Param.java | 14 +-
.../storage}/model/param/SftpParam.java | 2 +-
.../model/param/SharePointChinaParam.java | 4 +-
.../storage}/model/param/SharePointParam.java | 4 +-
.../storage}/model/param/TencentParam.java | 4 +-
.../storage}/model/param/UpYunParam.java | 4 +-
.../storage}/model/param/WebdavParam.java | 4 +-
.../request/GetGoogleDriveListRequest.java} | 4 +-
.../request}/GetS3BucketListRequest.java | 2 +-
.../model/request/SharePointInfoRequest.java | 2 +-
.../SharePointSearchSitesRequest.java | 4 +-
.../request}/SharePointSiteListsRequest.java | 4 +-
.../admin}/UpdateStorageIdRequest.java | 2 +-
.../admin}/UpdateStorageSortRequest.java | 2 +-
.../model/request/base}/FileItemRequest.java | 4 +-
.../request/base}/FileListConfigRequest.java | 4 +-
.../model/request/base}/FileListRequest.java | 6 +-
.../base}/SaveStorageSourceRequest.java | 10 +-
.../request/operator/BatchDeleteRequest.java | 7 +-
.../request/operator/NewFolderRequest.java | 8 +-
.../request/operator/RenameFileRequest.java | 8 +-
.../request/operator/RenameFolderRequest.java | 8 +-
.../request/operator/UploadFileRequest.java | 8 +-
.../storage}/model/result/FileInfoResult.java | 2 +-
.../storage}/model/result/FileItemResult.java | 16 +-
.../model/result/GoogleDriveInfoResult.java} | 4 +-
.../model/result}/S3BucketNameResult.java | 2 +-
.../result/SharepointSiteListResult.java} | 4 +-
.../model/result/SharepointSiteResult.java} | 4 +-
.../result}/StorageSourceAdminResult.java | 10 +-
.../result/StorageSourceConfigResult.java | 4 +-
.../model/result/StorageSourceResult.java | 4 +-
.../schedule/AccessTokenRefreshSchedule.java | 13 +-
.../service/StorageSourceConfigService.java | 192 +++++++
.../storage/service/StorageSourceService.java | 369 +++++++++++++
.../service/base/AbstractBaseFileService.java | 48 +-
.../base/AbstractMicrosoftDriveService.java} | 141 ++---
.../base/AbstractOneDriveServiceBase.java | 6 +-
.../base/AbstractProxyDownloadService.java} | 6 +-
.../base/AbstractProxyTransferService.java} | 21 +-
.../base/AbstractProxyUploadService.java} | 6 +-
.../base/AbstractS3BaseFileService.java | 174 +++---
.../base/AbstractSharePointServiceBase.java | 9 +-
.../service/base/BaseFileService.java | 15 +-
.../service/base/RefreshTokenService.java | 17 +
.../service/impl/AliyunServiceImpl.java | 12 +-
.../storage}/service/impl/FtpServiceImpl.java | 67 ++-
.../service/impl/GoogleDriveServiceImpl.java | 168 +++---
.../service/impl/HuaweiServiceImpl.java | 8 +-
.../service/impl/LocalServiceImpl.java | 81 +--
.../service/impl/MinIOServiceImpl.java | 8 +-
.../impl/OneDriveChinaServiceImpl.java | 8 +-
.../service/impl/OneDriveServiceImpl.java | 8 +-
.../service/impl/QiniuServiceImpl.java | 16 +-
.../storage}/service/impl/S3ServiceImpl.java | 10 +-
.../service/impl/SftpServiceImpl.java | 35 +-
.../impl/SharePointChinaServiceImpl.java | 8 +-
.../service/impl/SharePointServiceImpl.java | 8 +-
.../service/impl/TencentServiceImpl.java | 8 +-
.../service/impl/UpYunServiceImpl.java | 82 ++-
.../service/impl/WebdavServiceImpl.java | 42 +-
...itional-spring-configuration-metadata.json | 32 --
.../resources/application-default.properties | 2 +-
src/main/resources/application.properties | 4 -
..._add_field_allow_path_link_anon_access.sql | 1 +
..._add_field_allow_path_link_anon_access.sql | 1 +
src/main/resources/logback-spring.xml | 180 +++++--
.../resources/mapper/DownloadLogMapper.xml | 51 +-
.../resources/mapper/FilterConfigMapper.xml | 4 +-
.../resources/mapper/PasswordConfigMapper.xml | 4 +-
.../resources/mapper/ReadmeConfigMapper.xml | 4 +-
src/main/resources/mapper/ShortLinkMapper.xml | 9 +-
.../resources/mapper/StorageConfigMapper.xml | 12 +-
.../resources/mapper/StorageSourceMapper.xml | 8 +-
.../resources/mapper/SystemConfigMapper.xml | 4 +-
309 files changed, 4591 insertions(+), 4620 deletions(-)
delete mode 100644 src/main/java/im/zhaojun/zfile/admin/controller/CacheController.java
delete mode 100644 src/main/java/im/zhaojun/zfile/admin/controller/link/DownloadLogManagerController.java
delete mode 100644 src/main/java/im/zhaojun/zfile/admin/controller/link/ShortLinkManagerController.java
delete mode 100644 src/main/java/im/zhaojun/zfile/admin/controller/login/LoginController.java
delete mode 100644 src/main/java/im/zhaojun/zfile/admin/exception/ForbidFileOperationException.java
delete mode 100644 src/main/java/im/zhaojun/zfile/admin/mapper/DownloadLogMapper.java
delete mode 100644 src/main/java/im/zhaojun/zfile/admin/model/dto/StorageSourceCacheKey.java
delete mode 100644 src/main/java/im/zhaojun/zfile/admin/model/param/IStorageParam.java
delete mode 100644 src/main/java/im/zhaojun/zfile/admin/model/verify/VerifyResult.java
delete mode 100644 src/main/java/im/zhaojun/zfile/admin/service/DownloadLogService.java
delete mode 100644 src/main/java/im/zhaojun/zfile/admin/service/FilterConfigService.java
delete mode 100644 src/main/java/im/zhaojun/zfile/admin/service/PasswordConfigService.java
delete mode 100644 src/main/java/im/zhaojun/zfile/admin/service/ReadmeConfigService.java
delete mode 100644 src/main/java/im/zhaojun/zfile/admin/service/StorageSourceConfigService.java
delete mode 100644 src/main/java/im/zhaojun/zfile/admin/service/StorageSourceService.java
delete mode 100644 src/main/java/im/zhaojun/zfile/common/cache/MyTimedCache.java
delete mode 100644 src/main/java/im/zhaojun/zfile/common/cache/ZFileCache.java
delete mode 100644 src/main/java/im/zhaojun/zfile/common/config/FlywayDbInitializer.java
delete mode 100644 src/main/java/im/zhaojun/zfile/common/config/Knife4jConfiguration.java
delete mode 100644 src/main/java/im/zhaojun/zfile/common/config/MybatisEnumTypeHandler.java
delete mode 100644 src/main/java/im/zhaojun/zfile/common/config/SaTokenConfigure.java
delete mode 100644 src/main/java/im/zhaojun/zfile/common/exception/DisableProxyDownloadException.java
delete mode 100644 src/main/java/im/zhaojun/zfile/common/exception/FileAccessException.java
delete mode 100644 src/main/java/im/zhaojun/zfile/common/exception/FileUploadException.java
delete mode 100644 src/main/java/im/zhaojun/zfile/common/exception/GlobalException.java
delete mode 100644 src/main/java/im/zhaojun/zfile/common/exception/IllegalDownloadLinkException.java
delete mode 100644 src/main/java/im/zhaojun/zfile/common/exception/InitializeStorageSourceException.java
delete mode 100644 src/main/java/im/zhaojun/zfile/common/exception/InstallSystemException.java
delete mode 100644 src/main/java/im/zhaojun/zfile/common/exception/InvalidShortLinkException.java
delete mode 100644 src/main/java/im/zhaojun/zfile/common/exception/InvalidStorageSourceException.java
delete mode 100644 src/main/java/im/zhaojun/zfile/common/exception/NotAllowedDownloadException.java
delete mode 100644 src/main/java/im/zhaojun/zfile/common/exception/NotEnabledStorageSourceException.java
delete mode 100644 src/main/java/im/zhaojun/zfile/common/exception/NotExistFileException.java
delete mode 100644 src/main/java/im/zhaojun/zfile/common/exception/PreviewException.java
delete mode 100644 src/main/java/im/zhaojun/zfile/common/exception/RefreshCacheException.java
delete mode 100644 src/main/java/im/zhaojun/zfile/common/exception/TextParseException.java
delete mode 100644 src/main/java/im/zhaojun/zfile/common/exception/UnSupportedOperation.java
delete mode 100644 src/main/java/im/zhaojun/zfile/common/exception/file/StorageSourceException.java
delete mode 100644 src/main/java/im/zhaojun/zfile/common/exception/file/operator/DownloadFileException.java
delete mode 100644 src/main/java/im/zhaojun/zfile/common/exception/file/operator/GetFileInfoException.java
delete mode 100644 src/main/java/im/zhaojun/zfile/common/exception/file/operator/ProxyDownloadFileException.java
delete mode 100644 src/main/java/im/zhaojun/zfile/common/util/AjaxJson.java
create mode 100644 src/main/java/im/zhaojun/zfile/core/CommonResultControllerAdvice.java
create mode 100644 src/main/java/im/zhaojun/zfile/core/config/FlywayDbInitializer.java
rename src/main/java/im/zhaojun/zfile/{common => core}/config/JacksonEnumDeserializer.java (98%)
create mode 100644 src/main/java/im/zhaojun/zfile/core/config/Knife4jConfiguration.java
rename src/main/java/im/zhaojun/zfile/{common => core}/config/MyBatisPlusConfig.java (97%)
rename src/main/java/im/zhaojun/zfile/{common => core}/config/RestTemplateConfig.java (92%)
create mode 100644 src/main/java/im/zhaojun/zfile/core/config/SaTokenConfigure.java
create mode 100644 src/main/java/im/zhaojun/zfile/core/config/SpringCacheConfig.java
rename src/main/java/im/zhaojun/zfile/{common => core}/config/StringToEnumConverterFactory.java (99%)
rename src/main/java/im/zhaojun/zfile/{common => core}/config/WebMvcConfig.java (93%)
rename src/main/java/im/zhaojun/zfile/{common => core}/config/ZFileProperties.java (84%)
create mode 100644 src/main/java/im/zhaojun/zfile/core/constant/MdcConstant.java
rename src/main/java/im/zhaojun/zfile/{common => core}/constant/ZFileConstant.java (51%)
rename src/main/java/im/zhaojun/zfile/{common/controller/front => core/controller}/FrontIndexController.java (91%)
rename src/main/java/im/zhaojun/zfile/{admin => core}/controller/LogController.java (93%)
create mode 100644 src/main/java/im/zhaojun/zfile/core/exception/IllegalDownloadLinkException.java
create mode 100644 src/main/java/im/zhaojun/zfile/core/exception/InstallSystemException.java
create mode 100644 src/main/java/im/zhaojun/zfile/core/exception/InvalidShortLinkException.java
rename src/main/java/im/zhaojun/zfile/{common => core}/exception/LoginVerifyException.java (55%)
rename src/main/java/im/zhaojun/zfile/{common => core}/exception/PasswordVerifyException.java (88%)
create mode 100644 src/main/java/im/zhaojun/zfile/core/exception/PreviewException.java
create mode 100644 src/main/java/im/zhaojun/zfile/core/exception/ServiceException.java
rename src/main/java/im/zhaojun/zfile/{admin => core}/exception/StorageSourceAutoConfigCorsException.java (78%)
create mode 100644 src/main/java/im/zhaojun/zfile/core/exception/StorageSourceException.java
rename src/main/java/im/zhaojun/zfile/{common => core}/exception/StorageSourceNotSupportProxyUploadException.java (77%)
rename src/main/java/im/zhaojun/zfile/{common => core}/exception/StorageSourceRefreshTokenException.java (76%)
create mode 100644 src/main/java/im/zhaojun/zfile/core/exception/TextParseException.java
create mode 100644 src/main/java/im/zhaojun/zfile/core/exception/ZFileRuntimeException.java
create mode 100644 src/main/java/im/zhaojun/zfile/core/exception/file/InvalidStorageSourceException.java
create mode 100644 src/main/java/im/zhaojun/zfile/core/exception/file/init/InitializeStorageSourceException.java
create mode 100644 src/main/java/im/zhaojun/zfile/core/exception/file/operator/DisableProxyDownloadException.java
create mode 100644 src/main/java/im/zhaojun/zfile/core/exception/file/operator/StorageSourceFileOperatorException.java
create mode 100644 src/main/java/im/zhaojun/zfile/core/exception/handler/GlobalExceptionHandler.java
create mode 100644 src/main/java/im/zhaojun/zfile/core/exception/http/HttpResponseStatusErrorException.java
rename src/main/java/im/zhaojun/zfile/{common => core}/filter/CorsFilter.java (97%)
create mode 100644 src/main/java/im/zhaojun/zfile/core/filter/MDCFilter.java
create mode 100644 src/main/java/im/zhaojun/zfile/core/model/request/PageQueryRequest.java
create mode 100644 src/main/java/im/zhaojun/zfile/core/util/AjaxJson.java
rename src/main/java/im/zhaojun/zfile/{common => core}/util/ClassUtils.java (93%)
create mode 100644 src/main/java/im/zhaojun/zfile/core/util/CodeMsg.java
rename src/main/java/im/zhaojun/zfile/{common => core}/util/EnumConvertUtils.java (98%)
rename src/main/java/im/zhaojun/zfile/{common => core}/util/FileComparator.java (90%)
rename src/main/java/im/zhaojun/zfile/{common => core}/util/FileResponseUtil.java (95%)
rename src/main/java/im/zhaojun/zfile/{common => core}/util/HttpUtil.java (80%)
rename src/main/java/im/zhaojun/zfile/{common => core}/util/NaturalOrderComparator.java (99%)
create mode 100644 src/main/java/im/zhaojun/zfile/core/util/PatternMatcherUtils.java
rename src/main/java/im/zhaojun/zfile/{common => core}/util/PlaceholderUtils.java (94%)
rename src/main/java/im/zhaojun/zfile/{common => core}/util/ProxyDownloadUrlUtils.java (71%)
rename src/main/java/im/zhaojun/zfile/{common => core}/util/RequestHolder.java (98%)
rename src/main/java/im/zhaojun/zfile/{common => core}/util/SizeToStrUtils.java (96%)
rename src/main/java/im/zhaojun/zfile/{common => core}/util/StringUtils.java (96%)
create mode 100644 src/main/java/im/zhaojun/zfile/core/util/UrlUtils.java
rename src/main/java/im/zhaojun/zfile/{common => core}/validation/StringListValue.java (94%)
rename src/main/java/im/zhaojun/zfile/{common => core}/validation/StringListValueConstraintValidator.java (95%)
delete mode 100644 src/main/java/im/zhaojun/zfile/home/aspect/FileListCacheAspect.java
delete mode 100644 src/main/java/im/zhaojun/zfile/home/controller/FileController.java
delete mode 100644 src/main/java/im/zhaojun/zfile/home/controller/SiteController.java
delete mode 100644 src/main/java/im/zhaojun/zfile/home/convert/StorageSourceConvert.java
delete mode 100644 src/main/java/im/zhaojun/zfile/home/model/dto/CacheInfoDTO.java
delete mode 100644 src/main/java/im/zhaojun/zfile/home/model/request/UserLoginRequest.java
delete mode 100644 src/main/java/im/zhaojun/zfile/home/service/base/RefreshTokenService.java
rename src/main/java/im/zhaojun/zfile/{admin => module/config}/constant/SystemConfigConstant.java (87%)
rename src/main/java/im/zhaojun/zfile/{home/install => module/config/controller}/InstallController.java (81%)
rename src/main/java/im/zhaojun/zfile/{admin/controller/setting => module/config/controller}/SettingController.java (87%)
create mode 100644 src/main/java/im/zhaojun/zfile/module/config/controller/SiteController.java
rename src/main/java/im/zhaojun/zfile/{admin => module/config}/mapper/SystemConfigMapper.java (88%)
rename src/main/java/im/zhaojun/zfile/{home => module/config}/model/dto/SystemConfigDTO.java (91%)
rename src/main/java/im/zhaojun/zfile/{admin => module/config}/model/entity/SystemConfig.java (93%)
rename src/main/java/im/zhaojun/zfile/{admin => module/config}/model/enums/FileClickModeEnum.java (90%)
rename src/main/java/im/zhaojun/zfile/{home => module/config}/model/request/InstallSystemRequest.java (92%)
rename src/main/java/im/zhaojun/zfile/{admin/model/request/setting => module/config/model/request}/UpdateLinkSettingRequest.java (81%)
rename src/main/java/im/zhaojun/zfile/{admin/model/request/setting => module/config/model/request}/UpdateSecuritySettingRequest.java (83%)
rename src/main/java/im/zhaojun/zfile/{admin/model/request/setting => module/config/model/request}/UpdateSiteSettingRequest.java (95%)
rename src/main/java/im/zhaojun/zfile/{admin/model/request/setting => module/config/model/request}/UpdateUserNameAndPasswordRequest.java (90%)
rename src/main/java/im/zhaojun/zfile/{admin/model/request/setting => module/config/model/request}/UpdateViewSettingRequest.java (94%)
create mode 100644 src/main/java/im/zhaojun/zfile/module/config/model/request/UpdateWebDAVRequest.java
rename src/main/java/im/zhaojun/zfile/{home => module/config}/model/result/SiteConfigResult.java (96%)
rename src/main/java/im/zhaojun/zfile/{admin => module/config}/service/SystemConfigService.java (66%)
rename src/main/java/im/zhaojun/zfile/{admin/controller/stroage => module/filter/controller}/StorageSourceFilterController.java (83%)
rename src/main/java/im/zhaojun/zfile/{admin => module/filter}/mapper/FilterConfigMapper.java (92%)
rename src/main/java/im/zhaojun/zfile/{admin => module/filter}/model/entity/FilterConfig.java (92%)
rename src/main/java/im/zhaojun/zfile/{admin => module/filter}/model/enums/FilterConfigHiddenModeEnum.java (91%)
create mode 100644 src/main/java/im/zhaojun/zfile/module/filter/service/FilterConfigService.java
rename src/main/java/im/zhaojun/zfile/{home => module/link}/aspect/RefererCheckAspect.java (90%)
rename src/main/java/im/zhaojun/zfile/{home => module/link}/controller/ShortLinkController.java (63%)
create mode 100644 src/main/java/im/zhaojun/zfile/module/link/controller/ShortLinkManagerController.java
rename src/main/java/im/zhaojun/zfile/{admin => module/link}/convert/ShortLinkConvert.java (68%)
rename src/main/java/im/zhaojun/zfile/{admin => module/link}/mapper/ShortLinkMapper.java (75%)
rename src/main/java/im/zhaojun/zfile/{admin => module/link}/model/entity/ShortLink.java (94%)
rename src/main/java/im/zhaojun/zfile/{admin => module/link}/model/enums/RefererTypeEnum.java (91%)
rename src/main/java/im/zhaojun/zfile/{admin/model/request/link => module/link/model/request}/BatchDeleteRequest.java (73%)
rename src/main/java/im/zhaojun/zfile/{home => module/link}/model/request/BatchGenerateLinkRequest.java (90%)
rename src/main/java/im/zhaojun/zfile/{admin/model/request/link => module/link/model/request}/QueryDownloadLogRequest.java (67%)
create mode 100644 src/main/java/im/zhaojun/zfile/module/link/model/request/QueryShortLinkLogRequest.java
rename src/main/java/im/zhaojun/zfile/{admin/model/result/link => module/link/model/request}/ShortLinkResult.java (86%)
rename src/main/java/im/zhaojun/zfile/{home => module/link}/model/request/ShortLinkSearchRequest.java (96%)
rename src/main/java/im/zhaojun/zfile/{home => module/link}/model/result/BatchGenerateLinkResponse.java (85%)
rename src/main/java/im/zhaojun/zfile/{admin => module/link}/service/ShortLinkService.java (58%)
create mode 100644 src/main/java/im/zhaojun/zfile/module/log/controller/DownloadLogManagerController.java
rename src/main/java/im/zhaojun/zfile/{admin => module/log}/convert/DownloadLogConvert.java (69%)
create mode 100644 src/main/java/im/zhaojun/zfile/module/log/mapper/DownloadLogMapper.java
create mode 100644 src/main/java/im/zhaojun/zfile/module/log/model/dto/DownloadTopFileDTO.java
create mode 100644 src/main/java/im/zhaojun/zfile/module/log/model/dto/DownloadTopIpDTO.java
create mode 100644 src/main/java/im/zhaojun/zfile/module/log/model/dto/DownloadTopRefererDTO.java
rename src/main/java/im/zhaojun/zfile/{admin => module/log}/model/entity/DownloadLog.java (95%)
rename src/main/java/im/zhaojun/zfile/{admin => module/log}/model/request/DownloadTopInfoRequest.java (88%)
rename src/main/java/im/zhaojun/zfile/{admin/model/result/link => module/log/model/result}/DownloadLogResult.java (76%)
create mode 100644 src/main/java/im/zhaojun/zfile/module/log/service/DownloadLogService.java
create mode 100644 src/main/java/im/zhaojun/zfile/module/login/controller/LoginController.java
rename src/main/java/im/zhaojun/zfile/{admin => module/login}/model/enums/LoginVerifyModeEnum.java (91%)
rename src/main/java/im/zhaojun/zfile/{admin/model/request/login/VerifyLogin2FARequest.java => module/login/model/request/VerifyLoginTwoFactorAuthenticatorRequest.java} (86%)
rename src/main/java/im/zhaojun/zfile/{admin/model/result/login/Login2FAResult.java => module/login/model/result/LoginTwoFactorAuthenticatorResult.java} (81%)
rename src/main/java/im/zhaojun/zfile/{admin/model/result/login => module/login/model/result}/LoginVerifyImgResult.java (90%)
create mode 100644 src/main/java/im/zhaojun/zfile/module/login/request/UserLoginRequest.java
rename src/main/java/im/zhaojun/zfile/{admin/service/login => module/login/service}/ImgVerifyCodeService.java (91%)
rename src/main/java/im/zhaojun/zfile/{admin/service/login/TwoFAVerifyService.java => module/login/service/TwoFactorAuthenticatorVerifyService.java} (68%)
rename src/main/java/im/zhaojun/zfile/{admin/controller/stroage => module/password/controller}/StorageSourcePasswordController.java (83%)
rename src/main/java/im/zhaojun/zfile/{admin => module/password}/mapper/PasswordConfigMapper.java (87%)
create mode 100644 src/main/java/im/zhaojun/zfile/module/password/model/dto/VerifyResultDTO.java
rename src/main/java/im/zhaojun/zfile/{admin => module/password}/model/entity/PasswordConfig.java (96%)
create mode 100644 src/main/java/im/zhaojun/zfile/module/password/service/PasswordConfigService.java
rename src/main/java/im/zhaojun/zfile/{admin/controller/stroage => module/readme/controller}/StorageSourceReadmeController.java (83%)
rename src/main/java/im/zhaojun/zfile/{admin => module/readme}/mapper/ReadmeConfigMapper.java (87%)
rename src/main/java/im/zhaojun/zfile/{admin => module/readme}/model/entity/ReadmeConfig.java (92%)
rename src/main/java/im/zhaojun/zfile/{admin => module/readme}/model/enums/ReadmeDisplayModeEnum.java (90%)
create mode 100644 src/main/java/im/zhaojun/zfile/module/readme/service/ReadmeConfigService.java
create mode 100644 src/main/java/im/zhaojun/zfile/module/storage/annotation/CheckPassword.java
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/annotation/RefererCheck.java (88%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/annotation/StorageParamItem.java (93%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/annotation/StorageParamSelect.java (71%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/annotation/StorageParamSelectOption.java (90%)
rename src/main/java/im/zhaojun/zfile/{admin/annotation/select => module/storage/annotation}/impl/EncodingStorageParamSelect.java (64%)
create mode 100644 src/main/java/im/zhaojun/zfile/module/storage/aspect/CheckPasswordAspect.java
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/aspect/FileOperatorCheckAspect.java (66%)
create mode 100644 src/main/java/im/zhaojun/zfile/module/storage/aspect/FileOperatorExceptionWrapperAspect.java
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/chain/FileChain.java (74%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/chain/FileContext.java (78%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/chain/command/FileAccessPermissionVerifyCommand.java (52%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/chain/command/FileHiddenCommand.java (63%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/chain/command/FileSortCommand.java (81%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/chain/command/FileUrlAddVersionCommand.java (86%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/chain/command/FolderPasswordVerifyCommand.java (63%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/constant/StorageConfigConstant.java (82%)
rename src/main/java/im/zhaojun/zfile/{common => module/storage}/context/StorageSourceContext.java (66%)
rename src/main/java/im/zhaojun/zfile/{admin/controller/stroage => module/storage/controller/base}/StorageMetaDataController.java (83%)
rename src/main/java/im/zhaojun/zfile/{admin/controller/stroage => module/storage/controller/base}/StorageSourceController.java (77%)
rename src/main/java/im/zhaojun/zfile/{common/controller/callback/GdCallbackController.java => module/storage/controller/callback/GoogleDriveCallbackController.java} (89%)
rename src/main/java/im/zhaojun/zfile/{common => module/storage}/controller/callback/OneDriveCallbackController.java (89%)
create mode 100644 src/main/java/im/zhaojun/zfile/module/storage/controller/file/FileController.java
rename src/main/java/im/zhaojun/zfile/{home/controller => module/storage/controller/file}/FileOperatorController.java (51%)
rename src/main/java/im/zhaojun/zfile/{home/controller => module/storage/controller/file}/FileParseController.java (57%)
rename src/main/java/im/zhaojun/zfile/{common/controller/gd/GDHelperController.java => module/storage/controller/helper/GoogleDriveHelperController.java} (71%)
rename src/main/java/im/zhaojun/zfile/{common/controller/s3 => module/storage/controller/helper}/S3HelperController.java (90%)
rename src/main/java/im/zhaojun/zfile/{common/controller/onedrive => module/storage/controller/helper}/SharePointHelperController.java (87%)
rename src/main/java/im/zhaojun/zfile/{common/controller/download => module/storage/controller/proxy}/ProxyDownloadController.java (78%)
rename src/main/java/im/zhaojun/zfile/{common/controller/upload => module/storage/controller/proxy}/ProxyUploadController.java (74%)
create mode 100644 src/main/java/im/zhaojun/zfile/module/storage/convert/StorageSourceConvert.java
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/filter/DownloadLinkFilter.java (77%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/mapper/StorageSourceConfigMapper.java (71%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/mapper/StorageSourceMapper.java (91%)
rename src/main/java/im/zhaojun/zfile/{home/model/upyun => module/storage/model/bo}/AuthModel.java (88%)
rename src/main/java/im/zhaojun/zfile/{common/cache/RefreshTokenCache.java => module/storage/model/bo/RefreshTokenCacheBO.java} (72%)
rename src/main/java/im/zhaojun/zfile/{admin/annotation/model => module/storage/model/bo}/StorageSourceParamDef.java (87%)
rename src/main/java/im/zhaojun/zfile/{home/model/upyun => module/storage/model/bo}/UploadSignParam.java (84%)
create mode 100644 src/main/java/im/zhaojun/zfile/module/storage/model/dto/FileOperatorTypeDefaultValueDTO.java
rename src/main/java/im/zhaojun/zfile/{admin/model/dto/OAuth2Token.java => module/storage/model/dto/OAuth2TokenDTO.java} (65%)
rename src/main/java/im/zhaojun/zfile/{home/model/dto/StorageSourceAllParam.java => module/storage/model/dto/StorageSourceAllParamDTO.java} (97%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/model/dto/StorageSourceDTO.java (91%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/model/entity/StorageSource.java (93%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/model/entity/StorageSourceConfig.java (90%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/model/enums/FileOperatorTypeEnum.java (91%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/model/enums/FileTypeEnum.java (89%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/model/enums/SearchModeEnum.java (89%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/model/enums/StorageParamTypeEnum.java (89%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/model/enums/StorageTypeEnum.java (97%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/model/param/AliyunParam.java (72%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/model/param/FtpParam.java (80%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/model/param/GoogleDriveParam.java (93%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/model/param/HuaweiParam.java (72%)
create mode 100644 src/main/java/im/zhaojun/zfile/module/storage/model/param/IStorageParam.java
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/model/param/LocalParam.java (79%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/model/param/MicrosoftDriveParam.java (92%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/model/param/MinIOParam.java (83%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/model/param/OneDriveChinaParam.java (87%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/model/param/OneDriveParam.java (73%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/model/param/ProxyDownloadParam.java (73%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/model/param/ProxyTransferParam.java (80%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/model/param/ProxyUploadParam.java (68%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/model/param/QiniuParam.java (72%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/model/param/S3BaseParam.java (79%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/model/param/S3Param.java (65%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/model/param/SftpParam.java (71%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/model/param/SharePointChinaParam.java (87%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/model/param/SharePointParam.java (84%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/model/param/TencentParam.java (66%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/model/param/UpYunParam.java (90%)
rename src/main/java/im/zhaojun/zfile/{admin => module/storage}/model/param/WebdavParam.java (77%)
rename src/main/java/im/zhaojun/zfile/{admin/model/request/gd/GetGdDriveListRequest.java => module/storage/model/request/GetGoogleDriveListRequest.java} (85%)
rename src/main/java/im/zhaojun/zfile/{admin/model/request/s3 => module/storage/model/request}/GetS3BucketListRequest.java (94%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/model/request/SharePointInfoRequest.java (95%)
rename src/main/java/im/zhaojun/zfile/{home/model/request/sharepoint => module/storage/model/request}/SharePointSearchSitesRequest.java (83%)
rename src/main/java/im/zhaojun/zfile/{home/model/request/sharepoint => module/storage/model/request}/SharePointSiteListsRequest.java (89%)
rename src/main/java/im/zhaojun/zfile/{home/model/request => module/storage/model/request/admin}/UpdateStorageIdRequest.java (91%)
rename src/main/java/im/zhaojun/zfile/{home/model/request => module/storage/model/request/admin}/UpdateStorageSortRequest.java (91%)
rename src/main/java/im/zhaojun/zfile/{home/model/request => module/storage/model/request/base}/FileItemRequest.java (90%)
rename src/main/java/im/zhaojun/zfile/{home/model/request => module/storage/model/request/base}/FileListConfigRequest.java (86%)
rename src/main/java/im/zhaojun/zfile/{home/model/request => module/storage/model/request/base}/FileListRequest.java (89%)
rename src/main/java/im/zhaojun/zfile/{admin/model/request => module/storage/model/request/base}/SaveStorageSourceRequest.java (88%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/model/request/operator/BatchDeleteRequest.java (83%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/model/request/operator/NewFolderRequest.java (75%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/model/request/operator/RenameFileRequest.java (77%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/model/request/operator/RenameFolderRequest.java (78%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/model/request/operator/UploadFileRequest.java (76%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/model/result/FileInfoResult.java (90%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/model/result/FileItemResult.java (66%)
rename src/main/java/im/zhaojun/zfile/{admin/model/result/gd/GdDriveInfoResult.java => module/storage/model/result/GoogleDriveInfoResult.java} (83%)
rename src/main/java/im/zhaojun/zfile/{admin/model/result/s3 => module/storage/model/result}/S3BucketNameResult.java (90%)
rename src/main/java/im/zhaojun/zfile/{admin/model/result/sharepoint/SharepointSiteList.java => module/storage/model/result/SharepointSiteListResult.java} (85%)
rename src/main/java/im/zhaojun/zfile/{admin/model/result/sharepoint/SharepointSite.java => module/storage/model/result/SharepointSiteResult.java} (82%)
rename src/main/java/im/zhaojun/zfile/{admin/model/result/storage => module/storage/model/result}/StorageSourceAdminResult.java (88%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/model/result/StorageSourceConfigResult.java (87%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/model/result/StorageSourceResult.java (88%)
rename src/main/java/im/zhaojun/zfile/{common => module/storage}/schedule/AccessTokenRefreshSchedule.java (73%)
create mode 100644 src/main/java/im/zhaojun/zfile/module/storage/service/StorageSourceConfigService.java
create mode 100644 src/main/java/im/zhaojun/zfile/module/storage/service/StorageSourceService.java
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/service/base/AbstractBaseFileService.java (83%)
rename src/main/java/im/zhaojun/zfile/{home/service/base/MicrosoftDriveServiceBase.java => module/storage/service/base/AbstractMicrosoftDriveService.java} (72%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/service/base/AbstractOneDriveServiceBase.java (71%)
rename src/main/java/im/zhaojun/zfile/{home/service/base/ProxyDownloadService.java => module/storage/service/base/AbstractProxyDownloadService.java} (50%)
rename src/main/java/im/zhaojun/zfile/{home/service/base/ProxyTransferService.java => module/storage/service/base/AbstractProxyTransferService.java} (77%)
rename src/main/java/im/zhaojun/zfile/{home/service/base/ProxyUploadService.java => module/storage/service/base/AbstractProxyUploadService.java} (57%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/service/base/AbstractS3BaseFileService.java (62%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/service/base/AbstractSharePointServiceBase.java (62%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/service/base/BaseFileService.java (66%)
create mode 100644 src/main/java/im/zhaojun/zfile/module/storage/service/base/RefreshTokenService.java
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/service/impl/AliyunServiceImpl.java (80%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/service/impl/FtpServiceImpl.java (74%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/service/impl/GoogleDriveServiceImpl.java (74%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/service/impl/HuaweiServiceImpl.java (81%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/service/impl/LocalServiceImpl.java (68%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/service/impl/MinIOServiceImpl.java (81%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/service/impl/OneDriveChinaServiceImpl.java (86%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/service/impl/OneDriveServiceImpl.java (86%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/service/impl/QiniuServiceImpl.java (83%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/service/impl/S3ServiceImpl.java (80%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/service/impl/SftpServiceImpl.java (82%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/service/impl/SharePointChinaServiceImpl.java (86%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/service/impl/SharePointServiceImpl.java (86%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/service/impl/TencentServiceImpl.java (81%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/service/impl/UpYunServiceImpl.java (77%)
rename src/main/java/im/zhaojun/zfile/{home => module/storage}/service/impl/WebdavServiceImpl.java (78%)
create mode 100644 src/main/resources/db/migration-mysql/V13__system_config_add_field_allow_path_link_anon_access.sql
create mode 100644 src/main/resources/db/migration-sqlite/V13__system_config_add_field_allow_path_link_anon_access.sql
diff --git a/README.md b/README.md
index 47a394c..34b7663 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,7 @@
-
-
-
-
+
+
+
基于 Java 的在线网盘程序,支持对接 S3、OneDrive、SharePoint、又拍云、本地存储、FTP、SFTP 等存储源,支持在线浏览图片、播放音视频,文本文件、Office、obj(3d)等文件类型。
diff --git a/src/main/java/im/zhaojun/zfile/ZfileApplication.java b/src/main/java/im/zhaojun/zfile/ZfileApplication.java
index 0f3cacf..40e7cac 100644
--- a/src/main/java/im/zhaojun/zfile/ZfileApplication.java
+++ b/src/main/java/im/zhaojun/zfile/ZfileApplication.java
@@ -6,16 +6,18 @@ import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
+
+/**
+ * @author zhaojun
+ */
@SpringBootApplication
@EnableAspectJAutoProxy(exposeProxy = true, proxyTargetClass = true)
-@ServletComponentScan(basePackages = "im.zhaojun.zfile.*.filter")
+@ServletComponentScan(basePackages = {"im.zhaojun.zfile.core.filter", "im.zhaojun.zfile.module.storage.filter"})
@ComponentScan(basePackages = "im.zhaojun.zfile.*")
public class ZfileApplication {
-
public static void main(String[] args) {
SpringApplication.run(ZfileApplication.class, args);
}
-
}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/admin/controller/CacheController.java b/src/main/java/im/zhaojun/zfile/admin/controller/CacheController.java
deleted file mode 100644
index a26311b..0000000
--- a/src/main/java/im/zhaojun/zfile/admin/controller/CacheController.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package im.zhaojun.zfile.admin.controller;
-
-import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
-import com.github.xiaoymin.knife4j.annotations.ApiSort;
-import im.zhaojun.zfile.home.model.dto.CacheInfoDTO;
-import im.zhaojun.zfile.admin.service.StorageSourceService;
-import im.zhaojun.zfile.common.util.AjaxJson;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-
-/**
- * 存储源缓存维护接口
- *
- * @author zhaojun
- */
-@RestController
-@Api(tags = "存储源模块-缓存")
-@ApiSort(5)
-@RequestMapping("/admin/cache")
-public class CacheController {
-
- @Resource
- private StorageSourceService storageSourceService;
-
- @ApiOperationSupport(order = 1)
- @ApiOperation(value = "启用存储源缓存", notes = "开启缓存后,N 秒内重复请求相同文件夹,不会重复调用 API。" +
- "参数 N 在配置文件中设置 {zfile.cache.timeout},默认为 1800 秒。")
- @ApiImplicitParam(paramType = "path", name = "storageId", value = "存储源 id", required = true)
- @PostMapping("/{storageId}/enable")
- public AjaxJson enableCache(@PathVariable("storageId") Integer storageId) {
- storageSourceService.updateCacheStatus(storageId, true);
- return AjaxJson.getSuccess();
- }
-
-
- @ApiOperationSupport(order = 2)
- @ApiOperation(value = "禁用存储源缓存")
- @ApiImplicitParam(paramType = "path", name = "storageId", value = "存储源 id", required = true)
- @PostMapping("/{storageId}/disable")
- public AjaxJson disableCache(@PathVariable("storageId") Integer storageId) {
- storageSourceService.updateCacheStatus(storageId, false);
- return AjaxJson.getSuccess();
- }
-
-
- @ApiOperationSupport(order = 3)
- @ApiOperation(value = "查看存储源缓存", notes = "可查看存储源缓存的所有目录路径")
- @ApiImplicitParam(paramType = "path", name = "storageId", value = "存储源 id", required = true)
- @GetMapping("/{storageId}/info")
- public AjaxJson cacheInfo(@PathVariable("storageId") Integer storageId) {
- CacheInfoDTO cacheInfo = storageSourceService.findCacheInfo(storageId);
- return AjaxJson.getSuccessData(cacheInfo);
- }
-
-
- @ApiOperationSupport(order = 4)
- @ApiOperation(value = "刷新存储源缓存", notes = "刷新存储源缓存路径,系统会重新预热此路径的内容")
- @ApiImplicitParams({
- @ApiImplicitParam(paramType = "path", name = "storageId", value = "存储源 id", required = true),
- @ApiImplicitParam(paramType = "body", name = "key", value = "缓存 key", required = true)
- })
- @PostMapping("/{storageId}/refresh")
- public AjaxJson refreshCache(@PathVariable("storageId") Integer storageId, String key) throws Exception {
- storageSourceService.refreshCache(storageId, key);
- return AjaxJson.getSuccess();
- }
-
-
- @ApiOperationSupport(order = 5)
- @ApiOperation(value = "开启缓存自动刷新", notes = "开启后每隔 N 秒检测到期的缓存, 对于过期缓存尝试调用 API, 重新写入缓存." +
- "参数 N 在配置文件中设置 {zfile.cache.auto-refresh-interval},默认为 5 秒。")
- @ApiImplicitParam(paramType = "path", name = "storageId", value = "存储源 id", required = true)
- @PostMapping("/{storageId}/auto-refresh/start")
- public AjaxJson enableAutoRefresh(@PathVariable("storageId") Integer storageId) {
- storageSourceService.startAutoCacheRefresh(storageId);
- return AjaxJson.getSuccess();
- }
-
-
- @ApiOperationSupport(order = 5)
- @ApiOperation(value = "关闭缓存自动刷新")
- @ApiImplicitParam(paramType = "path", name = "storageId", value = "存储源 id", required = true)
- @PostMapping("/{storageId}/auto-refresh/stop")
- public AjaxJson disableAutoRefresh(@PathVariable("storageId") Integer storageId) {
- storageSourceService.stopAutoCacheRefresh(storageId);
- return AjaxJson.getSuccess();
- }
-
-
- @ApiOperationSupport(order = 6)
- @ApiOperation(value = "清空缓存")
- @ApiImplicitParam(paramType = "path", name = "storageId", value = "存储源 id", required = true)
- @PostMapping("/{storageId}/clear")
- public AjaxJson clearCache(@PathVariable("storageId") Integer storageId) {
- storageSourceService.clearCache(storageId);
- return AjaxJson.getSuccess();
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/admin/controller/link/DownloadLogManagerController.java b/src/main/java/im/zhaojun/zfile/admin/controller/link/DownloadLogManagerController.java
deleted file mode 100644
index 7b068a0..0000000
--- a/src/main/java/im/zhaojun/zfile/admin/controller/link/DownloadLogManagerController.java
+++ /dev/null
@@ -1,150 +0,0 @@
-package im.zhaojun.zfile.admin.controller.link;
-
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.core.util.StrUtil;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.OrderItem;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
-import com.github.xiaoymin.knife4j.annotations.ApiSort;
-import im.zhaojun.zfile.admin.convert.DownloadLogConvert;
-import im.zhaojun.zfile.admin.model.entity.DownloadLog;
-import im.zhaojun.zfile.admin.model.entity.StorageSource;
-import im.zhaojun.zfile.admin.model.request.link.BatchDeleteRequest;
-import im.zhaojun.zfile.admin.model.request.link.QueryDownloadLogRequest;
-import im.zhaojun.zfile.admin.model.result.link.DownloadLogResult;
-import im.zhaojun.zfile.admin.service.DownloadLogService;
-import im.zhaojun.zfile.admin.service.StorageSourceService;
-import im.zhaojun.zfile.common.util.AjaxJson;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-import javax.annotation.Resource;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.stream.Stream;
-
-/**
- * 直链下载日志接口
- *
- * @author zhaojun
- */
-@Api(tags = "直链日志管理")
-@ApiSort(7)
-@Controller
-@RequestMapping("/admin/download/log")
-public class DownloadLogManagerController {
-
- @Resource
- private StorageSourceService storageSourceService;
-
- @Resource
- private DownloadLogConvert downloadLogConvert;
-
- @Resource
- private DownloadLogService downloadLogService;
-
- @ApiOperationSupport(order = 1)
- @GetMapping("/list")
- @ApiOperation(value = "直链下载日志")
- @ResponseBody
- @ApiImplicitParams({
- @ApiImplicitParam(paramType = "query", name = "key", value = "直链 key"),
- @ApiImplicitParam(paramType = "query", name = "page", value = "分页页数"),
- @ApiImplicitParam(paramType = "query", name = "limit", value = "每页条数"),
- @ApiImplicitParam(paramType = "query", name = "orderBy", defaultValue = "createDate", value = "排序字段"),
- @ApiImplicitParam(paramType = "query", name = "orderDirection", defaultValue = "desc", value = "排序顺序")
- })
- public AjaxJson> list(QueryDownloadLogRequest queryDownloadLogRequest,
- @RequestParam(required = false, defaultValue = "create_time") String orderBy,
- @RequestParam(required = false, defaultValue = "desc") String orderDirection) {
- Page pages = Page.of(queryDownloadLogRequest.getPage(), queryDownloadLogRequest.getLimit());
- boolean asc = Objects.equals(orderDirection, "asc");
- pages.addOrder(new OrderItem(orderBy, asc));
-
- DownloadLog downloadLog = new DownloadLog();
- QueryWrapper queryWrapper = new QueryWrapper<>(downloadLog);
-
- if (StrUtil.isNotEmpty(queryDownloadLogRequest.getStorageKey())) {
- queryWrapper.eq("storage_key", queryDownloadLogRequest.getStorageKey());
- }
- if (StrUtil.isNotEmpty(queryDownloadLogRequest.getPath())) {
- queryWrapper.like("path", queryDownloadLogRequest.getPath());
- }
- if (StrUtil.isNotEmpty(queryDownloadLogRequest.getShortKey())) {
- queryWrapper.like("short_key", queryDownloadLogRequest.getShortKey());
- }
- if (StrUtil.isNotEmpty(queryDownloadLogRequest.getIp())) {
- queryWrapper.like("ip", queryDownloadLogRequest.getIp());
- }
- if (StrUtil.isNotEmpty(queryDownloadLogRequest.getReferer())) {
- queryWrapper.like("referer", queryDownloadLogRequest.getReferer());
- }
- if (StrUtil.isNotEmpty(queryDownloadLogRequest.getUserAgent())) {
- queryWrapper.like("user_agent", queryDownloadLogRequest.getUserAgent());
- }
- if (ObjectUtil.isNotEmpty(queryDownloadLogRequest.getDateFrom())) {
- queryWrapper.ge("create_time", queryDownloadLogRequest.getDateFrom());
- }
- if (ObjectUtil.isNotEmpty(queryDownloadLogRequest.getDateTo())) {
- queryWrapper.le("create_time", queryDownloadLogRequest.getDateFrom());
- }
- Page selectResult = downloadLogService.page(pages, queryWrapper);
-
- long total = selectResult.getTotal();
- List records = selectResult.getRecords();
-
- Map cache = new HashMap<>();
-
- Stream shortLinkResultList = records.stream().map(model -> {
- String storageKey = model.getStorageKey();
- StorageSource storageSource;
- if (cache.containsKey(storageKey)) {
- storageSource = cache.get(storageKey);
- } else {
- storageSource = storageSourceService.findByStorageKey(storageKey);
- cache.put(storageKey, storageSource);
- }
- return downloadLogConvert.entityToResultList(model, storageSource);
- });
- return AjaxJson.getPageData(total, shortLinkResultList);
- }
-
-
- @ApiOperationSupport(order = 2)
- @DeleteMapping("/delete/{id}")
- @ApiOperation(value = "删除直链")
- @ApiImplicitParam(paramType = "path", name = "id", value = "直链 id", required = true)
- @ResponseBody
- public AjaxJson deleteById(@PathVariable Integer id) {
- downloadLogService.removeById(id);
- return AjaxJson.getSuccess();
- }
-
-
- @ApiOperationSupport(order = 3)
- @PostMapping("/delete/batch")
- @ResponseBody
- @ApiImplicitParam(paramType = "query", name = "ids", value = "直链 id", required = true)
- @ApiOperation(value = "批量删除直链")
- public AjaxJson batchDelete(@RequestBody BatchDeleteRequest batchDeleteRequest) {
- List ids = batchDeleteRequest.getIds();
- downloadLogService.removeBatchByIds(ids);
- return AjaxJson.getSuccess();
- }
-
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/admin/controller/link/ShortLinkManagerController.java b/src/main/java/im/zhaojun/zfile/admin/controller/link/ShortLinkManagerController.java
deleted file mode 100644
index 563d9d1..0000000
--- a/src/main/java/im/zhaojun/zfile/admin/controller/link/ShortLinkManagerController.java
+++ /dev/null
@@ -1,143 +0,0 @@
-package im.zhaojun.zfile.admin.controller.link;
-
-import cn.hutool.core.util.StrUtil;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.OrderItem;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
-import com.github.xiaoymin.knife4j.annotations.ApiSort;
-import im.zhaojun.zfile.admin.convert.ShortLinkConvert;
-import im.zhaojun.zfile.admin.model.entity.ShortLink;
-import im.zhaojun.zfile.admin.model.entity.StorageSource;
-import im.zhaojun.zfile.admin.model.request.link.BatchDeleteRequest;
-import im.zhaojun.zfile.admin.model.result.link.ShortLinkResult;
-import im.zhaojun.zfile.admin.service.ShortLinkService;
-import im.zhaojun.zfile.admin.service.StorageSourceService;
-import im.zhaojun.zfile.common.util.AjaxJson;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-import javax.annotation.Resource;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.stream.Stream;
-
-/**
- * 直链管理接口
- *
- * @author zhaojun
- */
-@Api(tags = "直链管理")
-@ApiSort(7)
-@Controller
-@RequestMapping("/admin")
-public class ShortLinkManagerController {
-
- @Resource
- private ShortLinkService shortLinkService;
-
- @Resource
- private StorageSourceService storageSourceService;
-
- @Resource
- private ShortLinkConvert shortLinkConvert;
-
- @ApiOperationSupport(order = 1)
- @GetMapping("/link/list")
- @ApiOperation(value = "搜索短链")
- @ResponseBody
- @ApiImplicitParams({
- @ApiImplicitParam(paramType = "query", name = "key", value = "短链 key"),
- @ApiImplicitParam(paramType = "query", name = "storageId", value = "存储源 ID"),
- @ApiImplicitParam(paramType = "query", name = "url", value = "短链 url"),
- @ApiImplicitParam(paramType = "query", name = "dateFrom", value = "短链创建时间从"),
- @ApiImplicitParam(paramType = "query", name = "dateTo", value = "短链创建时间至"),
- @ApiImplicitParam(paramType = "query", name = "page", value = "分页页数"),
- @ApiImplicitParam(paramType = "query", name = "limit", value = "每页条数"),
- @ApiImplicitParam(paramType = "query", name = "orderBy", defaultValue = "createDate", value = "排序字段"),
- @ApiImplicitParam(paramType = "query", name = "orderDirection", defaultValue = "desc", value = "排序顺序")
- })
- public AjaxJson> list(String key, String storageId,
- String url,
- String dateFrom,
- String dateTo,
- Integer page,
- Integer limit,
- @RequestParam(required = false, defaultValue = "create_date") String orderBy,
- @RequestParam(required = false, defaultValue = "desc") String orderDirection) {
- Page pages = Page.of(page, limit);
- boolean asc = Objects.equals(orderDirection, "asc");
- pages.addOrder(new OrderItem(orderBy, asc));
- QueryWrapper queryWrapper = new QueryWrapper<>(new ShortLink());
- if (StrUtil.isNotEmpty(storageId)) {
- queryWrapper.eq("storage_id", storageId);
- }
- if (StrUtil.isNotEmpty(key)) {
- queryWrapper.like("short_key", key);
- }
- if (StrUtil.isNotEmpty(url)) {
- queryWrapper.like("url", url);
- }
- if (StrUtil.isNotEmpty(dateFrom)) {
- queryWrapper.ge("create_date", dateFrom);
- }
- if (StrUtil.isNotEmpty(dateTo)) {
- queryWrapper.le("create_date", dateTo);
- }
- Page selectResult = shortLinkService.page(pages, queryWrapper);
-
- long total = selectResult.getTotal();
- List records = selectResult.getRecords();
-
- Map cache = new HashMap<>();
-
- Stream shortLinkResultList = records.stream().map(shortLink -> {
- Integer shortLinkStorageId = shortLink.getStorageId();
- StorageSource storageSource;
- if (cache.containsKey(shortLinkStorageId)) {
- storageSource = cache.get(shortLinkStorageId);
- } else {
- storageSource = storageSourceService.findById(shortLinkStorageId);
- cache.put(shortLinkStorageId, storageSource);
- }
- return shortLinkConvert.entityToResultList(shortLink, storageSource);
- });
- return AjaxJson.getPageData(total, shortLinkResultList);
- }
-
-
- @ApiOperationSupport(order = 2)
- @DeleteMapping("/link/delete/{id}")
- @ApiOperation(value = "删除短链")
- @ApiImplicitParam(paramType = "path", name = "id", value = "短链 id", required = true)
- @ResponseBody
- public AjaxJson deleteById(@PathVariable Integer id) {
- shortLinkService.removeById(id);
- return AjaxJson.getSuccess();
- }
-
-
- @ApiOperationSupport(order = 3)
- @PostMapping("/link/delete/batch")
- @ResponseBody
- @ApiImplicitParam(paramType = "query", name = "ids", value = "短链 id", required = true)
- @ApiOperation(value = "批量删除短链")
- public AjaxJson batchDelete(@RequestBody BatchDeleteRequest batchDeleteRequest) {
- shortLinkService.removeBatchByIds(batchDeleteRequest.getIds());
- return AjaxJson.getSuccess();
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/admin/controller/login/LoginController.java b/src/main/java/im/zhaojun/zfile/admin/controller/login/LoginController.java
deleted file mode 100644
index 8cc56e1..0000000
--- a/src/main/java/im/zhaojun/zfile/admin/controller/login/LoginController.java
+++ /dev/null
@@ -1 +0,0 @@
-package im.zhaojun.zfile.admin.controller.login;
import cn.dev33.satoken.stp.SaTokenInfo;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.crypto.SecureUtil;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.github.xiaoymin.knife4j.annotations.DynamicParameter;
import com.github.xiaoymin.knife4j.annotations.DynamicResponseParameters;
import dev.samstevens.totp.exceptions.QrGenerationException;
import im.zhaojun.zfile.admin.model.enums.LoginVerifyModeEnum;
import im.zhaojun.zfile.admin.model.request.login.VerifyLogin2FARequest;
import im.zhaojun.zfile.admin.model.result.login.Login2FAResult;
import im.zhaojun.zfile.admin.model.result.login.LoginVerifyImgResult;
import im.zhaojun.zfile.admin.service.SystemConfigService;
import im.zhaojun.zfile.admin.service.login.ImgVerifyCodeService;
import im.zhaojun.zfile.admin.service.login.TwoFAVerifyService;
import im.zhaojun.zfile.common.util.AjaxJson;
import im.zhaojun.zfile.home.model.dto.SystemConfigDTO;
import im.zhaojun.zfile.home.model.request.UserLoginRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Objects;
/**
* 登陆注销相关接口
*
* @author zhaojun
*/
@Api(tags = "登录模块")
@ApiSort(1)
@RestController
@RequestMapping("/admin")
public class LoginController {
@Resource
private SystemConfigService systemConfigService;
@Resource
private ImgVerifyCodeService imgVerifyCodeService;
@Resource
private TwoFAVerifyService twoFAVerifyService;
@ApiOperationSupport(order = 1, ignoreParameters = {"zfile-token"})
@ApiOperation(value = "登录")
@DynamicResponseParameters(properties = {
@DynamicParameter(name = "data", value = "登录成功后返回 token 值,后续请求需要在 header 或 cookie 中添加名为 zfile-token 的令牌", example = "629932e1-5103-4c33-85c0-dc89df108ef7", required = true),
@DynamicParameter(name = "code", value = "状态码,0 为正常,其他值表示登录失败,异常情况下见响应消息", dataTypeClass = Integer.class, example = "0"),
@DynamicParameter(name = "msg", value = "响应消息", example = "ok"),
})
@PostMapping("/login")
public AjaxJson> doLogin(@Valid @RequestBody UserLoginRequest userLoginRequest) {
SystemConfigDTO systemConfig = systemConfigService.getSystemConfig();
String verifyCode = userLoginRequest.getVerifyCode();
String verifyCodeUUID = userLoginRequest.getVerifyCodeUUID();
LoginVerifyModeEnum loginVerifyMode = systemConfig.getLoginVerifyMode();
String loginVerifySecret = systemConfig.getLoginVerifySecret();
if (Objects.equals(loginVerifyMode, LoginVerifyModeEnum.TWO_FACTOR_AUTHENTICATION_MODE)) {
twoFAVerifyService.checkCode(loginVerifySecret, verifyCode);
} else if (Objects.equals(loginVerifyMode, LoginVerifyModeEnum.IMG_VERIFY_MODE)) {
imgVerifyCodeService.checkCaptcha(verifyCodeUUID, verifyCode);
}
if (Objects.equals(systemConfig.getUsername(), userLoginRequest.getUsername()) &&
Objects.equals(systemConfig.getPassword(), SecureUtil.md5(userLoginRequest.getPassword()))) {
StpUtil.login("admin");
SaTokenInfo tokenInfo = StpUtil.getTokenInfo();
return AjaxJson.getSuccess("登录成功", tokenInfo.getTokenValue());
}
return AjaxJson.getError("登录失败, 账号或密码错误");
}
@ApiOperationSupport(order = 2)
@ApiOperation(value = "注销")
@PostMapping("/logout")
public AjaxJson> logout() {
StpUtil.logout();
return AjaxJson.getSuccess("注销成功");
}
@ApiOperationSupport(order = 3)
@ApiOperation(value = "生成 2FA")
@GetMapping("/2fa/setup")
public AjaxJson setupDevice() throws QrGenerationException {
Login2FAResult login2FAResult = twoFAVerifyService.setupDevice();
return AjaxJson.getSuccessData(login2FAResult);
}
@ApiOperationSupport(order = 4)
@ApiOperation(value = "2FA 验证并绑定")
@PostMapping("/2fa/verify")
public AjaxJson> deviceVerify(@Valid @RequestBody VerifyLogin2FARequest verifyLogin2FARequest) {
twoFAVerifyService.deviceVerify(verifyLogin2FARequest);
return AjaxJson.getSuccess();
}
@ApiOperationSupport(order = 5)
@ApiOperation(value = "获取登陆验证方式")
@GetMapping("/login/verify-mode")
public AjaxJson loginVerifyMode() {
SystemConfigDTO systemConfig = systemConfigService.getSystemConfig();
return AjaxJson.getSuccessData(systemConfig.getLoginVerifyMode());
}
@ApiOperationSupport(order = 6)
@ApiOperation(value = "获取图形验证码")
@GetMapping("/login/captcha")
public AjaxJson captcha() {
LoginVerifyImgResult loginVerifyImgResult = imgVerifyCodeService.generatorCaptcha();
return AjaxJson.getSuccessData(loginVerifyImgResult);
}
@ApiOperationSupport(order = 7)
@ApiOperation(value = "检测是否已登录")
@GetMapping("/login/check")
public AjaxJson checkLogin() {
return AjaxJson.getSuccessData(StpUtil.isLogin());
}
}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/admin/exception/ForbidFileOperationException.java b/src/main/java/im/zhaojun/zfile/admin/exception/ForbidFileOperationException.java
deleted file mode 100644
index 0190858..0000000
--- a/src/main/java/im/zhaojun/zfile/admin/exception/ForbidFileOperationException.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package im.zhaojun.zfile.admin.exception;
-
-import lombok.Getter;
-
-/**
- * 禁止的文件操作异常
- *
- * @author zhaojun
- */
-@Getter
-public class ForbidFileOperationException extends RuntimeException {
-
- private final Integer storageId;
-
- private final String action;
-
- public ForbidFileOperationException(Integer storageId, String action) {
- this.storageId = storageId;
- this.action = action;
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/admin/mapper/DownloadLogMapper.java b/src/main/java/im/zhaojun/zfile/admin/mapper/DownloadLogMapper.java
deleted file mode 100644
index b8083a8..0000000
--- a/src/main/java/im/zhaojun/zfile/admin/mapper/DownloadLogMapper.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package im.zhaojun.zfile.admin.mapper;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import im.zhaojun.zfile.admin.model.entity.DownloadLog;
-import org.apache.ibatis.annotations.Mapper;
-
-/**
- * 下载日志 Mapper 接口
- *
- * @author zhaojun
- */
-@Mapper
-public interface DownloadLogMapper extends BaseMapper {
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/admin/model/dto/StorageSourceCacheKey.java b/src/main/java/im/zhaojun/zfile/admin/model/dto/StorageSourceCacheKey.java
deleted file mode 100644
index 8f28c93..0000000
--- a/src/main/java/im/zhaojun/zfile/admin/model/dto/StorageSourceCacheKey.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package im.zhaojun.zfile.admin.model.dto;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-/**
- * 缓存对象,用户表示那个存储源的那个文件夹.
- *
- * @author zhaojun
- */
-@Data
-@AllArgsConstructor
-@NoArgsConstructor
-public class StorageSourceCacheKey {
-
- private Integer storageId;
-
- private String key;
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/admin/model/param/IStorageParam.java b/src/main/java/im/zhaojun/zfile/admin/model/param/IStorageParam.java
deleted file mode 100644
index 9fc2786..0000000
--- a/src/main/java/im/zhaojun/zfile/admin/model/param/IStorageParam.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package im.zhaojun.zfile.admin.model.param;
-
-
-public interface IStorageParam {
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/admin/model/verify/VerifyResult.java b/src/main/java/im/zhaojun/zfile/admin/model/verify/VerifyResult.java
deleted file mode 100644
index c64a215..0000000
--- a/src/main/java/im/zhaojun/zfile/admin/model/verify/VerifyResult.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package im.zhaojun.zfile.admin.model.verify;
-
-import lombok.Data;
-
-/**
- * 用于表示校验结果的类
- *
- * @author zhaojun
- */
-@Data
-public class VerifyResult {
-
- /**
- * 是否成功
- */
- private boolean passed;
-
- /**
- * 消息
- */
- private String msg;
-
- /**
- * 代码
- */
- private Integer code;
-
- /**
- * 表达式
- */
- private String pattern;
-
- public static VerifyResult success() {
- VerifyResult verifyResult = new VerifyResult();
- verifyResult.setPassed(true);
- return verifyResult;
- }
-
-
- public static VerifyResult success(String pattern) {
- VerifyResult verifyResult = new VerifyResult();
- verifyResult.setPassed(true);
- verifyResult.setPattern(pattern);
- return verifyResult;
- }
-
-
- public static VerifyResult fail(String msg, Integer code) {
- VerifyResult verifyResult = new VerifyResult();
- verifyResult.setPassed(false);
- verifyResult.setMsg(msg);
- verifyResult.setCode(code);
- return verifyResult;
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/admin/service/DownloadLogService.java b/src/main/java/im/zhaojun/zfile/admin/service/DownloadLogService.java
deleted file mode 100644
index da33f1b..0000000
--- a/src/main/java/im/zhaojun/zfile/admin/service/DownloadLogService.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package im.zhaojun.zfile.admin.service;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import im.zhaojun.zfile.admin.mapper.DownloadLogMapper;
-import im.zhaojun.zfile.admin.model.entity.DownloadLog;
-import org.springframework.stereotype.Service;
-
-/**
- * 下载日志 Service
- *
- * @author zhaojun
- */
-@Service
-public class DownloadLogService extends ServiceImpl {
-
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/admin/service/FilterConfigService.java b/src/main/java/im/zhaojun/zfile/admin/service/FilterConfigService.java
deleted file mode 100644
index cfeeb18..0000000
--- a/src/main/java/im/zhaojun/zfile/admin/service/FilterConfigService.java
+++ /dev/null
@@ -1,219 +0,0 @@
-package im.zhaojun.zfile.admin.service;
-
-import cn.hutool.core.io.FileUtil;
-import cn.hutool.core.util.StrUtil;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import im.zhaojun.zfile.admin.mapper.FilterConfigMapper;
-import im.zhaojun.zfile.admin.model.entity.FilterConfig;
-import im.zhaojun.zfile.common.exception.FileAccessException;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import javax.annotation.Resource;
-import java.nio.file.FileSystems;
-import java.nio.file.PathMatcher;
-import java.nio.file.Paths;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * 存储源过滤器 Service
- *
- * @author zhaojun
- */
-@Slf4j
-@Service
-public class FilterConfigService extends ServiceImpl {
-
- @Resource
- private FilterConfigMapper filterConfigMapper;
-
-
- /**
- * 存储源 ID -> 过滤器列表(全部)缓存.
- */
- private final Map> baseCache = new HashMap<>();
-
- /**
- * 存储源 ID -> 过滤器列表(禁止访问)缓存.
- */
- private final Map> inaccessibleCache = new HashMap<>();
-
- /**
- * 存储源 ID -> 过滤器列表(禁止下载)缓存.
- */
- private final Map> disableDownloadCache = new HashMap<>();
-
-
- /**
- * 根据存储源 ID 获取存储源配置列表
- *
- * @param storageId
- * 存储源 ID
- *
- * @return 存储源过滤器配置列表
- */
- public List findByStorageId(Integer storageId){
- if (baseCache.get(storageId) != null) {
- return baseCache.get(storageId);
- } else {
- List dbResult = filterConfigMapper.findByStorageId(storageId);
- baseCache.put(storageId, dbResult);
- return dbResult;
- }
- }
-
-
- /**
- * 批量保存存储源过滤器配置, 会先删除之前的所有配置(在事务中运行)
- *
- * @param storageId
- * 存储源 ID
- *
- * @param filterConfigList
- * 存储源过滤器配置列表
- */
- @Transactional(rollbackFor = Exception.class)
- public void batchSave(Integer storageId, List filterConfigList) {
- filterConfigMapper.deleteByStorageId(storageId);
- super.saveBatch(filterConfigList);
- baseCache.put(storageId, filterConfigList);
- }
-
-
- /**
- * 判断访问的路径是否是不允许访问的
- *
- * @param storageId
- * 存储源 ID
- *
- * @param path
- * 请求路径
- *
- * @throws FileAccessException 如果没权限访问此目录, 则抛出异常
- *
- */
- public void checkPathPermission(Integer storageId, String path) {
- List filterConfigList = findByStorageIdAndInaccessible(storageId);
- if (testPattern(filterConfigList, path)) {
- throw new FileAccessException("您没有权限访问该路径");
- }
-
- }
-
-
- /**
- * 获取所有类型为禁止访问的过滤规则
- *
- * @param storageId
- * 存储 ID
- *
- * @return 禁止访问的过滤规则列表
- */
- public List findByStorageIdAndInaccessible(Integer storageId){
- if (inaccessibleCache.get(storageId) != null) {
- return inaccessibleCache.get(storageId);
- } else {
- List dbResult = filterConfigMapper.findByStorageIdAndInaccessible(storageId);
- inaccessibleCache.put(storageId, dbResult);
- return dbResult;
- }
- }
-
-
- /**
- * 获取所有类型为禁止下载的过滤规则
- *
- * @param storageId
- * 存储 ID
- *
- * @return 禁止下载的过滤规则列表
- */
- public List findByStorageIdAndDisableDownload(Integer storageId){
- if (disableDownloadCache.get(storageId) != null) {
- return disableDownloadCache.get(storageId);
- } else {
- List dbResult = filterConfigMapper.findByStorageIdAndDisableDownload(storageId);
- disableDownloadCache.put(storageId, dbResult);
- return dbResult;
- }
- }
-
-
- /**
- * 指定存储源下的文件名称, 根据过滤表达式判断是否会显示, 如果符合任意一条表达式, 表示隐藏则返回 true, 反之表示不隐藏则返回 false.
- *
- * @param storageId
- * 存储源 ID
- *
- * @param fileName
- * 文件名
- *
- * @return 是否是隐藏文件夹
- */
- public boolean filterResultIsHidden(Integer storageId, String fileName) {
- List filterConfigList = findByStorageId(storageId);
- return testPattern(filterConfigList, fileName);
- }
-
-
- /**
- * 指定存储源下的文件名称, 根据过滤表达式判断文件名和所在路径是否禁止下载, 如果符合任意一条表达式, 则返回 true, 反之则返回 false.
- *
- * @param storageId
- * 存储源 ID
- *
- * @param fileName
- * 文件名
- *
- * @return 是否显示
- */
- public boolean filterResultIsDisableDownload(Integer storageId, String fileName) {
- List filterConfigList = findByStorageIdAndDisableDownload(storageId);
- String filePath = FileUtil.getParent(fileName, 1);
- if (StrUtil.isEmpty(filePath)) {
- return testPattern(filterConfigList, fileName);
- } else {
- return testPattern(filterConfigList, fileName) || testPattern(filterConfigList, filePath);
- }
- }
-
-
- /**
- * 根据规则表达式和测试字符串进行匹配,如测试字符串和其中一个规则匹配上,则返回 true,反之返回 false。
- *
- * @param patternList
- * 规则列表
- *
- * @param test
- *
- * 测试字符串
- *
- * @return 是否显示
- */
- private boolean testPattern(List patternList, String test) {
- for (FilterConfig filterConfig : patternList) {
- String expression = filterConfig.getExpression();
-
- if (StrUtil.isEmpty(expression)) {
- return false;
- }
-
- try {
- PathMatcher pathMatcher = FileSystems.getDefault().getPathMatcher("glob:" + expression);
- boolean match = pathMatcher.matches(Paths.get(test));
- if (match) {
- return true;
- }
- log.debug("regex: {}, name {}, contains: {}", expression, test, match);
- } catch (Exception e) {
- log.debug("regex: {}, name {}, parse error, skip expression", expression, test);
- }
- }
-
- return false;
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/admin/service/PasswordConfigService.java b/src/main/java/im/zhaojun/zfile/admin/service/PasswordConfigService.java
deleted file mode 100644
index b6a0d52..0000000
--- a/src/main/java/im/zhaojun/zfile/admin/service/PasswordConfigService.java
+++ /dev/null
@@ -1,159 +0,0 @@
-package im.zhaojun.zfile.admin.service;
-
-import cn.hutool.core.util.StrUtil;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import im.zhaojun.zfile.admin.mapper.PasswordConfigMapper;
-import im.zhaojun.zfile.admin.model.entity.PasswordConfig;
-import im.zhaojun.zfile.admin.model.verify.VerifyResult;
-import im.zhaojun.zfile.common.util.AjaxJson;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import javax.annotation.Resource;
-import java.nio.file.FileSystems;
-import java.nio.file.PathMatcher;
-import java.nio.file.Paths;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * 存储源密码配置 Service
- *
- * @author zhaojun
- */
-@Service
-@Slf4j
-public class PasswordConfigService extends ServiceImpl {
-
- @Resource
- private PasswordConfigMapper passwordConfigMapper;
-
-
- /**
- * 存储源 ID -> 密码规则列表(全部)缓存.
- */
- private final Map> baseCache = new HashMap<>();
-
-
- /**
- * 根据存储源 ID 查询密码规则列表
- *
- * @param storageId
- * 存储源 ID
- *
- * @return 密码规则列表
- */
- public List findByStorageId(Integer storageId) {
- if (baseCache.get(storageId) != null) {
- return baseCache.get(storageId);
- } else {
- List dbResult = passwordConfigMapper.findByStorageId(storageId);
- baseCache.put(storageId, dbResult);
- return dbResult;
- }
- }
-
-
- /**
- * 批量保存指定存储源 ID 的密码规则列表
- *
- * @param storageId
- * 存储源 ID
- *
- * @param passwordConfigList
- * 存储源类别
- */
- @Transactional(rollbackFor = Exception.class)
- public void batchSave(Integer storageId, List passwordConfigList) {
- passwordConfigMapper.deleteByStorageId(storageId);
- super.saveBatch(passwordConfigList);
- baseCache.put(storageId, passwordConfigList);
- }
-
-
- /**
- * 校验密码
- *
- * @param storageId
- * 存储源 ID
- *
- * @param path
- * 请求路径
- *
- * @param inputPassword
- * 用户输入的密码
- *
- * @return 是否校验通过
- */
- public VerifyResult verifyPassword(Integer storageId, String path, String inputPassword) {
- List passwordConfigList = findByStorageId(storageId);
-
- for (PasswordConfig passwordConfig : passwordConfigList) {
- String expression = passwordConfig.getExpression();
- if (StrUtil.isEmpty(expression)) {
- continue;
- }
-
- try {
- PathMatcher pathMatcher = FileSystems.getDefault()
- .getPathMatcher("glob:" + expression);
- // 判断当前请求路径是否和规则路径表达式匹配
- boolean match = pathMatcher.matches(Paths.get(path));
- // 如果匹配且输入了密码则校验
- if (match) {
- if (StrUtil.isEmpty(inputPassword)) {
- return VerifyResult.fail("此文件夹需要密码.", AjaxJson.REQUIRED_PASSWORD);
- }
-
- String expectedPassword = passwordConfig.getPassword();
- if (matchPassword(expectedPassword, inputPassword)) {
- log.debug("匹配文件夹密码 path: {}, expression: {}, 用户输入: {}, 匹配成功", path, expression, inputPassword);
- return VerifyResult.success(expression);
- }
- log.debug("匹配文件夹密码 path: {}, expression: {}, 用户输入: {}, 不匹配.", path, expression, inputPassword);
- return VerifyResult.fail("此文件夹密码错误.", AjaxJson.INVALID_PASSWORD);
- }
- } catch (Exception e) {
- log.warn("匹配文件夹密码 path: {}, expression: {}, 用户输入: {}, 解析错误, 跳过此规则.",
- path, expression, inputPassword, e);
- }
- }
-
- log.debug("校验文件夹密码 path: {}, 没有匹配的表达式, 不进行密码校验.", path);
- return VerifyResult.success();
- }
-
-
- /**
- * 校验两个密码是否相同, 忽略空白字符
- *
- * @param expectedPasswordContent
- * 预期密码
- *
- * @param password
- * 实际输入密码
- *
- * @return 是否匹配
- */
- private boolean matchPassword(String expectedPasswordContent, String password) {
- if (Objects.equals(expectedPasswordContent, password)) {
- return true;
- }
-
- if (expectedPasswordContent == null) {
- return false;
- }
-
- if (password == null) {
- return false;
- }
-
- expectedPasswordContent = expectedPasswordContent.replace("\n", "").trim();
- password = password.replace("\n", "").trim();
- return Objects.equals(expectedPasswordContent, password);
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/admin/service/ReadmeConfigService.java b/src/main/java/im/zhaojun/zfile/admin/service/ReadmeConfigService.java
deleted file mode 100644
index 1196134..0000000
--- a/src/main/java/im/zhaojun/zfile/admin/service/ReadmeConfigService.java
+++ /dev/null
@@ -1,114 +0,0 @@
-package im.zhaojun.zfile.admin.service;
-
-import cn.hutool.core.util.StrUtil;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import im.zhaojun.zfile.admin.mapper.ReadmeConfigMapper;
-import im.zhaojun.zfile.admin.model.entity.ReadmeConfig;
-import im.zhaojun.zfile.common.constant.ZFileConstant;
-import im.zhaojun.zfile.common.util.StringUtils;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import javax.annotation.Resource;
-import java.nio.file.FileSystems;
-import java.nio.file.PathMatcher;
-import java.nio.file.Paths;
-import java.util.List;
-
-/**
- * 存储源 readme 配置 Service
- *
- * @author zhaojun
- */
-@Slf4j
-@Service
-public class ReadmeConfigService extends ServiceImpl {
-
- @Resource
- private ReadmeConfigMapper readmeConfigMapper;
-
-
- /**
- * 根据存储源 ID 查询文档配置
- *
- * @param storageId
- * 存储源ID
- *
- * @return 存储源文档配置列表
- */
- public List findByStorageId(Integer storageId){
- return readmeConfigMapper.findByStorageId(storageId);
- }
-
-
- /**
- * 批量保存存储源 readme 配置, 会先删除之前的所有配置(在事务中运行)
- *
- * @param storageId
- * 存储源 ID
- *
- * @param filterConfigList
- * 存储源 readme 配置列表
- */
- @Transactional(rollbackFor = Exception.class)
- public void batchSave(Integer storageId, List filterConfigList) {
- readmeConfigMapper.deleteByStorageId(storageId);
- super.saveBatch(filterConfigList);
- }
-
-
-
- /**
- * 根据存储源指定路径下的 readme 配置
- *
- * @param storageId
- * 存储源ID
- *
- * @param path
- * 文件夹路径
- *
- * @return 存储源 readme 配置列表
- */
- public ReadmeConfig findReadmeByPath(Integer storageId, String path) {
- List readmeConfigList = readmeConfigMapper.findByStorageId(storageId);
- return getReadmeByTestPattern(readmeConfigList, path);
- }
-
-
- /**
- * 根据规则表达式和测试字符串进行匹配,如测试字符串和其中一个规则匹配上,则返回 true,反之返回 false。
- *
- * @param patternList
- * 规则列表
- *
- * @param test
- * 测试字符串
- *
- * @return 是否显示
- */
- private ReadmeConfig getReadmeByTestPattern(List patternList, String test) {
- test = StringUtils.concat(test, ZFileConstant.PATH_SEPARATOR);
-
- for (ReadmeConfig filterConfig : patternList) {
- String expression = filterConfig.getExpression();
- if (StrUtil.isEmpty(expression)) {
- continue;
- }
-
- try {
- PathMatcher pathMatcher = FileSystems.getDefault().getPathMatcher("glob:" + expression);
- boolean match = pathMatcher.matches(Paths.get(test));
- if (match) {
- return filterConfig;
- }
- log.debug("regex: {}, name {}, contains: {}", expression, test, match);
- } catch (Exception e) {
- log.debug("regex: {}, name {}, parse error, skip expression", expression, test);
- }
- }
-
- return null;
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/admin/service/StorageSourceConfigService.java b/src/main/java/im/zhaojun/zfile/admin/service/StorageSourceConfigService.java
deleted file mode 100644
index 497bc44..0000000
--- a/src/main/java/im/zhaojun/zfile/admin/service/StorageSourceConfigService.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package im.zhaojun.zfile.admin.service;
-
-import cn.hutool.core.collection.CollUtil;
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import im.zhaojun.zfile.admin.mapper.StorageSourceConfigMapper;
-import im.zhaojun.zfile.admin.model.entity.StorageSourceConfig;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * 存储源拓展配置 Service
- *
- * @author zhaojun
- */
-@Service
-@Slf4j
-public class StorageSourceConfigService extends ServiceImpl implements IService {
-
- @Resource
- private StorageSourceConfigMapper storageSourceConfigMapper;
-
- /**
- * 存储源 ID -> 存储源参数列表对象缓存
- */
- private final Map> sourceConfigConfigMapCache = new HashMap<>();
-
- /**
- * 根据存储源 ID 查询存储源拓展配置, 并按照存储源 id 排序
- *
- * @param storageId
- * 存储源 ID
- *
- * @return 存储源拓展配置列表
- */
- public List selectStorageConfigByStorageId(Integer storageId) {
- if (sourceConfigConfigMapCache.containsKey(storageId)) {
- return sourceConfigConfigMapCache.get(storageId);
- } else {
- List dbResult = storageSourceConfigMapper.findByStorageIdOrderById(storageId);
- sourceConfigConfigMapCache.put(storageId, dbResult);
- return dbResult;
- }
- }
-
-
- /**
- * 获取指定存储源的指定参数名称
- *
- * @param storageId
- * 存储源 id
- *
- * @param name
- * 参数名
- *
- * @return 参数信息
- */
- public StorageSourceConfig findByStorageIdAndName(Integer storageId, String name) {
- return storageSourceConfigMapper.findByStorageIdAndName(storageId, name);
- }
-
-
- /**
- * 批量更新存储源设置
- *
- * @param storageSourceConfigList
- * 存储源设置列表
- */
- @Transactional(rollbackFor = Exception.class)
- public void updateStorageConfig(List storageSourceConfigList) {
- super.updateBatchById(storageSourceConfigList);
- if (CollUtil.isNotEmpty(storageSourceConfigList)) {
- StorageSourceConfig first = CollUtil.getFirst(storageSourceConfigList);
- Integer storageId = first.getStorageId();
- sourceConfigConfigMapCache.remove(storageId);
- }
- }
-
-
- /**
- * 根据存储源 id 删除所有设置
- *
- * @param id
- * 存储源 ID
- */
- @Transactional(rollbackFor = Exception.class)
- public void deleteByStorageId(Integer id) {
- storageSourceConfigMapper.deleteByStorageId(id);
- sourceConfigConfigMapCache.remove(id);
- }
-
-
- /**
- * 批量保存
- *
- * @param entityList
- * 实体对象集合
- *
- * @return 是否保存成功
- */
- @Override
- public boolean saveBatch(Collection entityList) {
- if (CollUtil.isNotEmpty(entityList)) {
- StorageSourceConfig storageSourceConfig = CollUtil.getFirst(entityList);
- Integer storageId = storageSourceConfig.getStorageId();
- sourceConfigConfigMapCache.put(storageId, new ArrayList<>(entityList));
- }
- return saveBatch(entityList, DEFAULT_BATCH_SIZE);
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/admin/service/StorageSourceService.java b/src/main/java/im/zhaojun/zfile/admin/service/StorageSourceService.java
deleted file mode 100644
index f8ba017..0000000
--- a/src/main/java/im/zhaojun/zfile/admin/service/StorageSourceService.java
+++ /dev/null
@@ -1,503 +0,0 @@
-package im.zhaojun.zfile.admin.service;
-
-import cn.hutool.core.convert.Convert;
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.core.util.ReflectUtil;
-import cn.hutool.core.util.StrUtil;
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import im.zhaojun.zfile.admin.annotation.model.StorageSourceParamDef;
-import im.zhaojun.zfile.admin.mapper.StorageSourceMapper;
-import im.zhaojun.zfile.admin.model.entity.StorageSource;
-import im.zhaojun.zfile.admin.model.entity.StorageSourceConfig;
-import im.zhaojun.zfile.admin.model.param.IStorageParam;
-import im.zhaojun.zfile.admin.model.request.SaveStorageSourceRequest;
-import im.zhaojun.zfile.common.cache.ZFileCache;
-import im.zhaojun.zfile.common.context.StorageSourceContext;
-import im.zhaojun.zfile.common.exception.InitializeStorageSourceException;
-import im.zhaojun.zfile.common.exception.InvalidStorageSourceException;
-import im.zhaojun.zfile.home.model.dto.CacheInfoDTO;
-import im.zhaojun.zfile.home.model.dto.StorageSourceAllParam;
-import im.zhaojun.zfile.home.model.dto.StorageSourceDTO;
-import im.zhaojun.zfile.home.model.enums.StorageTypeEnum;
-import im.zhaojun.zfile.home.model.request.UpdateStorageSortRequest;
-import im.zhaojun.zfile.home.service.base.AbstractBaseFileService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.BeanUtils;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import javax.annotation.Resource;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-
-/**
- * 存储源基本信息 Service
- *
- * @author zhaojun
- */
-@Slf4j
-@Service
-public class StorageSourceService extends ServiceImpl implements IService {
-
- @Resource
- private StorageSourceMapper storageSourceMapper;
-
- @Resource
- private StorageSourceConfigService storageSourceConfigService;
-
- @Resource
- private StorageSourceContext storageSourceContext;
-
- @Resource
- private ZFileCache zFileCache;
-
- public static final Class STORAGE_SOURCE_ALL_PARAM_CLASS = StorageSourceAllParam.class;
-
-
- /**
- * 存储源 ID -> 存储源对象缓存
- */
- private final Map storageIdMapCache = new HashMap<>();
-
-
- /**
- * 存储源 KEY -> 存储源对象缓存
- */
- private final Map storageKeyMapCache = new HashMap<>();
-
-
- /**
- * 获取所有存储源列表
- *
- * @return 存储源列表
- */
- public List findAllOrderByOrderNum() {
- return storageSourceMapper.findAllOrderByOrderNum();
- }
-
-
- /**
- * 获取所有已启用的存储源列表,按照存储源的排序号排序
- *
- * @return 已启用的存储源列表
- */
- public List findListByEnableOrderByOrderNum() {
- return storageSourceMapper.findListByEnableOrderByOrderNum();
- }
-
-
- /**
- * 获取指定存储源设置
- *
- * @param id
- * 存储源 ID
- *
- * @return 存储源设置
- */
- public StorageSource findById(Integer id) {
- if (storageIdMapCache.get(id) != null) {
- return storageIdMapCache.get(id);
- } else {
- StorageSource dbResult = storageSourceMapper.selectById(id);
- storageIdMapCache.put(id, dbResult);
- return dbResult;
- }
- }
-
-
- /**
- * 获取指定存储源 DTO 对象, 此对象包含详细的参数设置.
- *
- * @param id
- * 存储源 ID
- *
- * @return 存储源 DTO
- */
- public StorageSourceDTO findStorageSourceDTOById(Integer id) {
- StorageSource storageSource = findById(id);
- Boolean defaultSwitchToImgMode = storageSource.getDefaultSwitchToImgMode();
- if (defaultSwitchToImgMode == null) {
- storageSource.setDefaultSwitchToImgMode(false);
- }
-
- StorageSourceDTO storageSourceDTO = new StorageSourceDTO();
- BeanUtils.copyProperties(storageSource, storageSourceDTO);
-
- List storageSourceConfigList = storageSourceConfigService.selectStorageConfigByStorageId(storageSource.getId());
-
- StorageSourceAllParam storageSourceAllParam = new StorageSourceAllParam();
- for (StorageSourceConfig storageSourceConfig : storageSourceConfigList) {
- String name = storageSourceConfig.getName();
- String value = storageSourceConfig.getValue();
-
- Field declaredField;
- try {
- declaredField = STORAGE_SOURCE_ALL_PARAM_CLASS.getDeclaredField(name);
- declaredField.setAccessible(true);
-
- Class> paramFieldType = declaredField.getType();
- Object convertToValue = Convert.convert(paramFieldType, value);
- declaredField.set(storageSourceAllParam, convertToValue);
- } catch (NoSuchFieldException | IllegalAccessException e) {
- log.error("通过反射, 将字段 {} 注入 StorageSourceDTO 时出现异常:", name, e);
- }
- }
-
- storageSourceDTO.setStorageSourceAllParam(storageSourceAllParam);
- return storageSourceDTO;
- }
-
-
- /**
- * 根据 id 获取指定存储源的类型.
- *
- * @param id
- * 存储源 ID
- *
- * @return 存储源对应的类型.
- */
- public StorageTypeEnum findStorageTypeById(Integer id) {
- return findById(id).getType();
- }
-
-
- /**
- * 保存存储源基本信息及其对应的参数设置
- *
- * @param saveStorageSourceRequest
- * 存储源 DTO 对象
- */
- @Transactional(rollbackFor = Exception.class)
- public void saveStorageSource(SaveStorageSourceRequest saveStorageSourceRequest) {
-
- // 判断是新增还是修改
- boolean updateFlag = saveStorageSourceRequest.getId() != null;
-
- // 保存基本信息
- StorageSource storageSource = new StorageSource();
- StorageTypeEnum storageType = saveStorageSourceRequest.getType();
- BeanUtils.copyProperties(saveStorageSourceRequest, storageSource);
-
- if (storageSource.getId() == null) {
- Integer nextId = selectNextId();
- storageSource.setId(nextId);
- }
-
-
- // 获取通过 id 缓存的对象
- StorageSource cacheStorageSource = storageIdMapCache.get(storageSource.getId());
- // 如果缓存的对象和当前的对象 key 不同, 则说明修改了 key, 需要移除 key 缓存, 并重新写入.
- if (ObjectUtil.isNotEmpty(cacheStorageSource) &&
- !StrUtil.equals(cacheStorageSource.getKey(), storageSource.getKey())) {
- storageKeyMapCache.remove(cacheStorageSource.getKey());
- }
-
- super.saveOrUpdate(storageSource);
-
- if (StrUtil.isEmpty(storageSource.getKey()) && !StrUtil.equals(storageSource.getId().toString(), storageSource.getKey())) {
- storageSource.setKey(Convert.toStr(storageSource.getId()));
- baseMapper.updateById(storageSource);
- }
- storageKeyMapCache.put(storageSource.getKey(), storageSource);
-
- StorageSourceAllParam storageSourceAllParam = saveStorageSourceRequest.getStorageSourceAllParam();
-
- // 获取该存储源类型需要的参数列表
- List storageSourceParamList = StorageSourceContext.getStorageSourceParamListByType(storageType);
-
- List storageSourceConfigList = new ArrayList<>();
- storageSourceConfigService.deleteByStorageId(saveStorageSourceRequest.getId());
-
- for (StorageSourceParamDef storageSourceParam : storageSourceParamList) {
- String paramKey = storageSourceParam.getKey();
- String paramName = storageSourceParam.getName();
-
- StorageSourceConfig storageSourceConfig = new StorageSourceConfig();
- storageSourceConfigList.add(storageSourceConfig);
-
- Object fieldValue = ReflectUtil.getFieldValue(storageSourceAllParam, paramKey);
- String fieldStrValue = Convert.toStr(fieldValue);
-
- boolean paramRequired = storageSourceParam.isRequired();
- String paramDefaultValue = storageSourceParam.getDefaultValue();
-
- // 如果是必填的, 并且值为空, 则抛出异常
- if (paramRequired && StrUtil.isEmpty(fieldStrValue)) {
- throw new InitializeStorageSourceException("存储源参数配置错误: [" + paramName + "] 不能为空");
- }
-
- // 如果默认值不为空, 且输入值为空, 则使用默认值
- if (StrUtil.isNotEmpty(paramDefaultValue) && StrUtil.isEmpty(fieldStrValue)) {
- fieldStrValue = paramDefaultValue;
- }
-
- storageSourceConfig.setTitle(paramName);
- storageSourceConfig.setName(paramKey);
- storageSourceConfig.setValue(fieldStrValue);
- storageSourceConfig.setType(storageType);
- storageSourceConfig.setStorageId(storageSource.getId());
- }
- storageSourceConfigService.saveBatch(storageSourceConfigList);
-
- storageSourceContext.init(storageSource.getId());
-
- AbstractBaseFileService driveService = storageSourceContext.get(storageSource.getId());
- if (driveService.getIsUnInitialized()) {
- throw new InitializeStorageSourceException("初始化异常, 请检查配置是否正确.");
- }
-
- if (storageSource.getAutoRefreshCache()) {
- startAutoCacheRefresh(storageSource.getId());
- } else if (updateFlag) {
- stopAutoCacheRefresh(storageSource.getId());
- }
-
- }
-
-
- /**
- * 查询存储源最大的 ID
- *
- * @return 存储源最大 ID
- */
- public synchronized Integer selectNextId() {
- Integer maxId = storageSourceMapper.selectMaxId();
- if (maxId == null) {
- return 1;
- } else {
- return maxId + 1;
- }
- }
-
-
-
- /**
- * 删除指定存储源设置, 会级联删除其参数设置
- *
- * @param id
- * 存储源 ID
- */
- @Transactional(rollbackFor = Exception.class)
- public void deleteById(Integer id) {
- if (log.isDebugEnabled()) {
- log.debug("尝试删除存储源, storageId: {}", id);
- }
- StorageSource storageSource = findById(id);
- storageSourceMapper.deleteById(id);
- storageSourceConfigService.deleteByStorageId(id);
- if (storageSource.getEnableCache()) {
- zFileCache.stopAutoCacheRefresh(id);
- zFileCache.clear(id);
- }
- String key = storageSource.getKey();
- storageIdMapCache.remove(id);
- storageKeyMapCache.remove(key);
- storageSourceContext.destroy(id);
- if (log.isDebugEnabled()) {
- log.debug("尝试删除存储源成功, 已清理相关数据, storageId: {}", id);
- }
- }
-
-
- /**
- * 更新指定存储源的缓存启用状态
- *
- * @param storageId
- * 存储源 ID
- *
- * @param cacheEnable
- * 是否启用缓存
- */
- public void updateCacheStatus(Integer storageId, Boolean cacheEnable) {
- StorageSource storageSource = findById(storageId);
- if (storageSource != null) {
- storageSource.setEnableCache(cacheEnable);
- super.saveOrUpdate(storageSource);
- storageIdMapCache.put(storageId, storageSource);
- }
- }
-
-
- /**
- * 获取指定存储源的缓存信息
- *
- * @param storageId
- * 存储源 ID
- *
- * @return 缓存信息
- */
- public CacheInfoDTO findCacheInfo(Integer storageId) {
- long hitCount = zFileCache.getHitCount(storageId);
- long missCount = zFileCache.getMissCount(storageId);
- Set keys = zFileCache.keySet(storageId);
- int cacheCount = keys.size();
- return new CacheInfoDTO(cacheCount, hitCount, missCount, keys);
- }
-
-
- /**
- * 刷新指定 key 的缓存:
- * 1. 清空此 key 的缓存.
- * 2. 重新调用方法写入缓存.
- *
- * @param storageId
- * 存储源 ID
- *
- * @param key
- * 缓存 key (文件夹名称)
- */
- public void refreshCache(Integer storageId, String key) throws Exception {
- if (log.isDebugEnabled()) {
- log.debug("手动刷新缓存 storageId: {}, key: {}", storageId, key);
- }
- zFileCache.remove(storageId, key);
- AbstractBaseFileService> baseFileService = storageSourceContext.get(storageId);
- baseFileService.fileList(key);
- }
-
-
- /**
- * 开启缓存自动刷新
- *
- * @param storageId
- * 存储源 ID
- */
- public void startAutoCacheRefresh(Integer storageId) {
- StorageSource storageSource = findById(storageId);
- storageSource.setAutoRefreshCache(true);
- super.saveOrUpdate(storageSource);
- storageIdMapCache.put(storageId, storageSource);
- zFileCache.startAutoCacheRefresh(storageId);
- }
-
-
- /**
- * 停止缓存自动刷新
- *
- * @param storageId
- * 存储源 ID
- */
- public void stopAutoCacheRefresh(Integer storageId) {
- StorageSource storageSource = findById(storageId);
- storageSource.setAutoRefreshCache(false);
- super.saveOrUpdate(storageSource);
- storageIdMapCache.put(storageId, storageSource);
- zFileCache.stopAutoCacheRefresh(storageId);
- }
-
-
- /**
- * 清理缓存
- *
- * @param storageId
- * 存储源 ID
- */
- public void clearCache(Integer storageId) {
- zFileCache.clear(storageId);
- }
-
-
- /**
- * 交换存储源排序
- *
- * @param updateStorageSortRequestList
- * 更新排序的存储源 id 及排序值列表
- */
- @Transactional(rollbackFor = Exception.class)
- public void updateStorageSort(List updateStorageSortRequestList) {
- for (int i = 0; i < updateStorageSortRequestList.size(); i++) {
- UpdateStorageSortRequest item = updateStorageSortRequestList.get(i);
- if (!Objects.equals(i, item.getOrderNum())) {
- storageSourceMapper.updateSetOrderNumById(i, item.getId());
- storageIdMapCache.clear();
- }
- }
- }
-
-
- /**
- * 根据存储源 key 获取存储源
- *
- * @param storageKey
- * 存储源 key
- *
- * @throws InvalidStorageSourceException 存储源不存在时, 抛出异常.
- *
- * @return 存储源信息
- */
- public StorageSource findByStorageKey(String storageKey) {
- if (storageKeyMapCache.containsKey(storageKey)) {
- return storageKeyMapCache.get(storageKey);
- } else {
- StorageSource storageSource = storageSourceMapper.findByStorageKey(storageKey);
- if (storageSource != null) {
- storageKeyMapCache.put(storageKey, storageSource);
- }
- return storageSource;
- }
-
-
- }
-
-
- /**
- * 判断存储源 key 是否已存在 (不读取缓存)
- *
- * @param storageKey
- * 存储源 key
- *
- * @return 是否已存在
- */
- public boolean existByStorageKey(String storageKey) {
- return storageSourceMapper.findIdByStorageKey(storageKey) != null;
- }
-
-
- /**
- * 根据存储源 id 获取存储源 key
- *
- * @param id
- * 存储源 id
- *
- * @return 存储源 key
- */
- public String findKeyById(Integer id){
- return findById(id).getKey();
- }
-
-
- /**
- * 根据存储源 key 获取存储源
- *
- * @param storageKey
- * 存储源 key
- *
- * @return 存储源信息
- */
- public Integer findIdByKey(String storageKey) {
- StorageSource storageSource = findByStorageKey(storageKey);
- if (storageSource == null) {
- return null;
- } else {
- return storageSource.getId();
- }
- }
-
-
- @Override
- public boolean updateById(StorageSource entity) {
- if (entity != null) {
- Integer id = entity.getId();
- storageIdMapCache.put(id, entity);
- storageKeyMapCache.put(entity.getKey(), entity);
- }
- return super.updateById(entity);
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/common/cache/MyTimedCache.java b/src/main/java/im/zhaojun/zfile/common/cache/MyTimedCache.java
deleted file mode 100644
index 95b3ba0..0000000
--- a/src/main/java/im/zhaojun/zfile/common/cache/MyTimedCache.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package im.zhaojun.zfile.common.cache;
-
-import cn.hutool.cache.impl.TimedCache;
-import cn.hutool.extra.spring.SpringUtil;
-import im.zhaojun.zfile.common.context.StorageSourceContext;
-import im.zhaojun.zfile.admin.model.dto.StorageSourceCacheKey;
-import im.zhaojun.zfile.home.service.base.AbstractBaseFileService;
-import lombok.extern.slf4j.Slf4j;
-
-/**
- * 自定义缓存类, 实现缓存超时后自动刷新
- *
- * @author zhaojun
- */
-@Slf4j
-public class MyTimedCache extends TimedCache {
-
- private StorageSourceContext storageSourceContext;
-
- public MyTimedCache(long timeout) {
- super(timeout);
- }
-
-
- /**
- * 当缓存超时后自动刷新
- *
- * @param key
- * 缓存 key
- *
- * @param cachedObject
- * 缓存值
- */
- @Override
- protected void onRemove(K key, V cachedObject) {
- if (storageSourceContext == null) {
- storageSourceContext = SpringUtil.getBean(StorageSourceContext.class);
- }
-
- StorageSourceCacheKey cacheKey = (StorageSourceCacheKey) key;
- AbstractBaseFileService> baseFileService = storageSourceContext.get(cacheKey.getStorageId());
-
- if (log.isDebugEnabled()) {
- log.debug("尝试刷新缓存: {}", cacheKey);
- }
-
- if (baseFileService == null) {
- log.error("尝试刷新缓存: {}, 时出现异常, 存储源已不存在", cacheKey);
- return;
- }
-
- try {
- baseFileService.fileList(cacheKey.getKey());
- } catch (Exception e) {
- log.error("尝试刷新缓存 {} 失败", cacheKey);
- e.printStackTrace();
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/common/cache/ZFileCache.java b/src/main/java/im/zhaojun/zfile/common/cache/ZFileCache.java
deleted file mode 100644
index 35e10c2..0000000
--- a/src/main/java/im/zhaojun/zfile/common/cache/ZFileCache.java
+++ /dev/null
@@ -1,257 +0,0 @@
-package im.zhaojun.zfile.common.cache;
-
-import cn.hutool.cache.impl.CacheObj;
-import im.zhaojun.zfile.admin.model.dto.StorageSourceCacheKey;
-import im.zhaojun.zfile.admin.model.entity.StorageSource;
-import im.zhaojun.zfile.admin.service.StorageSourceService;
-import im.zhaojun.zfile.common.context.StorageSourceContext;
-import im.zhaojun.zfile.home.model.dto.SystemConfigDTO;
-import im.zhaojun.zfile.home.model.result.FileItemResult;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * ZFile 缓存工具类
- *
- * @author zhaojun
- */
-@Service("zFileCache")
-@Slf4j
-public class ZFileCache {
-
- @Resource
- private StorageSourceService storageSourceService;
-
- @Resource
- private StorageSourceContext storageSourceContext;
-
- /**
- * 缓存过期时间
- */
- @Value("${zfile.cache.timeout}")
- private long timeout;
-
- /**
- * 缓存自动刷新间隔
- */
- @Value("${zfile.cache.auto-refresh.interval}")
- private long autoRefreshInterval;
-
- /**
- * 文件/文件对象缓存.
- *
- * ConcurrentMap>>
- * ConcurrentMap>
- *
- * storageId: 存储源 ID
- * key: 文件夹路径
- * value: 文件夹中内容
- */
- private final ConcurrentMap>> storageSourcesCache = new ConcurrentHashMap<>();
-
- /**
- * 系统设置缓存
- */
- private SystemConfigDTO systemConfigCache;
-
-
- /**
- * 写入缓存
- *
- * @param storageId
- * 存储源 ID
- *
- * @param key
- * 文件夹路径
- *
- * @param value
- * 文件夹中列表
- */
- public synchronized void put(Integer storageId, String key, List value) {
- getCacheByStorageId(storageId).put(new StorageSourceCacheKey(storageId, key), value);
- }
-
-
- /**
- * 获取指定存储源, 某个文件夹的名称
- *
- * @param storageId
- * 存储源 ID
- *
- * @param key
- * 文件夹路径
- *
- * @return 存储源中文件夹的内容
- */
- public List get(Integer storageId, String key) {
- return getCacheByStorageId(storageId).get(new StorageSourceCacheKey(storageId, key), false);
- }
-
-
- /**
- * 清空指定存储源的缓存.
- *
- * @param storageId
- * 存储源 ID
- */
- public void clear(Integer storageId) {
- if (log.isDebugEnabled()) {
- log.debug("清空存储源所有缓存, storageId: {}", storageId);
- }
- getCacheByStorageId(storageId).clear();
- }
-
-
-
- /**
- * 获取所有缓存 key (文件夹名称)
- *
- * @return 所有缓存 key
- */
- public Set keySet(Integer storageId) {
- Iterator>> cacheObjIterator = getCacheByStorageId(storageId).cacheObjIterator();
- Set keys = new HashSet<>();
- while (cacheObjIterator.hasNext()) {
- keys.add(cacheObjIterator.next().getKey().getKey());
- }
- return keys;
- }
-
-
- /**
- * 从缓存中删除指定存储源的某个路径的缓存
- *
- * @param storageId
- * 存储源 ID
- *
- * @param key
- * 文件夹路径
- */
- public void remove(Integer storageId, String key) {
- getCacheByStorageId(storageId).remove(new StorageSourceCacheKey(storageId, key));
- }
-
-
- /**
- * 更新缓存中的系统设置
- *
- * @param systemConfigCache
- * 系统设置
- */
- public void updateConfig(SystemConfigDTO systemConfigCache) {
- this.systemConfigCache = systemConfigCache;
- }
-
-
- /**
- * 从缓存中获取系统设置
- *
- * @return 系统设置
- */
- public SystemConfigDTO getConfig() {
- return this.systemConfigCache;
- }
-
-
- /**
- * 清空系统设置缓存
- */
- public void removeConfig() {
- this.systemConfigCache = null;
- }
-
-
- /**
- * 获取指定存储源对应的缓存
- *
- * @param storageId
- * 存储源 ID
- *
- * @return 存储源对应的缓存
- */
- private synchronized MyTimedCache> getCacheByStorageId(Integer storageId) {
- MyTimedCache> driveCache = storageSourcesCache.get(storageId);
- if (driveCache == null) {
- driveCache = new MyTimedCache<>(timeout * 1000);
- storageSourcesCache.put(storageId, driveCache);
- startAutoCacheRefresh(storageId);
- }
- return driveCache;
- }
-
-
- /**
- * 获取指定存储源的缓存命中数
- *
- * @param storageId
- * 存储源 ID
- *
- * @return 缓存命中数
- */
- public long getHitCount(Integer storageId) {
- return getCacheByStorageId(storageId).getHitCount();
- }
-
-
- /**
- * 获取指定存储源的缓存未命中数
- *
- * @param storageId
- * 存储源 ID
- *
- * @return 缓存未命中数
- */
- public long getMissCount(Integer storageId) {
- return getCacheByStorageId(storageId).getMissCount();
- }
-
-
- /**
- * 开启缓存自动刷新
- *
- * @param storageId
- * 存储源 ID
- */
- public void startAutoCacheRefresh(Integer storageId) {
- if (log.isDebugEnabled()) {
- log.debug("开启缓存自动刷新 storageId: {}", storageId);
- }
- StorageSource storageSource = storageSourceService.findById(storageId);
- Boolean autoRefreshCache = storageSource.getAutoRefreshCache();
- if (autoRefreshCache != null && autoRefreshCache) {
- MyTimedCache> driveCache = storageSourcesCache.get(storageId);
- if (driveCache == null) {
- driveCache = new MyTimedCache<>(timeout * 1000);
- storageSourcesCache.put(storageId, driveCache);
- }
- driveCache.schedulePrune(autoRefreshInterval * 1000);
- }
- }
-
-
- /**
- * 停止缓存自动刷新
- *
- * @param storageId
- * 存储源 ID
- */
- public void stopAutoCacheRefresh(Integer storageId) {
- if (log.isDebugEnabled()) {
- log.debug("停止缓存自动刷新 storageId: {}", storageId);
- }
- MyTimedCache> driveCache = storageSourcesCache.get(storageId);
- if (driveCache != null) {
- driveCache.cancelPruneSchedule();
- }
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/common/config/FlywayDbInitializer.java b/src/main/java/im/zhaojun/zfile/common/config/FlywayDbInitializer.java
deleted file mode 100644
index 75a106e..0000000
--- a/src/main/java/im/zhaojun/zfile/common/config/FlywayDbInitializer.java
+++ /dev/null
@@ -1 +0,0 @@
-package im.zhaojun.zfile.common.config;
import cn.hutool.core.util.StrUtil;
import org.flywaydb.core.Flyway;
import org.springframework.context.annotation.Configuration;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.Locale;
/**
* 数据库初始化
*
* @author zhaojun
*/
@Configuration
public class FlywayDbInitializer {
public static final String[] SUPPORT_DB_TYPE = new String[]{"mysql", "sqlite"};
@Resource
private DataSource dataSource;
/**
* 启动时根据当前数据库类型执行数据库初始化
*/
@PostConstruct
public void migrateFlyway() {
try {
String databaseProductName = dataSource.getConnection().getMetaData().getDatabaseProductName();
String dbType = databaseProductName.toLowerCase(Locale.ROOT);
// 检查当前数据库类型是否支持
if (!StrUtil.equalsAnyIgnoreCase(dbType, SUPPORT_DB_TYPE)) {
throw new RuntimeException("不支持的数据库类型 [" + dbType + "]");
}
Flyway load = Flyway.configure().dataSource(dataSource).outOfOrder(true).locations("db/migration-" + dbType).load();
load.migrate();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/common/config/Knife4jConfiguration.java b/src/main/java/im/zhaojun/zfile/common/config/Knife4jConfiguration.java
deleted file mode 100644
index 1997c4d..0000000
--- a/src/main/java/im/zhaojun/zfile/common/config/Knife4jConfiguration.java
+++ /dev/null
@@ -1 +0,0 @@
-package im.zhaojun.zfile.common.config;
import com.github.xiaoymin.knife4j.spring.extension.OpenApiExtensionResolver;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.builders.RequestParameterBuilder;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.RequestParameter;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.ArrayList;
import java.util.List;
/**
* @author zhaojun
*/
@Configuration
@EnableSwagger2
public class Knife4jConfiguration {
private final OpenApiExtensionResolver openApiExtensionResolver;
@Autowired
public Knife4jConfiguration(OpenApiExtensionResolver openApiExtensionResolver) {
this.openApiExtensionResolver = openApiExtensionResolver;
}
/**
* onedrive api docket
*
* @return docket
*/
@Bean(value = "onedriveApi")
public Docket onedriveApi() {
String groupName = "OneDrive 相关";
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("im.zhaojun.zfile.common.controller.onedrive"))
.paths(PathSelectors.regex("/onedrive/.*|/sharepoint/.*"))
.build()
.groupName(groupName)
.extensions(openApiExtensionResolver.buildExtensions(groupName));
}
/**
* admin api docket
*
* @return docket
*/
@Bean(value = "adminApi")
public Docket adminApi() {
String groupName = "管理员功能";
return new Docket(DocumentationType.SWAGGER_2)
.globalRequestParameters(generateRequestParameters())
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("im.zhaojun.zfile.controller.admin"))
.paths(PathSelectors.ant("/admin/**"))
.build()
.groupName(groupName)
.extensions(openApiExtensionResolver.buildExtensions(groupName));
}
/**
* home api docket
*
* @return docket
*/
@Bean(value = "homeApi")
public Docket homeApi() {
String groupName = "用户功能";
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("im.zhaojun.zfile.controller.home"))
.paths(PathSelectors.any())
.build()
.groupName(groupName)
.extensions(openApiExtensionResolver.buildExtensions(groupName));
}
/**
* install api info
*
* @return api info
*/
@Bean(value = "installApi")
public Docket installApi() {
String groupName = "初始化功能";
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("im.zhaojun.zfile.home.install"))
.paths(PathSelectors.any())
.build()
.groupName(groupName)
.extensions(openApiExtensionResolver.buildExtensions(groupName));
}
/**
* 获取通用的全局参数
*
* @return 全局参数列表
*/
private List generateRequestParameters(){
RequestParameterBuilder token = new RequestParameterBuilder();
List parameters = new ArrayList<>();
token.name("zfile-token").description("token").in(In.HEADER.toValue()).required(true).build();
parameters.add(token.build());
return parameters;
}
/**
* api 基本信息描述
*
* @return ApiInfo
*/
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("ZFILE 文档")
.description("# 这是 ZFILE Restful 接口文档展示页面")
.termsOfServiceUrl("https://www.zfile.vip")
.contact(new Contact("zhaojun", "https://zfile.vip", "admin@zfile.vip"))
.version("1.0")
.build();
}
}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/common/config/MybatisEnumTypeHandler.java b/src/main/java/im/zhaojun/zfile/common/config/MybatisEnumTypeHandler.java
deleted file mode 100644
index 7547a5b..0000000
--- a/src/main/java/im/zhaojun/zfile/common/config/MybatisEnumTypeHandler.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package im.zhaojun.zfile.common.config;
-
-import com.baomidou.mybatisplus.annotation.EnumValue;
-import com.baomidou.mybatisplus.annotation.IEnum;
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
-import com.baomidou.mybatisplus.core.toolkit.ExceptionUtils;
-import com.baomidou.mybatisplus.core.toolkit.ReflectionKit;
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
-import org.apache.ibatis.reflection.DefaultReflectorFactory;
-import org.apache.ibatis.reflection.MetaClass;
-import org.apache.ibatis.reflection.ReflectorFactory;
-import org.apache.ibatis.reflection.invoker.Invoker;
-import org.apache.ibatis.type.BaseTypeHandler;
-import org.apache.ibatis.type.JdbcType;
-
-import java.lang.reflect.Field;
-import java.math.BigDecimal;
-import java.sql.CallableStatement;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * 自定义枚举属性转换器
- *
- * @author hubin
- * @since 2017-10-11
- */
-public class MybatisEnumTypeHandler> extends BaseTypeHandler {
-
- private static final Map TABLE_METHOD_OF_ENUM_TYPES = new ConcurrentHashMap<>();
- private static final ReflectorFactory REFLECTOR_FACTORY = new DefaultReflectorFactory();
- private final Class enumClassType;
- private final Class> propertyType;
- private final Invoker getInvoker;
-
- public MybatisEnumTypeHandler(Class enumClassType) {
- if (enumClassType == null) {
- throw new IllegalArgumentException("Type argument cannot be null");
- }
- this.enumClassType = enumClassType;
- MetaClass metaClass = MetaClass.forClass(enumClassType, REFLECTOR_FACTORY);
- String name = "value";
- if (!IEnum.class.isAssignableFrom(enumClassType)) {
- name = findEnumValueFieldName(this.enumClassType).orElseThrow(() -> new IllegalArgumentException(String.format("Could not find @EnumValue in Class: %s.", this.enumClassType.getName())));
- }
- this.propertyType = ReflectionKit.resolvePrimitiveIfNecessary(metaClass.getGetterType(name));
- this.getInvoker = metaClass.getGetInvoker(name);
- }
-
- /**
- * 查找标记标记EnumValue字段
- *
- * @param clazz class
- * @return EnumValue字段
- * @since 3.3.1
- */
- public static Optional findEnumValueFieldName(Class> clazz) {
- if (clazz != null && clazz.isEnum()) {
- String className = clazz.getName();
- return Optional.ofNullable(CollectionUtils.computeIfAbsent(TABLE_METHOD_OF_ENUM_TYPES, className, key -> {
- Optional fieldOptional = findEnumValueAnnotationField(clazz);
- return fieldOptional.map(Field::getName).orElse(null);
- }));
- }
- return Optional.empty();
- }
-
- private static Optional findEnumValueAnnotationField(Class> clazz) {
- return Arrays.stream(clazz.getDeclaredFields()).filter(field -> field.isAnnotationPresent(EnumValue.class)).findFirst();
- }
-
- /**
- * 判断是否为MP枚举处理
- *
- * @param clazz class
- * @return 是否为MP枚举处理
- * @since 3.3.1
- */
- public static boolean isMpEnums(Class> clazz) {
- return clazz != null && clazz.isEnum() && (IEnum.class.isAssignableFrom(clazz) || findEnumValueFieldName(clazz).isPresent());
- }
-
- @SuppressWarnings("Duplicates")
- @Override
- public void setNonNullParameter(PreparedStatement ps, int i, E parameter, JdbcType jdbcType)
- throws SQLException {
- if (jdbcType == null) {
- ps.setObject(i, this.getValue(parameter));
- } else {
- // see r3589
- ps.setObject(i, this.getValue(parameter), jdbcType.TYPE_CODE);
- }
- }
-
- @Override
- public E getNullableResult(ResultSet rs, String columnName) throws SQLException {
- Object value = rs.getObject(columnName);
- if (null == value && rs.wasNull()) {
- return null;
- }
- return this.valueOf(value);
- }
-
- @Override
- public E getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
- Object value = rs.getObject(columnIndex, this.propertyType);
- if (null == value && rs.wasNull()) {
- return null;
- }
- return this.valueOf(value);
- }
-
- @Override
- public E getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
- Object value = cs.getObject(columnIndex, this.propertyType);
- if (null == value && cs.wasNull()) {
- return null;
- }
- return this.valueOf(value);
- }
-
- private E valueOf(Object value) {
- E[] es = this.enumClassType.getEnumConstants();
- return Arrays.stream(es).filter((e) -> equalsValue(value, getValue(e))).findAny().orElse(null);
- }
-
- /**
- * 值比较
- *
- * @param sourceValue 数据库字段值
- * @param targetValue 当前枚举属性值
- * @return 是否匹配
- * @since 3.3.0
- */
- protected boolean equalsValue(Object sourceValue, Object targetValue) {
- String sValue = StringUtils.toStringTrim(sourceValue);
- String tValue = StringUtils.toStringTrim(targetValue);
- if (sourceValue instanceof Number && targetValue instanceof Number
- && new BigDecimal(sValue).compareTo(new BigDecimal(tValue)) == 0) {
- return true;
- }
- return Objects.equals(sValue, tValue);
- }
-
- private Object getValue(Object object) {
- try {
- return this.getInvoker.invoke(object, new Object[0]);
- } catch (ReflectiveOperationException e) {
- throw ExceptionUtils.mpe(e);
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/common/config/SaTokenConfigure.java b/src/main/java/im/zhaojun/zfile/common/config/SaTokenConfigure.java
deleted file mode 100644
index 2d61aeb..0000000
--- a/src/main/java/im/zhaojun/zfile/common/config/SaTokenConfigure.java
+++ /dev/null
@@ -1 +0,0 @@
-package im.zhaojun.zfile.common.config;
import cn.dev33.satoken.interceptor.SaRouteInterceptor;
import cn.dev33.satoken.router.SaRouter;
import cn.dev33.satoken.stp.StpUtil;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* SaToken 权限配置, 配置管理员才能访问管理员功能.
*
* @author zhaojun
*/
@Configuration
public class SaTokenConfigure implements WebMvcConfigurer {
/**
* 注册权限校验拦截器, 拦截所有 /admin/** 请求, 但登陆相关的接口不需要认证.
* @param registry
* 拦截器注册器
*/
@Override
public void addInterceptors(InterceptorRegistry registry) {
// 注册路由拦截器,自定义验证规则
registry.addInterceptor(new SaRouteInterceptor((req, res, handler) -> {
// 根据路由划分模块,不同模块不同鉴权
SaRouter.match("/admin/**", StpUtil::checkLogin);
// 忽略所有登陆相关接口
})).addPathPatterns("/**").excludePathPatterns("/admin/login", "/admin/login/**", "/admin");
}
}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/common/exception/DisableProxyDownloadException.java b/src/main/java/im/zhaojun/zfile/common/exception/DisableProxyDownloadException.java
deleted file mode 100644
index b537702..0000000
--- a/src/main/java/im/zhaojun/zfile/common/exception/DisableProxyDownloadException.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package im.zhaojun.zfile.common.exception;
-
-/**
- * 禁止服务器代理下载异常
- *
- * @author zhaojun
- */
-public class DisableProxyDownloadException extends RuntimeException {
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/common/exception/FileAccessException.java b/src/main/java/im/zhaojun/zfile/common/exception/FileAccessException.java
deleted file mode 100644
index 928fa23..0000000
--- a/src/main/java/im/zhaojun/zfile/common/exception/FileAccessException.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package im.zhaojun.zfile.common.exception;
-
-/**
- * 文件权限异常
- *
- * @author zhaojun
- */
-public class FileAccessException extends RuntimeException {
-
- private static final long serialVersionUID = 1L;
-
- public FileAccessException() {
- }
-
- public FileAccessException(String message) {
- super(message);
- }
-
- public FileAccessException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public FileAccessException(Throwable cause) {
- super(cause);
- }
-
- public FileAccessException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
- super(message, cause, enableSuppression, writableStackTrace);
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/common/exception/FileUploadException.java b/src/main/java/im/zhaojun/zfile/common/exception/FileUploadException.java
deleted file mode 100644
index 5323598..0000000
--- a/src/main/java/im/zhaojun/zfile/common/exception/FileUploadException.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package im.zhaojun.zfile.common.exception;
-
-import im.zhaojun.zfile.home.model.enums.StorageTypeEnum;
-import lombok.Getter;
-
-/**
- * 文件上传异常
- *
- * @author zhaojun
- */
-@Getter
-public class FileUploadException extends RuntimeException {
-
- private final StorageTypeEnum storageTypeEnum;
-
- private final Integer storageId;
-
- private final String path;
-
- public FileUploadException(StorageTypeEnum storageTypeEnum, Integer storageId, String path, Throwable cause) {
- super(cause);
- this.storageTypeEnum = storageTypeEnum;
- this.path = path;
- this.storageId = storageId;
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/common/exception/GlobalException.java b/src/main/java/im/zhaojun/zfile/common/exception/GlobalException.java
deleted file mode 100644
index 1cb5f1c..0000000
--- a/src/main/java/im/zhaojun/zfile/common/exception/GlobalException.java
+++ /dev/null
@@ -1 +0,0 @@
-package im.zhaojun.zfile.common.exception;
import cn.dev33.satoken.exception.NotLoginException;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import im.zhaojun.zfile.admin.exception.ForbidFileOperationException;
import im.zhaojun.zfile.admin.exception.StorageSourceAutoConfigCorsException;
import im.zhaojun.zfile.admin.service.SystemConfigService;
import im.zhaojun.zfile.common.exception.file.operator.GetFileInfoException;
import im.zhaojun.zfile.common.exception.file.operator.ProxyDownloadFileException;
import im.zhaojun.zfile.common.util.AjaxJson;
import im.zhaojun.zfile.common.util.RequestHolder;
import im.zhaojun.zfile.common.util.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.catalina.connector.ClientAbortException;
import org.springframework.http.HttpStatus;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.validation.BindException;
import org.springframework.validation.BindingResult;
import org.springframework.web.HttpMediaTypeNotAcceptableException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
* 全局异常处理
*
* @author zhaojun
*/
@ControllerAdvice
@Slf4j
public class GlobalException {
@Resource
private SystemConfigService systemConfigService;
@ExceptionHandler({IllegalDownloadLinkException.class})
@ResponseBody
@ResponseStatus(HttpStatus.FORBIDDEN)
public AjaxJson getFileInfoException(IllegalDownloadLinkException e) {
return AjaxJson.getError(e.getMessage());
}
@ExceptionHandler({GetFileInfoException.class})
@ResponseBody
@ResponseStatus(HttpStatus.BAD_REQUEST)
public AjaxJson getFileInfoException(GetFileInfoException e) {
log.error("获取文件信息异常 {}. 存储源 ID: {}, 文件路径: {}", e.getMessage(), e.getStorageId(), e.getPathAndName());
return AjaxJson.getError("获取文件信息异常, 请联系管理员");
}
@ExceptionHandler({ProxyDownloadFileException.class})
@ResponseBody
@ResponseStatus(HttpStatus.BAD_REQUEST)
public AjaxJson proxyDownloadFileException(ProxyDownloadFileException e) {
log.error("代理下载文件异常 {}. 存储源 ID: {}, 下载路径: {}", e.getMessage(), e.getStorageId(), e.getPathAndName());
return AjaxJson.getError("下载文件异常, 请联系管理员!");
}
@ExceptionHandler({LoginVerifyException.class})
@ResponseBody
@ResponseStatus(HttpStatus.FORBIDDEN)
public AjaxJson loginVerifyException(LoginVerifyException e) {
return AjaxJson.getError(e.getMessage());
}
@ExceptionHandler({StorageSourceNotSupportProxyUploadException.class})
@ResponseBody
@ResponseStatus(HttpStatus.BAD_REQUEST)
public AjaxJson storageSourceNotSupportProxyUploadException(StorageSourceNotSupportProxyUploadException e) {
return AjaxJson.getError("非法操作, 当前存储源不支持此方式上传.");
}
@ExceptionHandler({DisableProxyDownloadException.class})
@ResponseBody
@ResponseStatus(HttpStatus.BAD_REQUEST)
public AjaxJson disableProxyDownloadException(DisableProxyDownloadException e) {
return AjaxJson.getError("非法操作, 当前文件不支持此类下载方式.");
}
@ExceptionHandler({UnsupportedOperationException.class})
@ResponseBody
@ResponseStatus(HttpStatus.BAD_REQUEST)
public AjaxJson handleFileUploadException(UnsupportedOperationException e) {
return AjaxJson.getError(e.getMessage());
}
@ExceptionHandler({FileUploadException.class})
@ResponseBody
@ResponseStatus(HttpStatus.UNAUTHORIZED)
public AjaxJson handleFileUploadException(FileUploadException e) {
if (log.isDebugEnabled()) {
log.debug("上传文件失败: 存储类型: {}, 存储源 id: {}, 存储源路径: {}",
e.getStorageTypeEnum(), e.getStorageId(), e.getPath(), e);
}
return AjaxJson.getError("上传失败");
}
@ExceptionHandler({FileAccessException.class})
@ResponseBody
@ResponseStatus(HttpStatus.UNAUTHORIZED)
public AjaxJson handleFileAccessException(FileAccessException e) {
return AjaxJson.getError(e.getMessage());
}
@ExceptionHandler({HttpMessageNotReadableException.class})
@ResponseBody
@ResponseStatus(HttpStatus.BAD_REQUEST)
public AjaxJson handlerHttpMessageNotReadableException(HttpMessageNotReadableException e) {
return AjaxJson.getBadRequestError("请求参数不合法");
}
@ExceptionHandler({NotEnabledStorageSourceException.class})
@ResponseStatus(HttpStatus.FORBIDDEN)
@ResponseBody
public AjaxJson notEnabledDrive() {
return AjaxJson.getError("存储源已关闭");
}
@ExceptionHandler({NotExistFileException.class})
@ResponseBody
public AjaxJson notExistFile() {
return AjaxJson.getError("文件不存在");
}
/**
* 捕获 ClientAbortException 异常, 不做任何处理, 防止出现大量堆栈日志输出, 此异常不影响功能.
*/
@ExceptionHandler({HttpMediaTypeNotAcceptableException.class, ClientAbortException.class})
@ResponseBody
@ResponseStatus
public void clientAbortException() {
// if (log.isDebugEnabled()) {
// log.debug("出现了断开异常:", ex);
// }
}
@ExceptionHandler(value = {MethodArgumentNotValidException.class, BindException.class})
@ResponseBody
public AjaxJson handleValidException(Exception e) {
BindingResult bindingResult = null;
if (e instanceof MethodArgumentNotValidException) {
bindingResult = ((MethodArgumentNotValidException) e).getBindingResult();
} else if (e instanceof BindException) {
bindingResult = ((BindException) e).getBindingResult();
}
Map errorMap = new HashMap<>(16);
bindingResult.getFieldErrors().forEach((fieldError) ->
errorMap.put(fieldError.getField(), fieldError.getDefaultMessage())
);
return new AjaxJson(400, "非法参数 !", errorMap);
}
/**
* 密码校验异常
*/
@ExceptionHandler({PasswordVerifyException.class})
@ResponseBody
@ResponseStatus
public AjaxJson> passwordVerifyException(PasswordVerifyException ex) {
return AjaxJson.get(ex.getCode(), ex.getMessage());
}
/**
* 无效的存储源异常
*/
@ExceptionHandler({InvalidStorageSourceException.class})
@ResponseBody
@ResponseStatus(HttpStatus.BAD_REQUEST)
public AjaxJson invalidDriveException() {
return AjaxJson.getBadRequestError("此存储源不存在或初始化失败, 请检查后台参数配置");
}
/**
* 文件预览异常
*/
@ExceptionHandler({PreviewException.class})
@ResponseBody
@ResponseStatus
public AjaxJson previewException(PreviewException ex) {
return AjaxJson.getError(ex.getMessage());
}
/**
* 初始化异常
*/
@ExceptionHandler({InitializeStorageSourceException.class})
@ResponseBody
@ResponseStatus
public AjaxJson initializeException(InitializeStorageSourceException ex) {
return AjaxJson.getError(ex.getMessage());
}
/**
* 初始化时自动设置 cors 异常
*/
@ExceptionHandler({StorageSourceAutoConfigCorsException.class})
@ResponseBody
@ResponseStatus
public AjaxJson autoConfigCorsException(StorageSourceAutoConfigCorsException ex) {
log.error("跨域配置失败, 存储源初始化信息 {}, 异常信息: ", JSON.toJSON(ex.getIStorageParam()), ex);
return AjaxJson.getError(ex.getMessage());
}
/**
* 无权限时,进行文件操作异常.
*/
@ExceptionHandler({ForbidFileOperationException.class})
@ResponseBody
@ResponseStatus
public AjaxJson autoConfigCorsException(ForbidFileOperationException ex) {
log.error("存储源 {} 拦截非法的文件操作 {}", ex.getStorageId(), ex.getAction());
return AjaxJson.getError("非法操作");
}
@ExceptionHandler
@ResponseBody
@ResponseStatus
public AjaxJson extraExceptionHandler(Exception e) {
log.error(e.getMessage(), e);
if (e.getClass() == Exception.class) {
return AjaxJson.getError("系统异常, 请联系管理员");
} else {
return AjaxJson.getError(e.getMessage());
}
}
/**
* 登录异常拦截器
*/
@ExceptionHandler(NotLoginException.class)
@ResponseStatus(HttpStatus.UNAUTHORIZED)
@ResponseBody
public AjaxJson handlerNotLoginException(NotLoginException e) {
HttpServletRequest request = RequestHolder.getRequest();
String axiosRequest = request.getHeader("axios-request");
if (StrUtil.isNotEmpty(axiosRequest)){
return AjaxJson.getNotLogin();
}
try {
String domain = systemConfigService.getRealFrontDomain();
String loginUrl = StringUtils.removeDuplicateSlashes(domain + "/login");
RequestHolder.getResponse().sendRedirect(loginUrl);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
return null;
}
}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/common/exception/IllegalDownloadLinkException.java b/src/main/java/im/zhaojun/zfile/common/exception/IllegalDownloadLinkException.java
deleted file mode 100644
index 6a8d1ee..0000000
--- a/src/main/java/im/zhaojun/zfile/common/exception/IllegalDownloadLinkException.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package im.zhaojun.zfile.common.exception;
-
-/**
- * 非法使用下载链接异常.
- *
- * @author zhaojun
- */
-public class IllegalDownloadLinkException extends RuntimeException {
-
- public IllegalDownloadLinkException() {
- super();
- }
-
- public IllegalDownloadLinkException(String message) {
- super(message);
- }
-
- public IllegalDownloadLinkException(String message, Throwable cause) {
- super(message, cause);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/common/exception/InitializeStorageSourceException.java b/src/main/java/im/zhaojun/zfile/common/exception/InitializeStorageSourceException.java
deleted file mode 100644
index 1724821..0000000
--- a/src/main/java/im/zhaojun/zfile/common/exception/InitializeStorageSourceException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package im.zhaojun.zfile.common.exception;
-
-/**
- * 存储源初始化异常
- *
- * @author zhaojun
- */
-public class InitializeStorageSourceException extends RuntimeException {
-
- private static final long serialVersionUID = -1920550904063819880L;
-
- public InitializeStorageSourceException() {
- }
-
- public InitializeStorageSourceException(String message) {
- super(message);
- }
-
- public InitializeStorageSourceException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public InitializeStorageSourceException(Throwable cause) {
- super(cause);
- }
-
- public InitializeStorageSourceException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
- super(message, cause, enableSuppression, writableStackTrace);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/common/exception/InstallSystemException.java b/src/main/java/im/zhaojun/zfile/common/exception/InstallSystemException.java
deleted file mode 100644
index 239fc1a..0000000
--- a/src/main/java/im/zhaojun/zfile/common/exception/InstallSystemException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package im.zhaojun.zfile.common.exception;
-
-/**
- * 系统初始化异常
- *
- * @author zhaojun
- */
-public class InstallSystemException extends RuntimeException {
-
- public InstallSystemException() {
- super();
- }
-
- public InstallSystemException(String message) {
- super(message);
- }
-
- public InstallSystemException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public InstallSystemException(Throwable cause) {
- super(cause);
- }
-
- protected InstallSystemException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
- super(message, cause, enableSuppression, writableStackTrace);
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/common/exception/InvalidShortLinkException.java b/src/main/java/im/zhaojun/zfile/common/exception/InvalidShortLinkException.java
deleted file mode 100644
index bf1e4d6..0000000
--- a/src/main/java/im/zhaojun/zfile/common/exception/InvalidShortLinkException.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package im.zhaojun.zfile.common.exception;
-
-/**
- * 无效的直链异常
- *
- * @author zhaojun
- */
-public class InvalidShortLinkException extends RuntimeException {
-
- public InvalidShortLinkException() {
- }
-
- public InvalidShortLinkException(String message) {
- super(message);
- }
-
- public InvalidShortLinkException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public InvalidShortLinkException(Throwable cause) {
- super(cause);
- }
-
- public InvalidShortLinkException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
- super(message, cause, enableSuppression, writableStackTrace);
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/common/exception/InvalidStorageSourceException.java b/src/main/java/im/zhaojun/zfile/common/exception/InvalidStorageSourceException.java
deleted file mode 100644
index e4c4c5b..0000000
--- a/src/main/java/im/zhaojun/zfile/common/exception/InvalidStorageSourceException.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package im.zhaojun.zfile.common.exception;
-
-/**
- * 无效的存储源异常
- *
- * @author zhaojun
- */
-public class InvalidStorageSourceException extends RuntimeException {
-
- public InvalidStorageSourceException() {
- }
-
- public InvalidStorageSourceException(String message) {
- super(message);
- }
-
- public InvalidStorageSourceException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public InvalidStorageSourceException(Throwable cause) {
- super(cause);
- }
-
- public InvalidStorageSourceException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
- super(message, cause, enableSuppression, writableStackTrace);
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/common/exception/NotAllowedDownloadException.java b/src/main/java/im/zhaojun/zfile/common/exception/NotAllowedDownloadException.java
deleted file mode 100644
index 0489b31..0000000
--- a/src/main/java/im/zhaojun/zfile/common/exception/NotAllowedDownloadException.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package im.zhaojun.zfile.common.exception;
-
-/**
- * 文件不允许下载异常
- *
- * @author zhaojun
- */
-public class NotAllowedDownloadException extends RuntimeException {
-
- public NotAllowedDownloadException() {
- }
-
- public NotAllowedDownloadException(String message) {
- super(message);
- }
-
- public NotAllowedDownloadException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public NotAllowedDownloadException(Throwable cause) {
- super(cause);
- }
-
- public NotAllowedDownloadException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
- super(message, cause, enableSuppression, writableStackTrace);
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/common/exception/NotEnabledStorageSourceException.java b/src/main/java/im/zhaojun/zfile/common/exception/NotEnabledStorageSourceException.java
deleted file mode 100644
index 515c852..0000000
--- a/src/main/java/im/zhaojun/zfile/common/exception/NotEnabledStorageSourceException.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package im.zhaojun.zfile.common.exception;
-
-/**
- * 未启用的存储源异常
- *
- * @author zhaojun
- */
-public class NotEnabledStorageSourceException extends RuntimeException {
-
- public NotEnabledStorageSourceException() {
- }
-
- public NotEnabledStorageSourceException(String message) {
- super(message);
- }
-
- public NotEnabledStorageSourceException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public NotEnabledStorageSourceException(Throwable cause) {
- super(cause);
- }
-
- public NotEnabledStorageSourceException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
- super(message, cause, enableSuppression, writableStackTrace);
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/common/exception/NotExistFileException.java b/src/main/java/im/zhaojun/zfile/common/exception/NotExistFileException.java
deleted file mode 100644
index 24d114c..0000000
--- a/src/main/java/im/zhaojun/zfile/common/exception/NotExistFileException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package im.zhaojun.zfile.common.exception;
-
-/**
- * 不存在的文件异常
- *
- * @author zhaojun
- */
-public class NotExistFileException extends RuntimeException {
-
- public NotExistFileException() {
- super();
- }
-
- public NotExistFileException(String message) {
- super(message);
- }
-
- public NotExistFileException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public NotExistFileException(Throwable cause) {
- super(cause);
- }
-
- protected NotExistFileException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
- super(message, cause, enableSuppression, writableStackTrace);
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/common/exception/PreviewException.java b/src/main/java/im/zhaojun/zfile/common/exception/PreviewException.java
deleted file mode 100644
index dc567ac..0000000
--- a/src/main/java/im/zhaojun/zfile/common/exception/PreviewException.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package im.zhaojun.zfile.common.exception;
-
-/**
- * 文件预览异常类
- *
- * @author zhaojun
- */
-public class PreviewException extends RuntimeException {
-
- public PreviewException() {
- }
-
- public PreviewException(String message) {
- super(message);
- }
-
- public PreviewException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public PreviewException(Throwable cause) {
- super(cause);
- }
-
- public PreviewException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
- super(message, cause, enableSuppression, writableStackTrace);
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/common/exception/RefreshCacheException.java b/src/main/java/im/zhaojun/zfile/common/exception/RefreshCacheException.java
deleted file mode 100644
index 90e7e72..0000000
--- a/src/main/java/im/zhaojun/zfile/common/exception/RefreshCacheException.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package im.zhaojun.zfile.common.exception;
-
-/**
- * 刷新缓存时出现的异常信息
- *
- * @author zhaojun
- */
-public class RefreshCacheException extends RuntimeException {
-
- public RefreshCacheException() {
- }
-
- public RefreshCacheException(String message) {
- super(message);
- }
-
- public RefreshCacheException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public RefreshCacheException(Throwable cause) {
- super(cause);
- }
-
- public RefreshCacheException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
- super(message, cause, enableSuppression, writableStackTrace);
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/common/exception/TextParseException.java b/src/main/java/im/zhaojun/zfile/common/exception/TextParseException.java
deleted file mode 100644
index e7d5302..0000000
--- a/src/main/java/im/zhaojun/zfile/common/exception/TextParseException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package im.zhaojun.zfile.common.exception;
-
-/**
- * 文件解析异常
- *
- * @author zhaojun
- */
-public class TextParseException extends RuntimeException {
-
- public TextParseException() {
- super();
- }
-
- public TextParseException(String message) {
- super(message);
- }
-
- public TextParseException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public TextParseException(Throwable cause) {
- super(cause);
- }
-
- protected TextParseException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
- super(message, cause, enableSuppression, writableStackTrace);
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/common/exception/UnSupportedOperation.java b/src/main/java/im/zhaojun/zfile/common/exception/UnSupportedOperation.java
deleted file mode 100644
index ea4911f..0000000
--- a/src/main/java/im/zhaojun/zfile/common/exception/UnSupportedOperation.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package im.zhaojun.zfile.common.exception;
-
-/**
- * 不支持的操作异常
- *
- * @author zhaojun
- */
-public class UnSupportedOperation extends RuntimeException {
-
- public UnSupportedOperation() {
- super();
- }
-
- public UnSupportedOperation(String message) {
- super(message);
- }
-
- public UnSupportedOperation(String message, Throwable cause) {
- super(message, cause);
- }
-
- public UnSupportedOperation(Throwable cause) {
- super(cause);
- }
-
- protected UnSupportedOperation(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
- super(message, cause, enableSuppression, writableStackTrace);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/common/exception/file/StorageSourceException.java b/src/main/java/im/zhaojun/zfile/common/exception/file/StorageSourceException.java
deleted file mode 100644
index 4a4f510..0000000
--- a/src/main/java/im/zhaojun/zfile/common/exception/file/StorageSourceException.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package im.zhaojun.zfile.common.exception.file;
-
-import lombok.Getter;
-import lombok.Setter;
-
-/**
- * 存储源异常
- *
- * @author zhaojun
- */
-@Getter
-@Setter
-public class StorageSourceException extends RuntimeException {
-
- // 存储源 ID
- private Integer storageId;
-
- public StorageSourceException(Integer storageId) {
- this.storageId = storageId;
- }
-
- public StorageSourceException(Integer storageId, String message) {
- super(message);
- this.storageId = storageId;
- }
-
- public StorageSourceException(Integer storageId, Throwable cause) {
- super(cause);
- this.storageId = storageId;
- }
-
- public StorageSourceException(Integer storageId, String message, Throwable cause) {
- super(message, cause);
- this.storageId = storageId;
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/common/exception/file/operator/DownloadFileException.java b/src/main/java/im/zhaojun/zfile/common/exception/file/operator/DownloadFileException.java
deleted file mode 100644
index 708d572..0000000
--- a/src/main/java/im/zhaojun/zfile/common/exception/file/operator/DownloadFileException.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package im.zhaojun.zfile.common.exception.file.operator;
-
-import im.zhaojun.zfile.common.exception.file.StorageSourceException;
-import lombok.Getter;
-import lombok.Setter;
-
-/**
- * 文件下载异常
- *
- * @author zhaojun
- */
-@Getter
-@Setter
-public class DownloadFileException extends StorageSourceException {
-
- // 下载文件路径
- private String pathAndName;
-
- public DownloadFileException(Integer storageId, String pathAndName, Throwable cause) {
- super(storageId, cause);
- this.pathAndName = pathAndName;
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/common/exception/file/operator/GetFileInfoException.java b/src/main/java/im/zhaojun/zfile/common/exception/file/operator/GetFileInfoException.java
deleted file mode 100644
index 09c5ced..0000000
--- a/src/main/java/im/zhaojun/zfile/common/exception/file/operator/GetFileInfoException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package im.zhaojun.zfile.common.exception.file.operator;
-
-import im.zhaojun.zfile.common.exception.file.StorageSourceException;
-import lombok.Getter;
-import lombok.Setter;
-
-/**
- * 获取文件信息异常
- *
- * @author zhaojun
- */
-@Getter
-@Setter
-public class GetFileInfoException extends StorageSourceException {
-
- // 文件信息路径
- private String pathAndName;
-
- public GetFileInfoException(Integer storageId, String pathAndName) {
- super(storageId);
- this.pathAndName = pathAndName;
- }
-
- public GetFileInfoException(Integer storageId, String pathAndName, String message) {
- super(storageId, message);
- this.pathAndName = pathAndName;
- }
-
-
- public GetFileInfoException(Integer storageId, String pathAndName, Throwable cause) {
- super(storageId, cause);
- this.pathAndName = pathAndName;
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/common/exception/file/operator/ProxyDownloadFileException.java b/src/main/java/im/zhaojun/zfile/common/exception/file/operator/ProxyDownloadFileException.java
deleted file mode 100644
index 278016f..0000000
--- a/src/main/java/im/zhaojun/zfile/common/exception/file/operator/ProxyDownloadFileException.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package im.zhaojun.zfile.common.exception.file.operator;
-
-import im.zhaojun.zfile.common.exception.file.StorageSourceException;
-import lombok.Getter;
-import lombok.Setter;
-
-/**
- * 代理文件下载异常
- *
- * @author zhaojun
- */
-@Getter
-@Setter
-public class ProxyDownloadFileException extends StorageSourceException {
-
- // 下载文件路径
- private String pathAndName;
-
- public ProxyDownloadFileException(Integer storageId, String pathAndName, Throwable cause) {
- super(storageId, cause);
- this.pathAndName = pathAndName;
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/common/util/AjaxJson.java b/src/main/java/im/zhaojun/zfile/common/util/AjaxJson.java
deleted file mode 100644
index bf05659..0000000
--- a/src/main/java/im/zhaojun/zfile/common/util/AjaxJson.java
+++ /dev/null
@@ -1 +0,0 @@
-package im.zhaojun.zfile.common.util;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.List;
/**
* ajax 请求返回 JSON 格式数据的封装
*
* @author zhaojun
*/
public class AjaxJson implements Serializable {
private static final long serialVersionUID = 1L; // 序列化版本号
public static final int CODE_SUCCESS = 0; // 成功状态码
public static final int CODE_ERROR = 500; // 错误状态码
public static final int CODE_WARNING = 501; // 警告状态码
public static final int CODE_NOT_JUR = 403; // 无权限状态码
public static final int CODE_NOT_LOGIN = 401; // 未登录状态码
public static final int CODE_INVALID_REQUEST = 400; // 无效请求状态码
public static final int REQUIRED_PASSWORD = 405; // 未输入密码
public static final int INVALID_PASSWORD = 406; // 无效的密码
@ApiModelProperty(value = "业务状态码,0 为正常,其他值均为异常,异常情况下见响应消息", example = "0")
private final int code;
@ApiModelProperty(value = "响应消息", example = "ok")
private String msg;
@ApiModelProperty(value = "响应数据")
private T data;
@ApiModelProperty(value = "数据总条数,分页情况有效")
private final Long dataCount;
/**
* 返回code
*/
public int getCode() {
return this.code;
}
/**
* 给 msg 赋值,连缀风格
*/
public AjaxJson setMsg(String msg) {
this.msg = msg;
return this;
}
public String getMsg() {
return this.msg;
}
/**
* 给data赋值,连缀风格
*/
public AjaxJson setData(T data) {
this.data = data;
return this;
}
// ============================ 构建 ==================================
public AjaxJson(int code, String msg, T data) {
this.code = code;
this.msg = msg;
this.data = data;
this.dataCount = null;
}
public AjaxJson(int code, String msg, T data, Long dataCount) {
this.code = code;
this.msg = msg;
this.data = data;
this.dataCount = dataCount;
}
// 返回成功
public static AjaxJson getSuccess() {
return new AjaxJson<>(CODE_SUCCESS, "ok", null, null);
}
public static AjaxJson getSuccess(String msg) {
return new AjaxJson<>(CODE_SUCCESS, msg, null, null);
}
public static AjaxJson> getSuccess(String msg, Object data) {
return new AjaxJson<>(CODE_SUCCESS, msg, data, null);
}
public static AjaxJson getSuccessData(T data) {
return new AjaxJson<>(CODE_SUCCESS, "ok", data, null);
}
public static AjaxJson> getSuccessArray(Object... data) {
return new AjaxJson<>(CODE_SUCCESS, "ok", data, null);
}
// 返回失败
public static AjaxJson> getError() {
return new AjaxJson<>(CODE_ERROR, "error", null, null);
}
public static AjaxJson getError(String msg) {
return new AjaxJson<>(CODE_ERROR, msg, null, null);
}
public static AjaxJson getBadRequestError(String msg) {
return new AjaxJson<>(CODE_INVALID_REQUEST, msg, null, null);
}
// 返回警告
public static AjaxJson> getWarning() {
return new AjaxJson<>(CODE_ERROR, "warning", null, null);
}
public static AjaxJson> getWarning(String msg) {
return new AjaxJson<>(CODE_WARNING, msg, null, null);
}
// 返回未登录
public static AjaxJson> getNotLogin() {
return new AjaxJson<>(CODE_NOT_LOGIN, "未登录,请登录后再次访问", null, null);
}
// 返回没有权限的
public static AjaxJson> getNotJur(String msg) {
return new AjaxJson<>(CODE_NOT_JUR, msg, null, null);
}
// 返回一个自定义状态码的
public static AjaxJson> get(int code, String msg) {
return new AjaxJson<>(code, msg, null, null);
}
// 返回分页和数据的
public static AjaxJson> getPageData(Long dataCount, Object data) {
return new AjaxJson<>(CODE_SUCCESS, "ok", data, dataCount);
}
// 返回,根据布尔值来确定最终结果的 (true=ok,false=error)
public static AjaxJson> getByBoolean(boolean b) {
return b ? getSuccess("ok") : getError("error");
}
@SuppressWarnings("rawtypes")
@Override
public String toString() {
String data_string = null;
if (data == null) {
} else if (data instanceof List) {
data_string = "List(length=" + ((List) data).size() + ")";
} else {
data_string = data.toString();
}
return "{"
+ "\"code\": " + this.getCode()
+ ", \"msg\": \"" + this.getMsg() + "\""
+ ", \"data\": " + data_string
+ ", \"dataCount\": " + dataCount
+ "}";
}
public T getData() {
return data;
}
public Long getDataCount() {
return dataCount;
}
}
\ No newline at end of file
diff --git a/src/main/java/im/zhaojun/zfile/core/CommonResultControllerAdvice.java b/src/main/java/im/zhaojun/zfile/core/CommonResultControllerAdvice.java
new file mode 100644
index 0000000..8a89fa0
--- /dev/null
+++ b/src/main/java/im/zhaojun/zfile/core/CommonResultControllerAdvice.java
@@ -0,0 +1,67 @@
+package im.zhaojun.zfile.core;
+
+import im.zhaojun.zfile.core.util.AjaxJson;
+import org.slf4j.MDC;
+import org.springframework.core.MethodParameter;
+import org.springframework.http.MediaType;
+import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter;
+import org.springframework.http.converter.json.MappingJacksonValue;
+import org.springframework.http.server.ServerHttpRequest;
+import org.springframework.http.server.ServerHttpResponse;
+import org.springframework.lang.NonNull;
+import org.springframework.lang.Nullable;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
+
+/**
+ * @author zhaojun
+ */
+@ControllerAdvice
+public class CommonResultControllerAdvice implements ResponseBodyAdvice