Skip to content
geelevelgeelevel

配置文件

JWT

yaml

yaml
# jwt configuration
jwt:
  signing-key: 'qmPlus'
  expires-time: 7d
  buffer-time: 1d

struct

go
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"`                   // 签发者
}

description

配置名类型说明
signing-keystringjwt的签名
expires-timeint64过期时间
buffer-timeint64缓冲时间(过期前这段时间内有过请求会刷新jwt续期)
issuerstringjwt签发者

Zap

yaml

yaml
# zap logger configuration
zap:
  level: 'info'
  format: 'console'
  prefix: '[GIN-VUE-ADMIN]'
  director: 'log'
  show-line: true
  encode-level: 'LowercaseColorLevelEncoder'
  stacktrace-key: 'stacktrace'
  log-in-console: true
  retention-day: 7

struct

go
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"` // 栈名
	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"` // 输出控制台
	RetentionDay  int    `mapstructure:"retention-day" json:"retention-day" yaml:"retention-day"`    // 日志保留天数
}

description

配置名类型说明
levelstringlevel的模式的详细说明,请看zap官方文档
info: info模式,无错误的堆栈信息,只输出信息
debug:debug模式,有错误的堆栈详细信息
warn:warn模式
error: error模式,有错误的堆栈详细信息
dpanic: dpanic模式
panic: panic模式
fatal: fatal模式
formatstringconsole: 控制台形式输出日志 json: json格式输出日志
prefixstring日志的前缀
directorstring存放日志的文件夹,修改即可,不需要手动创建
show_linebool显示行号, 默认为true,不建议修改
encode_levelstringLowercaseLevelEncoder:小写
LowercaseColorLevelEncoder:小写带颜色
CapitalLevelEncoder: 大写
CapitalColorLevelEncoder: 大写带颜色
stacktrace_keystring堆栈的名称,即在json格式输出日志时的josn的key
log_in_consolebool是否输出到控制台,默认为true
retention_dayint日志保留天数
  • 开发环境 || 调试环境配置建议
    • level:debug
    • format:console
    • encode-level:LowercaseColorLevelEncoder或者encode-leve:CapitalColorLevelEncoder
  • 部署环境配置建议
    • level:error
    • format:json
    • encode-level: LowercaseLevelEncoder 或者 encode-level:CapitalLevelEncoder
    • log-in-console: false
  • 建议只是建议,按照自己的需求进行即可,给出建议仅供参考

Redis

yaml

yaml
# redis configuration
redis:
  name: ''
  addr: '127.0.0.1:6379'
  password: ''
  db: 0
  use-cluster: false
  cluster-addrs: []

struct

go
type Redis struct {
	Name         string   `mapstructure:"name" json:"name" yaml:"name"`                         // 代表当前实例的名字
	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的哪个数据库
	UseCluster   bool     `mapstructure:"useCluster" json:"useCluster" yaml:"useCluster"`       // 是否使用集群模式
	ClusterAddrs []string `mapstructure:"clusterAddrs" json:"clusterAddrs" yaml:"clusterAddrs"` // 集群模式下的节点地址列表
}

description

配置名类型说明
namestring代表当前实例的名字
addrstringredis连接地址及端口
passwordstring密码
dbintredis的哪个数据库
use-clusterbool是否使用集群模式
cluster-addrs[]string集群模式下的节点地址列表

Email

yaml

yaml
# email configuration
email:
  to: 'xxx@qq.com'
  port: 465
  from: 'xxx@163.com'
  host: 'smtp.163.com'
  is-ssl: true
  secret: 'xxx'
  nickname: 'test'
  is-loginauth: false

struct

go
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
	IsLoginAuth bool   `mapstructure:"is-loginauth" json:"is-loginauth" yaml:"is-loginauth"` // 是否LoginAuth   是否使用LoginAuth认证方式(适用于IBM、微软邮箱服务器等)
}

description

配置名类型说明
tostring邮件接收者,可以是多个,
以英文逗号(,)进行区分,最好别带空格,如果是一个邮箱最后请不要加英文逗号(,)
fromstring发件人邮箱
hoststring邮箱的主服务器地址
secretstring密钥,用于登录的密钥,最好不要用邮箱密码
nicknamestring发件人昵称
portint邮件服务端口
is-sslbool是否使用SSL
is-loginauthbool是否使用LoginAuth认证方式(适用于IBM、微软邮箱服务器等)

Casbin

yaml

yaml
# casbin configuration
casbin:
  model-path: './resource/rbac_model.conf'

struct

go
type Casbin struct {
	ModelPath string `mapstructure:"model-path" json:"modelPath" yaml:"model-path"`
}

description

配置名类型说明建议是否修改
model-pathstring存放casbin模型的相对路径
默认值为./resource/rbac_model.conf
不推荐修改

System

yaml

yaml
# system configuration
system:
  env: 'public'
  db-type: 'mysql'
  oss-type: 'local'
  router-prefix: ''
  addr: 8888
  iplimit-count: 15000
  iplimit-time: 3600
  use-multipoint: false
  use-redis: false
  use-mongo: false
  use-strict-auth: false

struct

go
type System struct {
	Env           string `mapstructure:"env" json:"env" yaml:"env"`                                     // 环境值
	DbType        string `mapstructure:"db-type" json:"db-type" yaml:"db-type"`                         // 数据库类型:mysql(默认)|sqlite|sqlserver|postgresql
	OssType       string `mapstructure:"oss-type" json:"oss-type" yaml:"oss-type"`                     // Oss类型
	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"`       // 限制同IP访问次数
	LimitTimeIP   int    `mapstructure:"iplimit-time" json:"iplimit-time" yaml:"iplimit-time"`          // 限制时间
	UseMultipoint bool   `mapstructure:"use-multipoint" json:"use-multipoint" yaml:"use-multipoint"`    // 多点登录拦截
	UseRedis      bool   `mapstructure:"use-redis" json:"use-redis" yaml:"use-redis"`                   // 使用redis
	UseMongo      bool   `mapstructure:"use-mongo" json:"use-mongo" yaml:"use-mongo"`                   // 使用mongo
	UseStrictAuth bool   `mapstructure:"use-strict-auth" json:"use-strict-auth" yaml:"use-strict-auth"` // 使用树形角色分配模式
}

description

配置名类型说明
envstring环境模式,"develop"为开发模式(跳过身份验证),"public"为生产模式
addrint后端服务端口,默认8888
db-typestring数据库类型,支持:mysql、pgsql、sqlite、mssql、oracle
oss-typestring对象存储类型:local(本地存储)、qiniu(七牛云)、aliyun(阿里云)、minio
local:存储到 local.path 目录
其他类型需要配置对应的参数
router-prefixstring路由前缀,用于API路由统一前缀
use-multipointbool是否启用多点登录拦截(单点登录),默认false
use-redisbool是否使用Redis缓存,默认false
iplimit-countintIP限流:指定时间段内同IP最大访问次数,默认15000
iplimit-timeintIP限流:限制时间窗口(秒),默认3600
use-mongobool是否使用MongoDB数据库,默认false
use-strict-authbool是否开启严格角色模式(树形角色分配),默认false

captcha

yaml

yaml
# captcha configuration
captcha:
  key-long: 6
  img-width: 240
  img-height: 80
  open-captcha: 0
  open-captcha-timeout: 3600

struct

go
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代表错误三次后出现验证码
	OpenCaptchaTimeOut int `mapstructure:"open-captcha-timeout" json:"open-captcha-timeout" yaml:"open-captcha-timeout"` // 防爆破验证码超时时间,单位:s(秒)
}

description

配置名类型说明
key-longint验证码长度
img-widthint验证码宽度
img-heightint验证码高度
open-captchaint防爆破验证码开启此数,0代表每次登录都需要验证码,其他数字代表错误密码次数
open-captcha-timeoutint防爆破验证码超时时间,单位:s(秒)

Mysql [pgsql,sqlite,mssql,oracle]

yaml

yaml
# mysql connect configuration
mysql:
  path: ''
  port: ''
  config: ''
  db-name: ''
  username: ''
  password: ''
  prefix: ''
  singular: false
  engine: 'InnoDB'
  max-idle-conns: 10
  max-open-conns: 100
  log-mode: 'info'
  log-zap: false

struct

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

