package com.dcsoft.file;

import com.dcsoft.file.config.FileListener;
import org.apache.commons.io.monitor.FileAlterationMonitor;
import org.apache.commons.io.monitor.FileAlterationObserver;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import com.dcsoft.common.swagger.annotation.EnableCustomSwagger2;

import java.io.File;
import java.util.concurrent.TimeUnit;

/**
 * 文件服务
 *
 * @author dcsoft
 */
@EnableCustomSwagger2
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })
public class DCSFileApplication
{
  /*  public static String rootDir;

    @Value("${backImg.rootDir}")
    public void setRootDir(String rootDir) {
        this.rootDir = rootDir;
    }

    public static String copyDir;

    @Value("${backImg.copyDir}")
    public void setCopyDir(String copyDir) {
        this.copyDir = copyDir;
    }*/

    public static void main(String[] args)
    {
        SpringApplication.run(DCSFileApplication.class, args);
        System.out.println("(♥◠‿◠)ﾉﾞ  文件服务模块启动成功   ლ(´ڡ`ლ)ﾞ  \n" +
                "  ___     ___     ___   \n" +
                "  |   \\   / __|   / __|  \n" +
                "  | |) | | (__    \\__ \\  \n" +
                "  |___/   \\___|   |___/  ");

       /* // 轮询间隔 5 秒
        long interval = TimeUnit.SECONDS.toMillis(5);
        // 不使用过滤器
        FileAlterationObserver observer = new FileAlterationObserver(new File(rootDir));
        observer.addListener(new FileListener(rootDir,copyDir));
        // 创建文件变化监听器
        FileAlterationMonitor monitor = new FileAlterationMonitor(interval, observer);
        // 开始监控
        try {
            monitor.start();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }*/
    }
}
