package config

import (
	"fmt"
	"gadmin/internal/admin/library/feishu"
	"sync"
	"time"

	"github.com/joho/godotenv"
	"github.com/sirupsen/logrus"
)

var initOnce sync.Once

func Init(cfgfile string) {
	initOnce.Do(func() {

		envFilename := cfgfile

		fmt.Printf("当前运行环境为：%v, 加载的环境变量路径为：%v, 运行路径为：%v \r\n", SysType, envFilename, RootPtah)

		if err := godotenv.Load(envFilename); err != nil {
			logrus.Panic("本地环境加载失败", err)
			return
		}

		// 全局修改为上海时区
		time.Local, _ = time.LoadLocation("Asia/Shanghai")

		BuildLogger()
		InitDatabase()
		InitRedis()

		feishu.InitFeiShuClient()
	})
}
