config.go 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. package config
  2. type Config struct {
  3. Log Log `mapstructure:"log" json:"log" yaml:"log"`
  4. Serve Serve `mapstructure:"serve" json:"serve" yaml:"serve"`
  5. Mysql Mysql `mapstructure:"mysql" json:"mysql" yaml:"mysql"`
  6. Redis Redis `mapstructure:"redis" json:"redis" yaml:"redis"`
  7. Smm Smm `mapstructure:"smm" json:"smm" yaml:"smm"`
  8. Xiangyu Xiangyu `mapstructure:"xiangyu" json:"xiangyu" yaml:"xiangyu"`
  9. Email Email `mapstructure:"email" json:"email" yaml:"email"`
  10. Oss Oss `mapstructure:"oss" json:"oss" yaml:"oss"`
  11. }
  12. // Serve gin服务配置
  13. type Serve struct {
  14. Port int `mapstructure:"port" json:"port" yaml:"port" description:"gin开启监听http服务的端口"`
  15. RunMode string `mapstructure:"run-mode" json:"run-mode" yaml:"run-mode" description:"gin运行模式的默认,枚举值:debug,release"`
  16. UseRedis bool `mapstructure:"use-redis" json:"use-redis" yaml:"use-redis" description:"是否使用redis"`
  17. AppName string `mapstructure:"app-name" json:"app-name" yaml:"app-name" description:"项目名称"`
  18. StaticDir string `mapstructure:"static-dir" json:"static-dir" yaml:"static-dir" description:"上传的文件存储目录地址"`
  19. AppNameEn string `mapstructure:"app-name-en" json:"app-name-en" yaml:"app-name-en" description:"项目名称英文"`
  20. Md5Key string `mapstructure:"md5-key" json:"md5-key" yaml:"md5-key" description:"Md5密钥"`
  21. DesKey string `mapstructure:"des-key" json:"des-key" yaml:"des-key" description:"Des密钥"`
  22. IsStopTask bool `mapstructure:"is-stop-task" json:"is-stop-task" yaml:"is-stop-task" description:"是否停止任务,此功能用于多服务器部署时,定时任务只需一台服务器执行,其他服务器不执行的情况下设置为true"`
  23. }
  24. // Log 日志配置
  25. type Log struct {
  26. Prefix string `mapstructure:"prefix" json:"prefix" yaml:"prefix" description:"日志输出前缀"`
  27. LogFile bool `mapstructure:"log-file" json:"logFile" yaml:"log-file" description:""`
  28. Stdout string `mapstructure:"stdout" json:"stdout" yaml:"stdout" description:""`
  29. FileStdout string `mapstructure:"file-stdout" json:"file-stdout" yaml:"file-stdout" description:""`
  30. SaveMaxDay int `mapstructure:"save-max-day" json:"save-max-day" yaml:"save-max-day" description:"最多保留多少天的日志"`
  31. CuttingDay int `mapstructure:"cutting-day" json:"cutting-day" yaml:"cutting-day" description:"相隔几天切割文件"`
  32. LogDirPath string `mapstructure:"log-dir-path" json:"log-dir-path" yaml:"log-dir-path" description:"日志目录"`
  33. LogSoftLink string `mapstructure:"log-soft-link" json:"log-soft-link" yaml:"log-soft-link" description:"日志软链接"`
  34. BinlogDirPath string `mapstructure:"binlog-dir-path" json:"binlog-dir-path" yaml:"binlog-dir-path" description:"binlog日志目录"`
  35. BinlogSoftLink string `mapstructure:"binlog-soft-link" json:"binlog-soft-link" yaml:"binlog-soft-link" description:"binlog日志软链接"`
  36. FilelogDirPath string `mapstructure:"filelog-dir-path" json:"filelog-dir-path" yaml:"filelog-dir-path" description:"用户自主记录的日志目录"`
  37. FilelogSoftLink string `mapstructure:"filelog-soft-link" json:"filelog-soft-link" yaml:"filelog-soft-link" description:"用户自主记录的日志软链接"`
  38. }
  39. // Mysql 数据库配置
  40. type Mysql struct {
  41. //LogMode bool `mapstructure:"log-mode" json:"log-mode" yaml:"log-mode" description:"是否开启日志"`
  42. Stdout bool `mapstructure:"stdout" json:"stdout" yaml:"stdout" description:"日志是否输出在控制台"`
  43. DefaultDsnAliasName string `mapstructure:"default-dsn-alias-name" json:"default-dsn-alias-name" yaml:"default-dsn-alias-name" description:"默认的数据库连接别名"`
  44. List []MysqlConn `mapstructure:"list" json:"list" yaml:"list" description:"数据库链接配置列表"`
  45. }
  46. // MysqlConn mysql数据链接配置
  47. type MysqlConn struct {
  48. Dsn string `mapstructure:"dsn" json:"dsc" yaml:"dsn" description:"数据库连接配置"`
  49. AliasName string `mapstructure:"alias-name" json:"alias-name" yaml:"alias-name" description:"数据库别名"`
  50. MaxIdleConns int `mapstructure:"max-idle-conns" json:"max-idle-conns" yaml:"max-idle-conns" description:"最大空闲连接"`
  51. MaxOpenConns int `mapstructure:"max-open-conns" json:"max-open-conns" yaml:"max-open-conns" description:"最大连接数"`
  52. }
  53. // Redis redis配置
  54. type Redis struct {
  55. Address string `mapstructure:"address" json:"address" yaml:"address" description:"redis服务链接地址"`
  56. Password string `mapstructure:"password" json:"password" yaml:"password" description:"redis服务密码"`
  57. Db int `mapstructure:"db" json:"db" yaml:"db" description:"默认使用的redis库"`
  58. ServeType string `mapstructure:"serve-type" json:"serve-type" yaml:"serve-type" description:"redis服务类型,单机或者cluster;默认单机"`
  59. }
  60. // Smm smm配置
  61. type Smm struct {
  62. Username string `mapstructure:"username" json:"username" yaml:"username" description:"smm账号"`
  63. Password string `mapstructure:"password" json:"password" yaml:"password" description:"smm密码"`
  64. }
  65. // Xiangyu 象屿的配置
  66. type Xiangyu struct {
  67. SystemCode string `mapstructure:"system-code" json:"system-code" yaml:"system-code" description:"系统编码"`
  68. UserSyncTarget string `mapstructure:"user-sync-target" json:"user-sync-target" yaml:"user-sync-target" description:"用户同步平台编码"`
  69. UserSyncHost string `mapstructure:"user-sync-host" json:"user-sync-host" yaml:"user-sync-host" description:"用户同步平台地址"`
  70. UserAuthHost string `mapstructure:"user-auth-host" json:"user-auth-host" yaml:"user-auth-host" description:"用户认证平台地址"`
  71. UserSyncAuthUserName string `mapstructure:"user-sync-auth-user-name" json:"user-sync-auth-user-name" yaml:"user-sync-auth-user-name" description:"用户统一身份的鉴权username"`
  72. UserSyncAuthPwd string `mapstructure:"user-sync-auth-pwd" json:"user-sync-auth-pwd" yaml:"user-sync-auth-pwd" description:"用户统一身份的鉴权password"`
  73. UserKey string `mapstructure:"user-key" json:"user-key" yaml:"user-key" description:"统一平台秘钥"`
  74. DefaultRoleId int `mapstructure:"default-role-id" json:"default-role-id" yaml:"default-role-id" description:"默认的角色id"`
  75. IndexSyncHost string `mapstructure:"index-sync-host" json:"index-sync-host" yaml:"index-sync-host" description:"指标同步平台地址"`
  76. IndexSyncAuthUserName string `mapstructure:"index-sync-auth-user-name" json:"index-sync-auth-user-name" yaml:"index-sync-auth-user-name" description:"用户统一身份的鉴权username"`
  77. IndexSyncAuthPwd string `mapstructure:"index-sync-auth-pwd" json:"index-sync-auth-pwd" yaml:"index-sync-auth-pwd" description:"用户统一身份的鉴权password"`
  78. IndexKey string `mapstructure:"index-key" json:"index-key" yaml:"index-key" description:"统一平台秘钥"`
  79. IndexSyncTarget string `mapstructure:"index-sync-target" json:"index-sync-target" yaml:"index-sync-target" description:"指标同步平台编码"`
  80. IndexCrmHost string `mapstructure:"index-crm-host" json:"index-crm-host" yaml:"index-crm-host" description:"crm指标平台地址"`
  81. IndexCrmTarget string `mapstructure:"index-crm-target" json:"index-crm-target" yaml:"index-crm-target" description:"crm指标平台编码"`
  82. }
  83. type Email struct {
  84. Host string `mapstructure:"host" json:"host" yaml:"host" description:"邮件服务器"`
  85. Port int `mapstructure:"port" json:"port" yaml:"port" description:"邮件服务器端口"`
  86. UserName string `mapstructure:"username" json:"username" yaml:"username" description:"邮件服务器用户名"`
  87. Password string `mapstructure:"password" json:"password" yaml:"password" description:"邮件服务器密码"`
  88. Folder string `mapstructure:"folder" json:"folder" yaml:"folder" description:"邮件服务器文件夹"`
  89. ReadBatchSize int `mapstructure:"read-batch-size" json:"read-batch-size" yaml:"read-batch-size" description:"邮件读取批次"`
  90. StartReadIndex int `mapstructure:"start-read-index" json:"start-read-index" yaml:"start-read-index" description:"邮件开始读取的序号"`
  91. SyncEmailTime string `mapstructure:"sync-email-time" json:"sync-email-time" yaml:"sync-email-time" description:"邮件同步时间"`
  92. IgnoreEmail []string `mapstructure:"ignore-email" json:"ignore-email" yaml:"ignore-email" description:"邮件过滤,不读取这些邮箱"`
  93. IgnoreEmailCaseSensitive []string `mapstructure:"ignore-email-case-sensitive" json:"ignore-email-case-sensitive" yaml:"ignore-email-case-sensitive" description:"邮件过滤,不读取这些邮箱,大小写敏感"`
  94. IgnoreEmailAddress []string `mapstructure:"ignore-email-address" json:"ignore-email-address" yaml:"ignore-email-address" description:"邮件过滤,不读取这些邮箱,大小写敏感"`
  95. IgnoreEmailAddressCaseSensitive []string `mapstructure:"ignore-email-address-case-sensitive" json:"ignore-email-address-case-sensitive" yaml:"ignore-email-address-case-sensitive" description:"邮件过滤,不读取这些邮箱,大小写敏感"`
  96. IgnoreEmailTitle []string `mapstructure:"ignore-email-title" json:"ignore-email-title" yaml:"ignore-email-title" description:"邮件过滤,不读取这些标题"`
  97. IgnoreEmailTitleCaseSensitive []string `mapstructure:"ignore-email-title-case-sensitive" json:"ignore-email-title-case-sensitive" yaml:"ignore-email-title-case-sensitive" description:"邮件过滤,不读取这些标题,大小写敏感"`
  98. }
  99. type Oss struct {
  100. ObjectStorageClient string `mapstructure:"object-storage-client" json:"object-storage-client" yaml:"object-storage-client" description:"oss类型,取值:oss minio,s3,默认oss"`
  101. EndPoint string `mapstructure:"end-point" json:"end-point" yaml:"end-point" description:"oss服务地址"`
  102. BackEndPoint string `mapstructure:"back-end-point" json:"back-end-point" yaml:"back-end-point" description:"oss服务地址(用于内网)"`
  103. AccessKeyId string `mapstructure:"access-key-id" json:"access-key-id" yaml:"access-key-id" description:"oss服务access-key-id"`
  104. AccessKeySecret string `mapstructure:"access-key-secret" json:"access-key-secret" yaml:"access-key-secret" description:"oss服务access-key-secret"`
  105. BucketName string `mapstructure:"bucket-name" json:"bucket-name" yaml:"bucket-name" description:"oss服务bucketname"`
  106. RegionId string `mapstructure:"region-id" json:"region-id" yaml:"region-id" description:"oss服务region-id"`
  107. ImgHost string `mapstructure:"img-host" json:"img-host" yaml:"img-host" description:"oss服务imghost"`
  108. UploadDir string `mapstructure:"upload-dir" json:"upload-dir" yaml:"upload-dir" description:"oss服务上传路径"`
  109. Port string `mapstructure:"port" json:"port" yaml:"port" description:"oss服务端口"`
  110. ForceStyle bool `mapstructure:"force-style" json:"force-style" yaml:"force-style" description:"oss服务是否强制使用style,默认是True"`
  111. Protocol string `mapstructure:"protocol" json:"protocol" yaml:"protocol" description:"oss服务协议,默认是http"`
  112. DisableSSL bool `mapstructure:"disable-ssl" json:"disable-ssl" yaml:"disable-ssl" description:"是否禁用ssl"`
  113. OpenAcl bool `mapstructure:"open-acl" json:"open-acl" yaml:"open-acl" description:"是否开启acl"`
  114. ResourceProxyUrl string `mapstructure:"resource-proxy-url" json:"resource-proxy-url" yaml:"resource-proxy-url" description:"资源代理地址"`
  115. Ram OssRam `mapstructure:"ram" json:"ram" yaml:"ram"`
  116. }
  117. type OssRam struct {
  118. AccessKeyId string `mapstructure:"access-key-id" json:"access-key-id" yaml:"access-key-id" description:"oss服务access-key-id"`
  119. AccessKeySecret string `mapstructure:"access-key-secret" json:"access-key-secret" yaml:"access-key-secret" description:"oss服务access-key-secret"`
  120. StsScheme string `mapstructure:"sts-scheme" json:"sts-scheme" yaml:"sts-scheme" description:"oss服务sts-scheme"`
  121. RoleArn string `mapstructure:"role-arn" json:"role-arn" yaml:"role-arn" description:"oss服务role-arn"`
  122. RoleSessionName string `mapstructure:"role-session-name" json:"role-session-name" yaml:"role-session-name" description:"oss服务role-session-name"`
  123. STSTokenCacheKey string `mapstructure:"sts-token-cache-key" json:"sts-token-cache-key" yaml:"sts-token-cache-key" description:"oss服务sts-token-cache-key(缓存key,用于获取后短期内不再重复获取)"`
  124. }