type GeneralDB struct {
    Path         string `mapstructure:"path" json:"path" yaml:"path"`
    Port         string `mapstructure:"port" json:"port" yaml:"port"`
    Config       string `mapstructure:"config" json:"config" yaml:"config"`
    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"`
    Prefix       string `mapstructure:"prefix" json:"prefix" yaml:"prefix"`
    Singular     bool   `mapstructure:"singular" json:"singular" yaml:"singular"`
    Engine       string `mapstructure:"engine" json:"engine" yaml:"engine" default:"InnoDB"`
    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"`
    LogMode      string `mapstructure:"log-mode" json:"log-mode" yaml:"log-mode"`
    LogZap       bool   `mapstructure:"log-zap" json:"log-zap" yaml:"log-zap"`
}

description

配置名类型说明
pathstring数据库服务器地址
portstring数据库端口
usernamestring数据库用户名
passwordstring数据库密码
db-namestring数据库名
configstring数据库连接高级配置
prefixstring表名前缀
singularbool是否使用单数表名
enginestring数据库引擎,默认InnoDB
max-idle-connsint设置空闲中的最大连接数
max-open-connsint设置打开到数据库的最大连接数
log-modestring开启Gorm全局日志等级:"silent"、"error"、"warn"、"info",默认info
log-zapbool是否通过zap写入日志文件

struct

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

// GeneralDB 结构体定义见上方 Mysql 部分

description

配置名类型说明
pathstring数据库服务器地址
portstring数据库端口
usernamestring数据库用户名
passwordstring数据库密码
db-namestring数据库名
configstring数据库连接高级配置
prefixstring表名前缀
singularbool是否使用单数表名
enginestring数据库引擎,默认InnoDB
max-idle-connsint设置空闲中的最大连接数
max-open-connsint设置打开到数据库的最大连接数
log-modestring开启Gorm全局日志等级:"silent"、"error"、"warn"、"info",默认info
log-zapbool是否通过zap写入日志文件

Local

yaml

yaml
# local configuration
local:
  path: 'uploads/file'
  store-path: 'uploads/file'

struct

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

description

配置名类型说明
pathstring本地文件访问路径
store-pathstring本地文件存储路径

Qiniu

yaml

yaml
# qiniu configuration (请自行七牛申请对应的 公钥 私钥 bucket 和 域名地址)
qiniu:
  zone: '你的空间区域'
  bucket: '你的空间名'
  img-path: '你的oss域名'
  use-https: false
  access-key: 'xxxxxxxxxxxxxxxxxxxxxxxxx'
  secret-key: 'xxxxxxxxxxxxxxxxxxxxxxxxx'
  use-cdn-domains: false

struct

go
type Qiniu struct {
	Zone          string `mapstructure:"zone" json:"zone" yaml:"zone"`
	Bucket        string `mapstructure:"bucket" json:"bucket" yaml:"bucket"`
	ImgPath       string `mapstructure:"img-path" json:"imgPath" yaml:"img-path"`
	UseHTTPS      bool   `mapstructure:"use-https" json:"useHttps" yaml:"use-https"`
	AccessKey     string `mapstructure:"access-key" json:"accessKey" yaml:"access-key"`
	SecretKey     string `mapstructure:"secret-key" json:"secretKey" yaml:"secret-key"`
	UseCdnDomains bool   `mapstructure:"use-cdn-domains" json:"useCdnDomains" yaml:"use-cdn-domains"`
}

description

配置名类型说明
zonestring存储区域 Zone ,可配置选项为 ZoneHuadong / ZoneHuabei / ZoneHuanan / ZoneBeimei / ZoneXinjiapo
bucketstring存储空间
img-pathstringCDN 加速域名
use-httpsbool是否使用https
access-keystring秘钥AK
secret-keystring秘钥SK
use-cdn-domainsbool上传是否使用CDN上传加速

AutoCode

yaml

yaml
# autocode configuration
autocode:
  web: '/web/src'
  root: ''
  server: '/server'
  module: 'github.com/flipped-aurora/gin-vue-admin/server'
  ai-path: ''

struct

go
type Autocode struct {
	Web    string `mapstructure:"web" json:"web" yaml:"web"`
	Root   string `mapstructure:"root" json:"root" yaml:"root"`
	Server string `mapstructure:"server" json:"server" yaml:"server"`
	Module string `mapstructure:"module" json:"module" yaml:"module"`
	AiPath string `mapstructure:"ai-path" json:"ai-path" yaml:"ai-path"`
}

description

配置名类型说明
webstring前端项目路径
rootstring项目根目录,自动适配,请不要手动配置
serverstring服务端项目路径
modulestringGo模块名称
ai-pathstringAI相关路径