diff --git a/src/main/java/im/zhaojun/common/aspect/StorageStrategyInitCheckAspect.java b/src/main/java/im/zhaojun/common/aspect/StorageStrategyInitCheckAspect.java index b3ebe7d..a0103e6 100644 --- a/src/main/java/im/zhaojun/common/aspect/StorageStrategyInitCheckAspect.java +++ b/src/main/java/im/zhaojun/common/aspect/StorageStrategyInitCheckAspect.java @@ -1,7 +1,7 @@ package im.zhaojun.common.aspect; import im.zhaojun.common.exception.StorageStrategyUninitializedException; -import im.zhaojun.common.service.FileService; +import im.zhaojun.common.service.AbstractFileService; import im.zhaojun.common.service.SystemConfigService; import im.zhaojun.common.util.SpringContextHolder; import org.aspectj.lang.annotation.Aspect; @@ -18,7 +18,7 @@ public class StorageStrategyInitCheckAspect { @Before("@annotation(im.zhaojun.common.annotation.CheckStorageStrategyInit)") public void logStart() { SystemConfigService systemConfigService = SpringContextHolder.getBean(SystemConfigService.class); - FileService currentFileService = systemConfigService.getCurrentFileService(); + AbstractFileService currentFileService = systemConfigService.getCurrentFileService(); if (currentFileService == null || !currentFileService.getIsInitialized()) { throw new StorageStrategyUninitializedException("存储策略异常, 请联系管理员!"); } diff --git a/src/main/java/im/zhaojun/common/config/StorageTypeFactory.java b/src/main/java/im/zhaojun/common/config/StorageTypeFactory.java index 97696ec..e2a927d 100644 --- a/src/main/java/im/zhaojun/common/config/StorageTypeFactory.java +++ b/src/main/java/im/zhaojun/common/config/StorageTypeFactory.java @@ -1,7 +1,7 @@ package im.zhaojun.common.config; import im.zhaojun.common.model.enums.StorageTypeEnum; -import im.zhaojun.common.service.FileService; +import im.zhaojun.common.service.AbstractFileService; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; @@ -15,7 +15,7 @@ import java.util.Map; @Component public class StorageTypeFactory implements ApplicationContextAware { - private static Map storageTypeEnumFileServiceMap; + private static Map storageTypeEnumFileServiceMap; private static ApplicationContext applicationContext; @@ -27,15 +27,15 @@ public class StorageTypeFactory implements ApplicationContextAware { applicationContext = act; // 获取 Spring 容器中所有 FileService 类型的类 - storageTypeEnumFileServiceMap = act.getBeansOfType(FileService.class); + storageTypeEnumFileServiceMap = act.getBeansOfType(AbstractFileService.class); } /** * 获取指定存储类型 Service */ - public static FileService getStorageTypeService(StorageTypeEnum type) { - FileService result = null; - for (FileService fileService : storageTypeEnumFileServiceMap.values()) { + public static AbstractFileService getStorageTypeService(StorageTypeEnum type) { + AbstractFileService result = null; + for (AbstractFileService fileService : storageTypeEnumFileServiceMap.values()) { if (fileService.getStorageTypeEnum() == type) { result = fileService; break; diff --git a/src/main/java/im/zhaojun/common/controller/FileController.java b/src/main/java/im/zhaojun/common/controller/FileController.java index 053bdd1..3be8af6 100644 --- a/src/main/java/im/zhaojun/common/controller/FileController.java +++ b/src/main/java/im/zhaojun/common/controller/FileController.java @@ -10,7 +10,7 @@ import im.zhaojun.common.model.dto.ResultBean; import im.zhaojun.common.model.dto.SiteConfigDTO; import im.zhaojun.common.model.dto.SystemConfigDTO; import im.zhaojun.common.model.enums.StorageTypeEnum; -import im.zhaojun.common.service.FileService; +import im.zhaojun.common.service.AbstractFileService; import im.zhaojun.common.service.StorageConfigService; import im.zhaojun.common.service.SystemConfigService; import im.zhaojun.common.service.SystemService; @@ -56,7 +56,7 @@ public class FileController { @RequestParam(defaultValue = "asc") String order, @RequestParam(required = false) String password, @RequestParam(defaultValue = "1") Integer page) throws Exception { - FileService fileService = systemConfigService.getCurrentFileService(); + AbstractFileService fileService = systemConfigService.getCurrentFileService(); List fileItemList = fileService.fileList(StringUtils.removeDuplicateSeparator("/" + URLUtil.decode(path) + "/")); for (FileItemDTO fileItemDTO : fileItemList) { if (ZFileConstant.PASSWORD_FILE_NAME.equals(fileItemDTO.getName()) @@ -112,7 +112,7 @@ public class FileController { @CheckStorageStrategyInit @GetMapping("/clearCache") public ResultBean clearCache() { - FileService fileService = systemConfigService.getCurrentFileService(); + AbstractFileService fileService = systemConfigService.getCurrentFileService(); if (fileService != null) { fileService.clearCache(); } @@ -128,7 +128,7 @@ public class FileController { @CheckStorageStrategyInit @GetMapping("/search") public ResultBean search(@RequestParam(value = "name", defaultValue = "/") String name) throws Exception { - FileService fileService = systemConfigService.getCurrentFileService(); + AbstractFileService fileService = systemConfigService.getCurrentFileService(); SystemConfigDTO systemConfigDTO = systemConfigService.getSystemConfig(); if (!systemConfigDTO.getSearchEnable()) { throw new SearchDisableException("搜索功能未开启"); diff --git a/src/main/java/im/zhaojun/common/controller/InstallController.java b/src/main/java/im/zhaojun/common/controller/InstallController.java index a3def3f..ede7be9 100644 --- a/src/main/java/im/zhaojun/common/controller/InstallController.java +++ b/src/main/java/im/zhaojun/common/controller/InstallController.java @@ -6,7 +6,7 @@ import im.zhaojun.common.model.dto.InstallModelDTO; import im.zhaojun.common.model.dto.ResultBean; import im.zhaojun.common.model.dto.SystemConfigDTO; import im.zhaojun.common.model.enums.StorageTypeEnum; -import im.zhaojun.common.service.FileService; +import im.zhaojun.common.service.AbstractFileService; import im.zhaojun.common.service.StorageConfigService; import im.zhaojun.common.service.SystemConfigService; import org.springframework.stereotype.Controller; @@ -90,7 +90,7 @@ public class InstallController { StorageTypeEnum currentStorageStrategy = systemConfigService.getCurrentStorageStrategy(); if (Objects.equals(storageStrategy, currentStorageStrategy)) { - FileService fileService = systemConfigService.getCurrentFileService(); + AbstractFileService fileService = systemConfigService.getCurrentFileService(); fileService.clearCache(); fileService.init(); } diff --git a/src/main/java/im/zhaojun/common/service/FileAsyncCacheService.java b/src/main/java/im/zhaojun/common/service/FileAsyncCacheService.java index dd9c8c9..3c0333a 100644 --- a/src/main/java/im/zhaojun/common/service/FileAsyncCacheService.java +++ b/src/main/java/im/zhaojun/common/service/FileAsyncCacheService.java @@ -29,7 +29,7 @@ public class FileAsyncCacheService { return; } - FileService fileService = StorageTypeFactory.getStorageTypeService(storageStrategy); + AbstractFileService fileService = StorageTypeFactory.getStorageTypeService(storageStrategy); log.info("缓存 {} 所有文件开始", storageStrategy.getDescription()); long startTime = System.currentTimeMillis(); try { diff --git a/src/main/java/im/zhaojun/common/service/SystemConfigService.java b/src/main/java/im/zhaojun/common/service/SystemConfigService.java index 79cbbcc..96aec18 100644 --- a/src/main/java/im/zhaojun/common/service/SystemConfigService.java +++ b/src/main/java/im/zhaojun/common/service/SystemConfigService.java @@ -115,7 +115,7 @@ public class SystemConfigService { systemConfigRepository.save(systemConfig); } - public FileService getCurrentFileService() { + public AbstractFileService getCurrentFileService() { StorageTypeEnum storageStrategy = getCurrentStorageStrategy(); return StorageTypeFactory.getStorageTypeService(storageStrategy); } diff --git a/src/main/java/im/zhaojun/common/service/SystemService.java b/src/main/java/im/zhaojun/common/service/SystemService.java index e983196..5a026dc 100644 --- a/src/main/java/im/zhaojun/common/service/SystemService.java +++ b/src/main/java/im/zhaojun/common/service/SystemService.java @@ -25,7 +25,7 @@ public class SystemService { public synchronized SiteConfigDTO getConfig(String path) throws Exception { SiteConfigDTO siteConfigDTO = new SiteConfigDTO(); - FileService fileService = systemConfigService.getCurrentFileService(); + AbstractFileService fileService = systemConfigService.getCurrentFileService(); List fileItemList = fileService.fileList(path); for (FileItemDTO fileItemDTO : fileItemList) {