Skip to content

配置文件

JWT

yaml

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

struct

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

description

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

Zap

yaml

# zap logger configuration
zap:
  level: 'info'
  format: 'console'
  prefix: '[GIN-VUE-ADMIN]'
  director: 'log'
  link-name: 'latest_log'
  show-line: true
  encode-level: 'LowercaseColorLevelEncoder'
  stacktrace-key: 'stacktrace'
  log-in-console: true

struct

type Zap struct {
	Level         string `mapstructure:"level" json:"level" yaml:"level"`
	Format        string `mapstructure:"format" json:"format" yaml:"format"`
	Prefix        string `mapstructure:"prefix" json:"prefix" yaml:"prefix"`
	Director      string `mapstructure:"director" json:"director"  yaml:"director"`
	LinkName      string `mapstructure:"link-name" json:"linkName" yaml:"link-name"`
	ShowLine      bool   `mapstructure:"show-line" json:"showLine" yaml:"showLine"`
	EncodeLevel   string `mapstructure:"encode-level" json:"encodeLevel" yaml:"encode-level"`
	StacktraceKey string `mapstructure:"stacktrace-key" json:"stacktraceKey" yaml:"stacktrace-key"`
	LogInConsole  bool   `mapstructure:"log-in-console" json:"logInConsole" yaml:"log-in-console"`
}

description

配置名类型说明
levelstringlevel的模式的详细说明,请看zap官方文档
info: info模式,无错误的堆栈信息,只输出信息
debug:debug模式,有错误的堆栈详细信息
warn:warn模式
error: error模式,有错误的堆栈详细信息
dpanic: dpanic模式
panic: panic模式
fatal: fatal模式
formatstringconsole: 控制台形式输出日志 json: json格式输出日志
prefixstring日志的前缀
directorstring存放日志的文件夹,修改即可,不需要手动创建
link_namestring在server目录下会生成一个link_name的软连接文件,链接的是director配置项的最新日志文件
show_linebool显示行号, 默认为true,不建议修改
encode_levelstringLowercaseLevelEncoder:小写
LowercaseColorLevelEncoder:小写带颜色
CapitalLevelEncoder: 大写
CapitalColorLevelEncoder: 大写带颜色
stacktrace_keystring堆栈的名称,即在json格式输出日志时的josn的key
log_in_consolebool是否输出到控制台,默认为true
  • 开发环境 || 调试环境配置建议
    • 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

# redis configuration
redis:
  db: 0
  addr: '127.0.0.1:6379'
  password: ''

struct

type Redis struct {
	DB       int    `mapstructure:"db" json:"db" yaml:"db"`
	Addr     string `mapstructure:"addr" json:"addr" yaml:"addr"`
	Password string `mapstructure:"password" json:"password" yaml:"password"`
}

description

配置名类型说明
dbintredis的哪个数据库
addrstringredis连接地址及端口
passwordstring密码

Email

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'

struct

type Email struct {
	To       string `mapstructure:"to" json:"to" yaml:"to"`
	Port     int    `mapstructure:"port" json:"port" yaml:"port"`
	From     string `mapstructure:"from" json:"from" yaml:"from"`
	Host     string `mapstructure:"host" json:"host" yaml:"host"`
	IsSSL    bool   `mapstructure:"is-ssl" json:"isSSL" yaml:"is-ssl"`
	Secret   string `mapstructure:"secret" json:"secret" yaml:"secret"`
	Nickname string `mapstructure:"nickname" json:"nickname" yaml:"nickname"`
}

description

配置名类型说明
tostring邮件接收者,可以是多个,
以英文逗号(,)进行区分,最好别带空格,如果是一个邮箱最后请不要加英文逗号(,)
portint邮件服务端口
fromstring用户名
hoststring邮箱的主服务器地址
is-sslbool是否使用ssl
secretstring密码
nicknamestring对方收到的昵称

Casbin

yaml

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

struct

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

description

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

System

yaml

# system configuration
system:
  env: 'public'  # Change to "develop" to skip authentication for development mode
  addr: 8888
  db-type: 'mysql'
  oss-type: 'local'
  use-multipoint: false
  use-redis: false
  iplimit-count: 15000
  iplimit-time: 3600

struct

type System struct {
	Env           string `mapstructure:"env" json:"env" yaml:"env"`
	Addr          int    `mapstructure:"addr" json:"addr" yaml:"addr"`
	DbType        string `mapstructure:"db-type" json:"dbType" yaml:"db-type"`
	OssType       string `mapstructure:"oss-type" json:"ossType" yaml:"oss-type"`
	UseMultipoint bool   `mapstructure:"use-multipoint" json:"useMultipoint" yaml:"use-multipoint"`
}

description

配置名类型说明
envstring更改为“develop”以跳过开发模式的身份验证
addrint后端端口,默认8888
db-typestring可以使用mysql 后续支持pgsql
oss-typestring可以指定上传头像的oss为local/qiniu/aliyun/minio
local:本地的 local.path 目录
qiniu:七牛云
aliyun与minio可能框架不会集成,需自己添加,或者参考 额外功能
use-multipointbool单点登录,默认为关闭
use-redisbool使用redis,默认为关闭
iplimit-countinttime时间段内同IP最多访问次数,默认为15000
iplimit-timeint限制时间区间,默认为3600

captcha

yaml

# captcha configuration
captcha:
  key-long: 6
  img-width: 240
  img-height: 80

struct

