From b0f374409775bd30ed8f0dc8d47d015d3edc0abb Mon Sep 17 00:00:00 2001 From: sunty <1172534965@qq.com> Date: 星期二, 03 九月 2024 19:05:52 +0800 Subject: [PATCH] 1、修改查询策略 2、修改地址统计策略 --- config/config.go | 26 +++++++++++++++++++++----- 1 files changed, 21 insertions(+), 5 deletions(-) diff --git a/config/config.go b/config/config.go index ed8e823..f29e1cd 100644 --- a/config/config.go +++ b/config/config.go @@ -15,10 +15,12 @@ } type database struct { - Driver string `mapstructure: "driver"` - Host string `mapstructure: "host"` - Port string `mapstructure: "port"` - Name string `mapstructure: "name"` + Driver string `mapstructure: "driver"` + Host string `mapstructure: "host"` + Port string `mapstructure: "port"` + Name string `mapstructure: "name"` + Username string `mapstructure: "username"` + Password string `mapstructure: "password"` } type elastic struct { @@ -30,6 +32,7 @@ TopHitsSize int `mapstructure: "topHitsSize"` CameraSize int `mapstructure: "cameraSize"` TimeInterval int `mapstructure: "timeInterval"` + BatchSize int `mapstructure: "batchSize"` } type app struct { @@ -38,10 +41,20 @@ LogLevel string `mapstructure: "logLevel"` } +type api struct { + Host string `mapstructure: "host"` + Port string `mapstructure: "port"` + TimeThreshold int `mapstructure:"timeThreshold"` + CsTimes int `mapstructure:"csTimes"` + CsHours int `mapstructure:"csHours"` + AInterval int `mapstructure:"aInterval"` +} + var LogConf = &LogConfig{} var DataBase = &database{} var Elastic = &elastic{} var App = &app{} +var Api = &api{} var LogBasePath string var LogLevel int @@ -49,7 +62,9 @@ var err error viper.SetConfigType("yaml") viper.SetConfigName(env) - viper.AddConfigPath("config") + viper.AddConfigPath("./") + viper.AddConfigPath("./config") + viper.AddConfigPath("../config") err = viper.ReadInConfig() if err != nil { log.Fatal("error on parsing configuration file", err) @@ -57,6 +72,7 @@ viper.UnmarshalKey("elastic", Elastic) viper.UnmarshalKey("database", DataBase) viper.UnmarshalKey("app", App) + viper.UnmarshalKey("api", Api) viper.UnmarshalKey("log", LogConf) logger.SetLevel(LogConf.Level) if viper.GetString("LogBasePath") != "" { -- Gitblit v1.8.0