config

package
v0.0.0-...-d5480cd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CORS

type CORS struct {
	Mode      string          `mapstructure:"mode" json:"mode" yaml:"mode"`
	Whitelist []CORSWhitelist `mapstructure:"whitelist" json:"whitelist" yaml:"whitelist"`
}

type CORSWhitelist

type CORSWhitelist struct {
	AllowOrigin      string `mapstructure:"allow-origin" json:"allow-origin" yaml:"allow-origin"`
	AllowMethods     string `mapstructure:"allow-methods" json:"allow-methods" yaml:"allow-methods"`
	AllowHeaders     string `mapstructure:"allow-headers" json:"allow-headers" yaml:"allow-headers"`
	ExposeHeaders    string `mapstructure:"expose-headers" json:"expose-headers" yaml:"expose-headers"`
	AllowCredentials bool   `mapstructure:"allow-credentials" json:"allow-credentials" yaml:"allow-credentials"`
}

type Captcha

type Captcha struct {
	KeyLong             int `mapstructure:"key-long" json:"key-long" yaml:"key-long"`                                           // 验证码长度
	ImgWidth            int `mapstructure:"img-width" json:"img-width" yaml:"img-width"`                                        // 验证码宽度
	ImgHeight           int `mapstructure:"img-height" json:"img-height" yaml:"img-height"`                                     // 验证码高度
	OpenCaptcha         int `mapstructure:"open-captcha" json:"open-captcha" yaml:"open-captcha"`                               // 防爆破验证码开启次数,0代表每次登录都需要验证码,其他数字代表错误密码次数,如3代表错误三次后出现验证码
	OpenCaptchaMax      int `mapstructure:"open-captcha-max" json:"open-captcha-max" yaml:"open-captcha-max"`                   // 最多登录失败次数,超过则锁定ip时长为1小时
	OpenCaptchaBuildMax int `mapstructure:"open-captcha-build-max" json:"open-captcha-build-max" yaml:"open-captcha-build-max"` // 最多生成验证码的次数,超过这个次数,还没有登录成功,则锁定ip时长为1小时
}

type DsnProvider

type DsnProvider interface {
	Dsn() string
}

type Email

type Email struct {
	To       string `mapstructure:"to" json:"to" yaml:"to"`                   // 收件人:多个以英文逗号分隔 例:a@qq.com b@qq.com 正式开发中请把此项目作为参数使用
	From     string `mapstructure:"from" json:"from" yaml:"from"`             // 发件人  你自己要发邮件的邮箱
	Host     string `mapstructure:"host" json:"host" yaml:"host"`             // 服务器地址 例如 smtp.qq.com  请前往QQ或者你要发邮件的邮箱查看其smtp协议
	Secret   string `mapstructure:"secret" json:"secret" yaml:"secret"`       // 密钥    用于登录的密钥 最好不要用邮箱密码 去邮箱smtp申请一个用于登录的密钥
	Nickname string `mapstructure:"nickname" json:"nickname" yaml:"nickname"` // 昵称    发件人昵称 通常为自己的邮箱
	Port     int    `mapstructure:"port" json:"port" yaml:"port"`             // 端口     请前往QQ或者你要发邮件的邮箱查看其smtp协议 大多为 465
	IsSSL    bool   `mapstructure:"is-ssl" json:"is-ssl" yaml:"is-ssl"`       // 是否SSL   是否开启SSL
}

type Excel

type Excel struct {
	Dir string `mapstructure:"dir" json:"dir" yaml:"dir"`
}

type GeneralDB

type GeneralDB struct {
	Prefix string `mapstructure:"prefix" json:"prefix" yaml:"prefix"`
	Port   string `mapstructure:"port" json:"port" yaml:"port"`
	Config string `mapstructure:"config" json:"config" yaml:"config"` // 高级配置
	/* system.env == debug 使用开发数据库 */
	DebugDbName   string `mapstructure:"debug-db-name" json:"debug-db-name" yaml:"debug-db-name"`    // 数据库名
	DebugUsername string `mapstructure:"debug-username" json:"debug-username" yaml:"debug-username"` // 用户名
	DebugPassword string `mapstructure:"debug-password" json:"debug-password" yaml:"debug-password"` // 数据库密码
	DebugPath     string `mapstructure:"debug-path" json:"debug-path" yaml:"debug-path"`             // 数据库连接地址
	/* system.env == release 使用生产数据库 */
	DbName   string `mapstructure:"db-name" json:"db-name" yaml:"db-name"`    // 数据库名
	Username string `mapstructure:"username" json:"username" yaml:"username"` // 用户名
	Password string `mapstructure:"password" json:"password" yaml:"password"` // 数据库密码
	Path     string `mapstructure:"path" json:"path" yaml:"path"`             // 数据库连接地址
	/* --------------------------------- */
	Engine       string `mapstructure:"engine" json:"engine" yaml:"engine" default:"InnoDB"`        //数据库引擎,默认InnoDB
	LogMode      string `mapstructure:"log-mode" json:"log-mode" yaml:"log-mode"`                   // 是否开启Gorm全局日志
	MaxIdleConns int    `mapstructure:"max-idle-conns" json:"max-idle-conns" yaml:"max-idle-conns"` // 空闲中的最大连接数
	MaxOpenConns int    `mapstructure:"max-open-conns" json:"max-open-conns" yaml:"max-open-conns"` // 打开到数据库的最大连接数
	Singular     bool   `mapstructure:"singular" json:"singular" yaml:"singular"`                   //是否开启全局禁用复数,true表示开启
	LogZap       bool   `mapstructure:"log-zap" json:"log-zap" yaml:"log-zap"`                      // 是否通过zap写入日志文件
}