type Captcha struct {
	KeyLong   int `mapstructure:"key-long" json:"keyLong" yaml:"key-long"`
	ImgWidth  int `mapstructure:"img-width" json:"imgWidth" yaml:"img-width"`
	ImgHeight int `mapstructure:"img-height" json:"imgHeight" yaml:"img-height"`
}

description

配置名类型说明
key-longint验证码长度
img-widthint验证码宽度
img-heightint验证码高度

Mysql

yaml

# mysql connect configuration
mysql:
  path: ''
  config: ''
  db-name: ''
  username: ''
  password: ''
  max-idle-conns: 10
  max-open-conns: 100
  log-mode: false
  log-zap: ""

struct

type Mysql struct {
	Path         string `mapstructure:"path" json:"path" yaml:"path"`
	Config       string `mapstructure:"config" json:"config" yaml:"config"`
	Dbname       string `mapstructure:"db-name" json:"dbname" yaml:"db-name"`
	Username     string `mapstructure:"username" json:"username" yaml:"username"`
	Password     string `mapstructure:"password" json:"password" yaml:"password"`
	MaxIdleConns int    `mapstructure:"max-idle-conns" json:"maxIdleConns" yaml:"max-idle-conns"`
	MaxOpenConns int    `mapstructure:"max-open-conns" json:"maxOpenConns" yaml:"max-open-conns"`
	LogMode      string `mapstructure:"log-mode" json:"logMode" yaml:"log-mode"`                  // 开启Gorm全局日志等级
	LogZap       bool   `mapstructure:"log-zap" json:"logZap" yaml:"log-zap"`                    // 是否通过zap写入日志文件
}

description

配置名类型说明
usernamestring用户名
passwordstring密码
pathstringmysql的连接地址及端口
db-namestring数据库名
configstring高级配置
max-idle-connsint设置空闲中的最大连接数
max-open-connsint设置打开到数据库的最大连接数
log-modestring开启Gorm全局日志等级 "silent"、"error"、"warn"、"info" 不填默认info 填入silent可以关闭控制台日志
log-zapbool是否写入zap

Postgresql (研发中)

yaml

# Postgresql connect configuration
pgsql:
  path: ''
  port: ''
  config: ''
  db-name: ''
  username: ''
  password: ''
  max-idle-conns: 10
  max-open-conns: 100
  log-mode: ""
  log-zap: false

struct

type Pgsql struct {
	Path         string `mapstructure:"path" json:"path" yaml:"path"`
	Config       string `mapstructure:"config" json:"config" yaml:"config"`
	Dbname       string `mapstructure:"db-name" json:"dbname" yaml:"db-name"`
	Username     string `mapstructure:"username" json:"username" yaml:"username"`
	Password     string `mapstructure:"password" json:"password" yaml:"password"`
	MaxIdleConns int    `mapstructure:"max-idle-conns" json:"maxIdleConns" yaml:"max-idle-conns"`
	MaxOpenConns int    `mapstructure:"max-open-conns" json:"maxOpenConns" yaml:"max-open-conns"`
	LogMode      string `mapstructure:"log-mode" json:"logMode" yaml:"log-mode"`                  // 开启Gorm全局日志等级
	LogZap       bool   `mapstructure:"log-zap" json:"logZap" yaml:"log-zap"`                    // 是否通过zap写入日志文件
}

description

配置名类型说明
usernamestring用户名
passwordstring密码
pathstringmysql的连接地址及端口
db-namestring数据库名
configstring高级配置
max-idle-connsint设置空闲中的最大连接数
max-open-connsint设置打开到数据库的最大连接数
log-modestring开启Gorm全局日志等级 "silent"、"error"、"warn"、"info" 不填默认info 填入silent可以关闭控制台日志
log-zapbool是否写入zap

Local

yaml

# local configuration
local:
  path: 'uploads/file'

struct

type Local struct {
	Path string `mapstructure:"path" json:"path" yaml:"path" `
}

description

配置名类型说明
Pathstring本地存放路径

Qiniu

yaml

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

struct

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

autocode configuration

autocode:
  transfer-restart: true
  # root 自动适配项目根目录
  # 请不要手动配置,他会在项目加载的时候识别出根路径
  # 除root外请使用相对路径配置
  root: ""
  server: /server      #服务端所在位置
  server-api: /api/v1/autocode  #服务端api所在位置
  server-initialize: /initialize  #服务端initialize所在位置
  server-model: /model/autocode  #服务端model所在位置
  server-request: /model/autocode/request/  #服务端request所在位置
  server-router: /router/autocode  #服务端router所在位置
  server-service: /service/autocode  #服务端service所在位置
  web: /web/src     
  web-api: /api
  web-form: /view
  web-table: /view
配置名类型说明
rootstringroot 自动适配项目根目录 请不要手动配置(手动配置也无效),他会在项目加载的时候识别出根路径 除root外请使用相对路径配置
serverstring服务端所在位置
server-apistring服务端api文件所在位置
server-initializebool服务端initialize文件所在位置
server-modelstring服务端model文件所在位置
server-requeststring服务端requset文件所在位置
server-routerbool服务端router件所在位置
server-servicebool服务端service文件所在位置
webbool前端src文件夹位置
web-apibool前端自动生成的api所在位置
web-formbool前端自动生成的表单所在位置
web-tablebool前端自动生成的表格所在位置

Copyright © 2020-2024 Flipped-aurora Open Source Community