config.go 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. package config
  2. import "time"
  3. type Config struct {
  4. Log Log `mapstructure:"log" json:"log" yaml:"log"`
  5. Serve Serve `mapstructure:"serve" json:"serve" yaml:"serve"`
  6. Mysql Mysql `mapstructure:"mysql" json:"mysql" yaml:"mysql"`
  7. Redis Redis `mapstructure:"redis" json:"redis" yaml:"redis"`
  8. AliOss AliOss `mapstructure:"ali-oss" json:"ali-oss" yaml:"ali-oss"`
  9. EsClient EsClient `mapstructure:"es_client" json:"es_client" yaml:"es_client"`
  10. Mongo Mongo `mapstructure:"mongo" json:"mongo" yaml:"mongo"`
  11. EtaChartLib EtaChartLib `mapstructure:"eta_chart_lib" json:"eta_chart_lib" yaml:"eta_chart_lib"`
  12. System System `mapstructure:"system" json:"system" yaml:"system"`
  13. }
  14. // Serve gin服务配置
  15. type Serve struct {
  16. Port int `mapstructure:"port" json:"port" yaml:"port" description:"gin开启监听http服务的端口"`
  17. RunMode string `mapstructure:"run-mode" json:"run-mode" yaml:"run-mode" description:"gin运行模式的默认,枚举值:debug,release"`
  18. UseRedis bool `mapstructure:"use-redis" json:"use-redis" yaml:"use-redis" description:"是否使用redis"`
  19. AppName string `mapstructure:"app-name" json:"app-name" yaml:"app-name" description:"项目名称"`
  20. StaticDir string `mapstructure:"static-dir" json:"static-dir" yaml:"static-dir" description:"上传的文件存储目录地址"`
  21. UseMongo bool `mapstructure:"use-mongo" json:"use-mongo" yaml:"use-mongo" description:"是否使用mongo"`
  22. }
  23. // Log 日志配置
  24. type Log struct {
  25. Prefix string `mapstructure:"prefix" json:"prefix" yaml:"prefix" description:"日志输出前缀"`
  26. LogFile bool `mapstructure:"log-file" json:"logFile" yaml:"log-file" description:""`
  27. Stdout string `mapstructure:"stdout" json:"stdout" yaml:"stdout" description:""`
  28. FileStdout string `mapstructure:"file-stdout" json:"file-stdout" yaml:"file-stdout" description:""`
  29. SaveMaxDay int `mapstructure:"save-max-day" json:"save-max-day" yaml:"save-max-day" description:"最多保留多少天的日志"`
  30. CuttingDay int `mapstructure:"cutting-day" json:"cutting-day" yaml:"cutting-day" description:"相隔几天切割文件"`
  31. LogDirPath string `mapstructure:"log-dir-path" json:"log-dir-path" yaml:"log-dir-path" description:"日志目录"`
  32. LogSoftLink string `mapstructure:"log-soft-link" json:"log-soft-link" yaml:"log-soft-link" description:"日志软链接"`
  33. BinlogDirPath string `mapstructure:"binlog-dir-path" json:"binlog-dir-path" yaml:"binlog-dir-path" description:"binlog日志目录"`
  34. BinlogSoftLink string `mapstructure:"binlog-soft-link" json:"binlog-soft-link" yaml:"binlog-soft-link" description:"binlog日志软链接"`
  35. FilelogDirPath string `mapstructure:"filelog-dir-path" json:"filelog-dir-path" yaml:"filelog-dir-path" description:"用户自主记录的日志目录"`
  36. FilelogSoftLink string `mapstructure:"filelog-soft-link" json:"filelog-soft-link" yaml:"filelog-soft-link" description:"用户自主记录的日志软链接"`
  37. MongologDirPath string `mapstructure:"mongolog-dir-path" json:"mongolog-dir-path" yaml:"mongolog-dir-path" description:"mongo的日志目录"`
  38. MongologSoftLink string `mapstructure:"mongolog-soft-link" json:"mongolog-soft-link" yaml:"mongolog-soft-link" description:"mongo的日志软链接"`
  39. }
  40. // Mysql 数据库配置
  41. type Mysql struct {
  42. //LogMode bool `mapstructure:"log-mode" json:"log-mode" yaml:"log-mode" description:"是否开启日志"`
  43. Stdout bool `mapstructure:"stdout" json:"stdout" yaml:"stdout" description:"日志是否输出在控制台"`
  44. DefaultDsnAliasName string `mapstructure:"default-dsn-alias-name" json:"default-dsn-alias-name" yaml:"default-dsn-alias-name" description:"默认的数据库连接别名"`
  45. List []MysqlConn `mapstructure:"list" json:"list" yaml:"list" description:"数据库链接配置列表"`
  46. }
  47. // MysqlConn mysql数据链接配置
  48. type MysqlConn struct {
  49. Dsn string `mapstructure:"dsn" json:"dsc" yaml:"dsn" description:"数据库连接配置"`
  50. AliasName string `mapstructure:"alias-name" json:"alias-name" yaml:"alias-name" description:"数据库别名"`
  51. MaxIdleConns int `mapstructure:"max-idle-conns" json:"max-idle-conns" yaml:"max-idle-conns" description:"最大空闲连接"`
  52. MaxOpenConns int `mapstructure:"max-open-conns" json:"max-open-conns" yaml:"max-open-conns" description:"最大连接数"`
  53. }
  54. // Redis redis配置
  55. type Redis struct {
  56. Address string `mapstructure:"address" json:"address" yaml:"address" description:"redis服务链接地址"`
  57. Password string `mapstructure:"password" json:"password" yaml:"password" description:"redis服务密码"`
  58. Db int `mapstructure:"db" json:"db" yaml:"db" description:"默认使用的redis库"`
  59. }
  60. // AliOss aliOss配置
  61. type AliOss struct {
  62. BucketName string `mapstructure:"bucket-name" json:"bucket-name" yaml:"bucket-name"`
  63. EndPoint string `mapstructure:"end-point" json:"end-point" yaml:"end-point"`
  64. ImgHost string `mapstructure:"img-host" json:"img-host" yaml:"img-host" description:"阿里oss主机地址"`
  65. UploadDir string `mapstructure:"upload-dir" json:"upload-dir" yaml:"upload-dir" description:"图片上传的文件目录"`
  66. UploadAudioDir string `mapstructure:"upload-audio-dir" json:"upload-audio-dir" yaml:"upload-audio-dir" description:"视频上传的文件目录"`
  67. AccessKeyId string `mapstructure:"access-key-id" json:"access-key-id" yaml:"access-key-id" description:"access-key-id"`
  68. AccessKeySecret string `mapstructure:"access-key-secret" json:"access-key-secret" yaml:"access-key-secret" description:"access-key-secret"`
  69. }
  70. // EsClient es客户端配置
  71. type EsClient struct {
  72. // 终端地址
  73. Endpoints string `json:"endpoints" yaml:"endpoints"`
  74. // 用户
  75. Username string `json:"username" yaml:"username"`
  76. // 密码
  77. Password string `json:"password" yaml:"password"`
  78. // 超时时间,单位ms
  79. Timeout time.Duration `json:"timeout" yaml:"timeout"`
  80. // es日志目录
  81. Log string `json:"log" yaml:"log"`
  82. // 索引前缀
  83. Prefix string `json:"prefix" yaml:"prefix"`
  84. }
  85. // Mongo
  86. // @Description: mongo配置
  87. type Mongo struct {
  88. Url string `mapstructure:"url" json:"url" yaml:"url" description:"mongo地址url"`
  89. AuthMechanism string `mapstructure:"auth_mechanism" json:"auth_mechanism" yaml:"auth_mechanism" description:"鉴权方式"`
  90. AuthSource string `mapstructure:"auth-source" json:"auth-source" yaml:"auth-source" description:"认证数据库"`
  91. Database string `mapstructure:"database" json:"database" yaml:"database" description:"默认数据库"`
  92. Username string `mapstructure:"username" json:"username" yaml:"username" description:"用户名"`
  93. Password string `mapstructure:"password" json:"password" yaml:"password" description:"密码"`
  94. }
  95. type EtaChartLib struct {
  96. ServerUrl string `mapstructure:"server_url" json:"server_url" yaml:"server_url" description:"项目请求地址"`
  97. AppNameEn string `mapstructure:"app_name_en" json:"app_name_en" yaml:"app_name_en" description:"项目名称"`
  98. Md5Key string `mapstructure:"md5_key" json:"md5_key" yaml:"md5_key" description:"项目密钥"`
  99. }
  100. type System struct {
  101. ChromePath string `mapstructure:"chrome-path" json:"chrome-path" yaml:"chrome-path" description:"chrome路径"`
  102. }