GeneralDB 也被 Mysql 原样使用

type JWT

type JWT struct {
	SigningKey  string `mapstructure:"signing-key" json:"signing-key" yaml:"signing-key"`    // jwt签名
	ExpiresTime string `mapstructure:"expires-time" json:"expires-time" yaml:"expires-time"` // 过期时间
	BufferTime  string `mapstructure:"buffer-time" json:"buffer-time" yaml:"buffer-time"`    // 缓冲时间
	Issuer      string `mapstructure:"issuer" json:"issuer" yaml:"issuer"`                   // 签发者
}

type Local

type Local struct {
	Path      string `mapstructure:"path" json:"path" yaml:"path"`                   // 本地文件访问路径
	StorePath string `mapstructure:"store-path" json:"store-path" yaml:"store-path"` // 本地文件存储路径
}

type Mysql

type Mysql struct {
	GeneralDB `yaml:",inline" mapstructure:",squash"`
}

func (*Mysql) Dsn

func (m *Mysql) Dsn(env string) string

func (*Mysql) GetLogMode

func (m *Mysql) GetLogMode() string

type Redis

type Redis struct {
	Addr     string `mapstructure:"addr" json:"addr" yaml:"addr"`             // 服务器地址:端口
	Password string `mapstructure:"password" json:"password" yaml:"password"` // 密码
	DB       int    `mapstructure:"db" json:"db" yaml:"db"`                   // redis的哪个数据库
}

type Server

type Server struct {
	JWT     JWT     `mapstructure:"jwt" json:"jwt" yaml:"jwt"`
	Zap     Zap     `mapstructure:"zap" json:"zap" yaml:"zap"`
	Redis   Redis   `mapstructure:"redis" json:"redis" yaml:"redis"`
	Email   Email   `mapstructure:"email" json:"email" yaml:"email"`
	System  System  `mapstructure:"system" json:"system" yaml:"system"`
	Captcha Captcha `mapstructure:"captcha" json:"captcha" yaml:"captcha"`
	// gorm
	Mysql Mysql `mapstructure:"mysql" json:"mysql" yaml:"mysql"`

	Local Local `mapstructure:"local" json:"local" yaml:"local"`

	Excel Excel `mapstructure:"excel" json:"excel" yaml:"excel"`

	// 跨域配置
	Cors CORS `mapstructure:"cors" json:"cors" yaml:"cors"`

	Version string `mapstructure:"version" json:"version" yaml:"version"`
}

type System

type System struct {
	AuthCache    string `mapstructure:"auth-cache" json:"auth-cache" yaml:"auth-cache"` // token缓存的位置
	Username     string `mapstructure:"username" json:"username" yaml:"username"`       // 超级管理员账号
	Password     string `mapstructure:"password" json:"password" yaml:"password"`       // 超级管理员密码
	InitPwd      string `mapstructure:"init-pwd" json:"init-pwd" yaml:"init-pwd"`       // 初始化系统的密码init/db接口
	Env          string `mapstructure:"env" json:"env" yaml:"env"`                      // 环境值
	DbType       string `mapstructure:"db-type" json:"db-type" yaml:"db-type"`          // 数据库类型:mysql(默认)|sqlite|sqlserver|postgresql
	RouterPrefix string `mapstructure:"router-prefix" json:"router-prefix" yaml:"router-prefix"`
	Addr         int    `mapstructure:"addr" json:"addr" yaml:"addr"` // 端口值
	LimitCountIP int    `mapstructure:"iplimit-count" json:"iplimit-count" yaml:"iplimit-count"`
	LimitTimeIP  int    `mapstructure:"iplimit-time" json:"iplimit-time" yaml:"iplimit-time"`
	UseTls       bool   `mapstructure:"use-tls" json:"use-tls" yaml:"use-tls"`    // 开启https,使用tls证书
	TlsCert      string `mapstructure:"tls-cert" json:"tls-cert" yaml:"tls-cert"` // crt文件
	TlsKey       string `mapstructure:"tls-key" json:"tls-key" yaml:"tls-key"`    // key文件
}

type Zap

type Zap struct {
	Level         string `mapstructure:"level" json:"level" yaml:"level"`                            // 级别
	Prefix        string `mapstructure:"prefix" json:"prefix" yaml:"prefix"`                         // 日志前缀
	Format        string `mapstructure:"format" json:"format" yaml:"format"`                         // 输出
	Director      string `mapstructure:"director" json:"director"  yaml:"director"`                  // 日志文件夹
	EncodeLevel   string `mapstructure:"encode-level" json:"encode-level" yaml:"encode-level"`       // 编码级
	StacktraceKey string `mapstructure:"stacktrace-key" json:"stacktrace-key" yaml:"stacktrace-key"` // 栈名

	MaxAge       int  `mapstructure:"max-age" json:"max-age" yaml:"max-age"`                      // 日志留存时间
	ShowLine     bool `mapstructure:"show-line" json:"show-line" yaml:"show-line"`                // 显示行
	LogInConsole bool `mapstructure:"log-in-console" json:"log-in-console" yaml:"log-in-console"` // 输出控制台
}

func (*Zap) TransportLevel

func (z *Zap) TransportLevel() zapcore.Level

func (*Zap) ZapEncodeLevel

func (z *Zap) ZapEncodeLevel() zapcore.LevelEncoder

ZapEncodeLevel 根据 EncodeLevel 返回 zapcore.LevelEncoder

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL