package org.dromara.config;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.system.service.IGameEventService;
import org.dromara.system.service.ISysOssConfigService;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * 系统启动初始化配置类
 *
 * @author zlt
 */

@Slf4j
@Component
@RequiredArgsConstructor
public class SystemInitializationRunner implements ApplicationRunner {
    private final IGameEventService gameEventService;
    private final ISysOssConfigService ossConfigService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.info("开始初始化系统配置...");
        try {
            // 初始化OSS配置
            ossConfigService.init();
            log.info("OSS配置初始化完成");
        } catch (Exception e) {
            log.error("OSS配置初始化失败", e);
        }

        try {
            // 初始化默认赛事配置
            gameEventService.init();
            log.info("赛事配置初始化完成");
        } catch (Exception e) {
            log.error("赛事配置初始化失败", e);
        }

        log.info("系统配置初始化完成");
    }
}
