|
@@ -0,0 +1,29 @@
|
|
|
+package com.dayou.initializer;
|
|
|
+
|
|
|
+import com.dayou.config.FileNetConfig;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.context.ApplicationListener;
|
|
|
+import org.springframework.context.event.ContextRefreshedEvent;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 项目启动时初始化操作
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class ApplicationStartup implements ApplicationListener<ContextRefreshedEvent> {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FileNetConfig fileNetConfig;
|
|
|
+
|
|
|
+ // 判断所需文件夹是否存在
|
|
|
+ @Override
|
|
|
+ public void onApplicationEvent(ContextRefreshedEvent event) {
|
|
|
+ // 判断文件夹是否存在
|
|
|
+ File folder = new File(fileNetConfig.getBaseDir() + fileNetConfig.getAssetOutputCalculatePath());
|
|
|
+ if (!folder.exists()) { // 不存在就创建一个
|
|
|
+ folder.mkdirs();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|