mirror of
https://github.com/zfile-dev/zfile.git
synced 2025-04-19 05:34:52 +00:00
32 lines
1.1 KiB
Java
32 lines
1.1 KiB
Java
package im.zhaojun.common.aspect;
|
|
|
|
import im.zhaojun.common.exception.StorageStrategyUninitializedException;
|
|
import im.zhaojun.common.service.AbstractFileService;
|
|
import im.zhaojun.common.service.SystemConfigService;
|
|
import im.zhaojun.common.util.SpringContextHolder;
|
|
import org.aspectj.lang.annotation.Aspect;
|
|
import org.aspectj.lang.annotation.Before;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
/**
|
|
* @author zhaojun
|
|
*/
|
|
@Aspect
|
|
@Component
|
|
public class StorageStrategyInitCheckAspect {
|
|
|
|
@Before("@annotation(im.zhaojun.common.annotation.CheckStorageStrategyInit)")
|
|
public void logStart() {
|
|
SystemConfigService systemConfigService = SpringContextHolder.getBean(SystemConfigService.class);
|
|
AbstractFileService currentFileService = systemConfigService.getCurrentFileService();
|
|
if (currentFileService == null) {
|
|
throw new StorageStrategyUninitializedException("存储策略尚未初始化, 请联系管理员!");
|
|
}
|
|
if (currentFileService.getIsUnInitialized()) {
|
|
throw new StorageStrategyUninitializedException("存储策略异常, 请联系管理员!");
|
|
}
|
|
|
|
}
|
|
|
|
}
|