zhangqian
2023-08-19 94a8c84e8d29300644a689ce2cd6f537f1993224
conf/config.go
@@ -5,7 +5,7 @@
   "apsClient/pkg/logx"
   "apsClient/pkg/mysqlx"
   "apsClient/pkg/redisx"
   "flag"
   "apsClient/pkg/sqlitex"
   "github.com/spf13/viper"
   "log"
)
@@ -23,21 +23,6 @@
)
type (
   Captcha struct {
      KeyLong            int // 验证码长度
      ImgWidth           int // 验证码宽度
      ImgHeight          int // 验证码高度
      OpenCaptcha        int // 防爆破验证码开启此数,0代表每次登录都需要验证码,其他数字代表错误密码次数,如3代表错误三次后出现验证码
      OpenCaptchaTimeOut int // 防爆破验证码超时时间,单位:s(秒)
   }
   JWT struct {
      SigningKey  string // jwt签名
      ExpiresTime string // 过期时间
      BufferTime  string // 缓冲时间
      Issuer      string // 签发者
   }
   System struct {
      Env           string // 环境值 develop test public
      Port          int    // 端口
@@ -48,6 +33,7 @@
      LimitTimeIP   int
      RouterPrefix  string // 路由前缀
      SudoPassword  string // sudo密码
      DeviceId      string //设备id
   }
   Etcd struct {
@@ -80,6 +66,12 @@
      ApsServer string
   }
   nsqConf struct {
      NodeId         string
      NsqdAddr       string
      NsqlookupdAddr string
   }
   config struct {
      // 系统配置
      System System
@@ -90,14 +82,11 @@
      // mysql配置
      Mysql mysqlx.Conf
      // mysql配置
      Sqlite sqlitex.Conf
      // redis配置
      Redis redisx.Conf
      // 验证码
      Captcha Captcha
      // JWT配置
      JWT JWT
      // etcd配置
      Etcd Etcd
@@ -110,6 +99,8 @@
      //Services Address
      Services Services
      NsqConf nsqConf
   }
)
@@ -119,14 +110,6 @@
)
func init() {
   var configFile string
   flag.StringVar(&configFile, "config", "", "config file in json")
   flag.Parse()
   if len(configFile) > 0 {
      configName = configFile
   }
   Viper = viper.New()
   Viper.SetConfigName(configName)
   for _, path := range configPaths {
@@ -157,8 +140,6 @@
   log.Printf("   System:                %+v", Conf.System)
   log.Printf("   Log:                   %+v", Conf.Log)
   log.Printf("   Mysql:                 %+v", Conf.Mysql)
   log.Printf("   Captcha:               %+v", Conf.Captcha)
   log.Printf("   JWT:                   %+v", Conf.JWT)
   log.Printf("   etcd:                  %+v", Conf.Etcd)
   log.Printf("   rancher:               %+v", Conf.Rancher)
   log.Printf("   k8s:                   %+v", Conf.K8s)