初始化存储引擎后, 增加测试连接机制

This commit is contained in:
zhaojun1998
2019-12-25 21:57:22 +08:00
parent e334acd508
commit b65ccc95e2
10 changed files with 23 additions and 14 deletions

View File

@@ -1,7 +1,7 @@
package im.zhaojun.common.aspect;
import im.zhaojun.common.exception.StorageStrategyUninitializedException;
import im.zhaojun.common.model.enums.StorageTypeEnum;
import im.zhaojun.common.service.FileService;
import im.zhaojun.common.service.SystemConfigService;
import im.zhaojun.common.util.SpringContextHolder;
import org.aspectj.lang.annotation.Aspect;
@@ -18,10 +18,9 @@ public class StorageStrategyInitCheckAspect {
@Before("@annotation(im.zhaojun.common.annotation.CheckStorageStrategyInit)")
public void logStart() {
SystemConfigService systemConfigService = SpringContextHolder.getBean(SystemConfigService.class);
StorageTypeEnum currentStorageStrategy = systemConfigService.getCurrentStorageStrategy();
if (currentStorageStrategy == null) {
throw new StorageStrategyUninitializedException("存储策略未初始化");
FileService currentFileService = systemConfigService.getCurrentFileService();
if (currentFileService == null || !currentFileService.getIsInitialized()) {
throw new StorageStrategyUninitializedException("存储策略异常, 请联系管理员!");
}
}