package infra

import (
	_ "embed"
	"fmt"
	"gopkg.in/yaml.v2"
)

type ApplicationYamlStruct struct {
	ApplicationName string `yaml:"application"`
	Web             struct {
		Port        string   `yaml:"port"`
		RoutePrefix string   `yaml:"route-prefix"`
		Token       string   `yaml:"token"`
		WhiteList   []string `yaml:"white-list"`
	} `yaml:"web"`
	Log struct {
		Dir    string `yaml:"dir"`
		Prefix string `yaml:"prefix"`
	} `yaml:"log"`
	Mysql struct {
		Ip         string `yaml:"ip"`
		Port       string `yaml:"port"`
		Username   string `yaml:"username"`
		Password   string `yaml:"password"`
		Dbname     string `yaml:"dbname"`
		Charset    string `yaml:"charset"`
		SqlfileDir string `yaml:"sqlfile-dir"`
	} `yaml:"mysql"`
	Pdf struct {
		LocalDir      string `yaml:"local-dir"`
		Ttf           string `yaml:"ttf"`
		BackgroundPng string `yaml:"background-png"`
		LogoPng       string `yaml:"logo-png"`
	} `yaml:"pdf"`
}

var (
	//go:embed application.yaml
	applicationYamlBytes []byte
	ApplicationYaml      ApplicationYamlStruct
)

func InitApplication() {
	_ = yaml.Unmarshal(applicationYamlBytes, &ApplicationYaml)
	fmt.Println("加载配置文件内容为：", ApplicationYaml)
}
