From cfacd39210e1bd942a51901cdabfe91785c2c583 Mon Sep 17 00:00:00 2001 From: zhaojun1998 Date: Wed, 29 Jan 2020 12:52:07 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81,=20=E5=A2=9E=E5=BC=BA=E5=81=A5=E5=A3=AE=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../im/zhaojun/common/controller/AdminController.java | 4 +++- .../java/im/zhaojun/common/controller/FileController.java | 5 +++-- .../im/zhaojun/common/service/AbstractFileService.java | 3 ++- .../im/zhaojun/common/service/SystemConfigService.java | 8 ++++---- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/im/zhaojun/common/controller/AdminController.java b/src/main/java/im/zhaojun/common/controller/AdminController.java index 09eafdd..19ac8f8 100644 --- a/src/main/java/im/zhaojun/common/controller/AdminController.java +++ b/src/main/java/im/zhaojun/common/controller/AdminController.java @@ -63,7 +63,9 @@ public class AdminController { StorageTypeEnum currentStorageStrategy = currentFileService.getStorageTypeEnum(); if (!Objects.equals(currentStorageStrategy, systemConfigDTO.getStorageStrategy())) { - log.info("已将存储策略由 {} 切换为 {}", currentStorageStrategy, systemConfigDTO.getStorageStrategy()); + log.info("已将存储策略由 {} 切换为 {}", + currentStorageStrategy.getDescription(), + systemConfigDTO.getStorageStrategy().getDescription()); refreshStorageStrategy(); } diff --git a/src/main/java/im/zhaojun/common/controller/FileController.java b/src/main/java/im/zhaojun/common/controller/FileController.java index 6ef9f35..df26968 100644 --- a/src/main/java/im/zhaojun/common/controller/FileController.java +++ b/src/main/java/im/zhaojun/common/controller/FileController.java @@ -1,5 +1,6 @@ package im.zhaojun.common.controller; +import cn.hutool.core.util.BooleanUtil; import cn.hutool.core.util.URLUtil; import im.zhaojun.common.annotation.CheckStorageStrategyInit; import im.zhaojun.common.exception.SearchDisableException; @@ -88,10 +89,10 @@ public class FileController { public ResultBean search(@RequestParam(value = "name", defaultValue = "/") String name, @RequestParam(defaultValue = "name") String sortBy, @RequestParam(defaultValue = "asc") String order, - @RequestParam(defaultValue = "1") Integer page) throws Exception { + @RequestParam(defaultValue = "1") Integer page) { AbstractFileService fileService = systemConfigService.getCurrentFileService(); SystemConfigDTO systemConfigDTO = systemConfigService.getSystemConfig(); - if (!systemConfigDTO.getSearchEnable()) { + if (BooleanUtil.isFalse(systemConfigDTO.getSearchEnable())) { throw new SearchDisableException("搜索功能未开启"); } if (!fileAsyncCacheService.isCacheFinish()) { diff --git a/src/main/java/im/zhaojun/common/service/AbstractFileService.java b/src/main/java/im/zhaojun/common/service/AbstractFileService.java index 76d135c..4b009ad 100644 --- a/src/main/java/im/zhaojun/common/service/AbstractFileService.java +++ b/src/main/java/im/zhaojun/common/service/AbstractFileService.java @@ -1,5 +1,6 @@ package im.zhaojun.common.service; +import cn.hutool.core.util.BooleanUtil; import cn.hutool.core.util.StrUtil; import com.alicp.jetcache.Cache; import com.alicp.jetcache.RefreshPolicy; @@ -187,7 +188,7 @@ public abstract class AbstractFileService extends FileCacheService implements Fi private boolean isNotEncryptedFolder(List list) { // 如果开启了 "搜索包含加密文件" 选项, 则直接返回 true. SystemConfigDTO systemConfig = systemConfigService.getSystemConfig(); - if (systemConfig.getSearchContainEncryptedFile()) { + if (BooleanUtil.isFalse(systemConfig.getSearchContainEncryptedFile())) { return true; } diff --git a/src/main/java/im/zhaojun/common/service/SystemConfigService.java b/src/main/java/im/zhaojun/common/service/SystemConfigService.java index c7e1025..8659243 100644 --- a/src/main/java/im/zhaojun/common/service/SystemConfigService.java +++ b/src/main/java/im/zhaojun/common/service/SystemConfigService.java @@ -1,7 +1,7 @@ package im.zhaojun.common.service; import cn.hutool.core.convert.Convert; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.BooleanUtil; import cn.hutool.crypto.SecureUtil; import com.alicp.jetcache.Cache; import com.alicp.jetcache.anno.CacheType; @@ -92,7 +92,7 @@ public class SystemConfigService { } boolean oldEnableCache = getEnableCache(); - boolean curEnableCache = ObjectUtil.defaultIfNull(systemConfigDTO.getEnableCache(), false); + boolean curEnableCache = BooleanUtil.isTrue(systemConfigDTO.getEnableCache()); configCache.remove(SYSTEM_CONFIG_CACHE_KEY); @@ -146,12 +146,12 @@ public class SystemConfigService { public boolean getEnableCache() { SystemConfigDTO systemConfigDTO = getSystemConfig(); - return ObjectUtil.defaultIfNull(systemConfigDTO.getEnableCache(), false); + return BooleanUtil.isTrue(systemConfigDTO.getEnableCache()); } public boolean getSearchIgnoreCase() { SystemConfigDTO systemConfigDTO = getSystemConfig(); - return ObjectUtil.defaultIfNull(systemConfigDTO.getSearchIgnoreCase(), false); + return BooleanUtil.isTrue(systemConfigDTO.getSearchIgnoreCase()); }