package top.gtb520.java.backend.apibackserver;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import top.gtb520.java.backend.apibackserver.utils.YamlFile_Utils;
import top.gtb520.java.backend.apibackserver.utils.tools;

import java.io.File;
import java.util.List;

@SpringBootApplication
public class Main {
    public static YamlFile_Utils Yaml;

    public static void init() {
        Yaml = new YamlFile_Utils();
        // 测试数据库连接
        System.out.println("正在测试数据库连接...");
        tools.testDatabaseConnection();
    }

    public static void main(String[] args) {
        try {
            init();
        } catch (Exception e) {
            System.out.println("初始化失败");
            throw new RuntimeException(e);
        }
        System.out.println("初始化完成");

        // 启动程序
        SpringApplication.run(Main.class, args);
    }

    private static void Makedirs(List<File> Folders) {
        for (File EachFolder : Folders) {
            if (!EachFolder.exists()) {
                EachFolder.mkdirs();
            }
        }
    }
}
