package c_db

import (
	"cicv-data-closedloop/common/config/c_log"
	"os"
	"path/filepath"
)

var SqlFilesMap = map[string]string{}

func InitSqlFilesMap(dir string) {
	files, err := os.ReadDir(dir)
	if err != nil {
		c_log.GlobalLogger.Error("程序退出。加载sql文件错误：", err)
		os.Exit(-1)
	}

	for _, file := range files {
		if !file.IsDir() && filepath.Ext(file.Name()) == ".sql" {
			filePath := filepath.Join(dir, file.Name())
			SqlFilesMap[file.Name()] = filePath
		}
	}
	c_log.GlobalLogger.Info("sql文件加载成功：", SqlFilesMap)
}
