package cfg

import (
	"time"
)

type Config struct {
	Debug            bool                `yaml:"debug"`
	Prd              bool                `yaml:"prd"`
	CurlDebug        bool                `yaml:"curldebug"`
	SrvAddr          string              `yaml:"srv_addr"`
	RedisAddr        string              `yaml:"redis_addr"`
	RedisAddrSecond  RedisAddrSeconds    `yaml:"redis_addr_second"`
	DB               DBCfg               `yaml:"db"`
	MQ               MQCfg               `yaml:"mq"`
	ES               ESCfg               `yaml:"es"`
	Log              LogCfg              `yaml:"log"`
	ArkID            ArkIDCfg            `yaml:"arkid"`
	Admin            AdminCfg            `yaml:"admin"`
	Official         OfficialCfg         `yaml:"official"`
	WebsiteBackend   WebsiteBackendCfg   `yaml:"website_backend"`
	WxappletFilepath WxappletFilepathCfg `yaml:"wxapplet_filepath"`
	H5Filepath       H5FilepathCfg       `yaml:"h5_filepath"`
	ImBusinessRpc    ImBusinessRpcCfg    `yaml:"im_business_rpc"`
	Local            bool
	AppComm          AppCommCfg   `yaml:"app_comm"`
	Zhimeng          ZhimengCfg   `yaml:"zm"`
	Supply           SupplyCfg    `yaml:"supply"`
	ZhiosOpen        ZhiosOpenCfg `yaml:"zhios_open"`
	ZhimengDB        DBCfg        `yaml:"zhimeng_db"`
}
type RedisAddrSeconds struct {
	Addr string `json:"addr"`
	Pwd  string `json:"pwd"`
}
type ZhiosOpenCfg struct {
	URL string `yaml:"url"`
}
type ImBusinessRpcCfg struct {
	URL  string `yaml:"url"`
	PORT string `yaml:"port"`
}

// 公共模块
type AppCommCfg struct {
	URL string `yaml:"url"`
}
type SupplyCfg struct {
	URL string `yaml:"url"`
}
type ZhimengCfg struct {
	URL string `yaml:"url"`
}

// OfficialCfg is 官网

type OfficialCfg struct {
	URL string `yaml:"url"`
}
type WxappletFilepathCfg struct {
	URL string `yaml:"url"`
}
type H5FilepathCfg struct {
	URL string `yaml:"url"`
}
type WebsiteBackendCfg struct {
	URL string `yaml:"url"`
}

// AdminCfg is  后台接口调用需要
type AdminCfg struct {
	URL    string `yaml:"url"`
	IURL   string `yaml:"iurl"`
	AesKey string `yaml:"api_aes_key"`
	AesIV  string `yaml:"api_aes_iv"`
}

type ArkIDCfg struct {
	Admin         string `yaml:"admin"`
	AdminPassword string `yaml:"admin_password"`
	Url           string `yaml:"url`
}

//数据库配置结构体
type DBCfg struct {
	Host         string        `yaml:"host"`     //ip及端口
	Name         string        `yaml:"name"`     //库名
	User         string        `yaml:"user"`     //用户
	Psw          string        `yaml:"psw"`      //密码
	ShowLog      bool          `yaml:"show_log"` //是否显示SQL语句
	MaxLifetime  time.Duration `yaml:"max_lifetime"`
	MaxOpenConns int           `yaml:"max_open_conns"`
	MaxIdleConns int           `yaml:"max_idle_conns"`
	Path         string        `yaml:"path"` //日志文件存放路径
}

type MQCfg struct {
	Host string `yaml:"host"`
	Port string `yaml:"port"`
	User string `yaml:"user"`
	Pwd  string `yaml:"pwd"`
}
type ESCfg struct {
	Url  string `yaml:"url"`
	User string `yaml:"user"`
	Pwd  string `yaml:"pwd"`
}

//日志配置结构体
type LogCfg struct {
	AppName    string `yaml:"app_name" `
	Level      string `yaml:"level"`
	IsStdOut   bool   `yaml:"is_stdout"`
	TimeFormat string `yaml:"time_format"` // second, milli, nano, standard, iso,
	Encoding   string `yaml:"encoding"`    // console, json

	IsFileOut   bool   `yaml:"is_file_out"`
	FileDir     string `yaml:"file_dir"`
	FileName    string `yaml:"file_name"`
	FileMaxSize int    `yaml:"file_max_size"`
	FileMaxAge  int    `yaml:"file_max_age"`
}
