global.go 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. package model
  2. import "fmt"
  3. type Server struct {
  4. JWT JWT `mapstructure:"jwt" json:"jwt" yaml:"jwt"` // jwt
  5. Zap Zap `mapstructure:"zap" json:"zap" yaml:"zap"` // zap log
  6. Email Email `mapstructure:"email" json:"email" yaml:"email"` // email
  7. FsLogin FsLogin `mapstructure:"fs-login" json:"fs-login" yaml:"fs-login"` // 飞书登录
  8. System System `mapstructure:"system" json:"system" yaml:"system"` // 系统变量
  9. SrcRootPath string `mapstructure:"src-root" json:"src-root" yaml:"src-root"` // 资源根目录
  10. NsqList []Nsq `mapstructure:"nsq-list" json:"nsq-list" yaml:"nsq-list"` // nsq
  11. DbLogZap bool `mapstructure:"db-log-zap" json:"db-log-zap" yaml:"db-log-zap"` // db日志
  12. DBList []Mysql `mapstructure:"db-list" json:"db-list" yaml:"db-list"` // mysql
  13. RdsList []Redis `mapstructure:"redis-list" json:"redis-list" yaml:"redis-list"` // redis
  14. Excel Excel `mapstructure:"excel" json:"excel" yaml:"excel"` // excel 配置
  15. Timer Timer `mapstructure:"timer" json:"timer" yaml:"timer"` // 定时器
  16. Cors CORS `mapstructure:"cors" json:"cors" yaml:"cors"` // 跨域配置
  17. }
  18. type JWT struct {
  19. SigningKey string `mapstructure:"signing-key" json:"signing-key" yaml:"signing-key"` // jwt签名
  20. ExpiresTime int64 `mapstructure:"expires-time" json:"expires-time" yaml:"expires-time"` // 过期时间
  21. BufferTime int64 `mapstructure:"buffer-time" json:"buffer-time" yaml:"buffer-time"` // 缓冲时间
  22. Issuer string `mapstructure:"issuer" json:"issuer" yaml:"issuer"` // 签发者
  23. }
  24. type Zap struct {
  25. Format string `mapstructure:"format" json:"format" yaml:"format"` // 输出
  26. Prefix string `mapstructure:"prefix" json:"prefix" yaml:"prefix"` // 日志前缀
  27. Director string `mapstructure:"director" json:"director" yaml:"director"` // 日志文件夹
  28. ShowLine bool `mapstructure:"show-line" json:"show-line" yaml:"show-line"` // 显示行
  29. StacktraceKey string `mapstructure:"stacktrace-key" json:"stacktrace-key" yaml:"stacktrace-key"` // 栈名
  30. LogInConsole bool `mapstructure:"log-in-console" json:"log-in-console" yaml:"log-in-console"` // 输出控制台
  31. }
  32. type Email struct {
  33. To string `mapstructure:"to" json:"to" yaml:"to"` // 收件人:多个以英文逗号分隔
  34. Port int `mapstructure:"port" json:"port" yaml:"port"` // 端口
  35. From string `mapstructure:"from" json:"from" yaml:"from"` // 收件人
  36. Host string `mapstructure:"host" json:"host" yaml:"host"` // 服务器地址
  37. IsSSL bool `mapstructure:"is-ssl" json:"is-ssl" yaml:"is-ssl"` // 是否SSL
  38. Secret string `mapstructure:"secret" json:"secret" yaml:"secret"` // 密钥
  39. Nickname string `mapstructure:"nickname" json:"nickname" yaml:"nickname"` // 昵称
  40. }
  41. type FsLogin struct {
  42. AppID string `mapstructure:"appID" json:"appID" yaml:"appID"` // 飞书应用APPID
  43. AppSecret string `mapstructure:"appSecret" json:"appSecret" yaml:"appSecret"` // 飞书应用AppSecret
  44. RedirectUri string `mapstructure:"redirectUri" json:"redirectUri" yaml:"redirectUri"` // 回调链接
  45. }
  46. type Nsq struct {
  47. Addr string `mapstructure:"addr" json:"addr" yaml:"addr"` // 服务器地址:端口
  48. }
  49. type Casbin struct {
  50. ModelPath string `mapstructure:"model-path" json:"model-path" yaml:"model-path"` // 存放casbin模型的相对路径
  51. }
  52. type System struct {
  53. App string `mapstructure:"app" json:"app" yaml:"app"` // 项目代码
  54. Env string `mapstructure:"env" json:"env" yaml:"env"` // 环境值
  55. Addr int `mapstructure:"addr" json:"addr" yaml:"addr"` // 端口值
  56. DbType string `mapstructure:"db-type" json:"db-type" yaml:"db-type"` // 数据库类型:db(默认)|sqlite|sqlserver|postgresql
  57. UseMultipoint bool `mapstructure:"use-multipoint" json:"use-multipoint" yaml:"use-multipoint"` // 多点登录拦截
  58. UseRedis bool `mapstructure:"use-redis" json:"use-redis" yaml:"use-redis"` // 使用redis
  59. LimitCountIP int `mapstructure:"iplimit-count" json:"iplimit-count" yaml:"iplimit-count"`
  60. LimitTimeIP int `mapstructure:"iplimit-time" json:"iplimit-time" yaml:"iplimit-time"`
  61. }
  62. type Mysql struct {
  63. Disable bool `mapstructure:"disable" json:"disable" yaml:"disable"`
  64. ConnName string `mapstructure:"conn-name" json:"conn-name" yaml:"conn-name"`
  65. Path string `mapstructure:"path" json:"path" yaml:"path"` // 服务器地址:端口
  66. Port string `mapstructure:"port" json:"port" yaml:"port"` // :端口
  67. Config string `mapstructure:"config" json:"config" yaml:"config"` // 高级配置
  68. Dbname string `mapstructure:"db-name" json:"db-name" yaml:"db-name"` // 数据库名
  69. Username string `mapstructure:"username" json:"username" yaml:"username"` // 数据库用户名
  70. Password string `mapstructure:"password" json:"password" yaml:"password"` // 数据库密码
  71. MaxIdleConns int `mapstructure:"max-idle-conns" json:"max-idle-conns" yaml:"max-idle-conns"` // 空闲中的最大连接数
  72. MaxOpenConns int `mapstructure:"max-open-conns" json:"max-open-conns" yaml:"max-open-conns"` // 打开到数据库的最大连接数
  73. }
  74. func (m *Mysql) Dsn() string {
  75. return fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?%s&interpolateParams=true", m.Username, m.Password, m.Path, m.Port, m.Dbname, m.Config)
  76. }
  77. type Redis struct {
  78. Disable bool `mapstructure:"disable" json:"disable" yaml:"disable"`
  79. ConnName string `mapstructure:"conn-name" json:"conn-name" yaml:"conn-name"`
  80. DB int `mapstructure:"db" json:"db" yaml:"db"` // redis的哪个数据库
  81. Addr string `mapstructure:"addr" json:"addr" yaml:"addr"` // 服务器地址:端口
  82. Password string `mapstructure:"password" json:"password" yaml:"password"` // 密码
  83. }
  84. type Local struct {
  85. Path string `mapstructure:"path" json:"path" yaml:"path"` // 本地文件路径
  86. }
  87. type Excel struct {
  88. Dir string `mapstructure:"dir" json:"dir" yaml:"dir"`
  89. }
  90. type Timer struct {
  91. Start bool `mapstructure:"start" json:"start" yaml:"start"` // 是否启用
  92. Spec string `mapstructure:"spec" json:"spec" yaml:"spec"` // CRON表达式
  93. Detail []Detail `mapstructure:"detail" json:"detail" yaml:"detail"`
  94. }
  95. type Detail struct {
  96. TableName string `mapstructure:"tableName" json:"tableName" yaml:"tableName"` // 需要清理的表名
  97. CompareField string `mapstructure:"compareField" json:"compareField" yaml:"compareField"` // 需要比较时间的字段
  98. Interval string `mapstructure:"interval" json:"interval" yaml:"interval"` // 时间间隔
  99. }
  100. type CORS struct {
  101. Mode string `mapstructure:"mode" json:"mode" yaml:"mode"`
  102. Whitelist []CORSWhitelist `mapstructure:"whitelist" json:"whitelist" yaml:"whitelist"`
  103. }
  104. type CORSWhitelist struct {
  105. AllowOrigin string `mapstructure:"allow-origin" json:"allow-origin" yaml:"allow-origin"`
  106. AllowMethods string `mapstructure:"allow-methods" json:"allow-methods" yaml:"allow-methods"`
  107. AllowHeaders string `mapstructure:"allow-headers" json:"allow-headers" yaml:"allow-headers"`
  108. ExposeHeaders string `mapstructure:"expose-headers" json:"expose-headers" yaml:"expose-headers"`
  109. AllowCredentials bool `mapstructure:"allow-credentials" json:"allow-credentials" yaml:"allow-credentials"`
  110. }
  111. type GvaModel struct {
  112. ID int64 `db:"id" from:"id" json:"id"` // 主键ID
  113. CreatedAt int64 `db:"created_at" from:"created_at" json:"created_at"` // 创建时间
  114. UpdatedAt int64 `db:"updated_at" from:"updated_at" json:"updated_at"` // 更新时间
  115. }