package utils import ( "fmt" beeLogger "github.com/beego/bee/v2/logger" "github.com/beego/beego/v2/server/web" "strconv" ) var ( RunMode string //运行模式 APP_NAME_CN string MYSQL_URL string //数据库连接 MONGODB_URL string //mongodb连接 MONGODB_COMMUNITY string //mongodb库名 MONGODB_CREDENTIAL string Re error //redis错误 Rc RedisClient //redis缓存 ) // ES配置 var ( ES_URL string // ES服务器地址 ES_USERNAME string // ES账号 ES_PASSWORD string // ES密码 ) // ES索引配置 var ( DATA_INDEX_NAME string //数据指标库索引 CHART_INDEX_NAME string //研究图库索引 ) // 公共api内部服务调用 var ( // EDB_LIB_URL 公共指标库 EDB_LIB_URL string APP_EDB_LIB_NAME_EN string EDB_LIB_Md5_KEY string OpUserId int // 操作人id OpUserRealName string // 操作人真实名称 ) // 弘则 const ( APPID = "SJCrpOPvagscPxEv" SECRET = "gLLjT72uFHQZEFtaFCuoZegD1z2ezfyX" ) // 日志配置 var ( LogPath string //调用过程中的日志存放地址 LogFile string LogDataPath string //调用过程中图表相关的日志存放地址 LogDataFile string BinLogPath string //数据库相关的日志存放地址 BinLogFile string ApiLogPath string //接口请求地址和接口返回值日志存放地址 ApiLogFile string LogMaxDays int //日志最大保留天数 ) var ( EtaBridgeUrl string // 桥接服务地址 EtaBridgeAppNameEn string // 桥接服务英文名称-鉴权用 EtaBridgeMd5Key string // 桥接服务Md5密钥-鉴权用 EtaBridgeDesKey string // 桥接服务Des密钥-解密数据用 SyncUserPath string // 桥接服务-用户同步服务地址 SyncIndexPath string // 桥接服务-指标同步服务地址 ) // 基础配置 var ( DesKey string // 接口返回加密KEY ) // AlarmMsgUrl 报警服务地址 var AlarmMsgUrl string func init() { tmpRunMode, err := web.AppConfig.String("run_mode") if err != nil { panic("配置文件读取run_mode错误 " + err.Error()) } RunMode = tmpRunMode fmt.Println("RunMode:", RunMode) config, err := web.AppConfig.GetSection(RunMode) if err != nil { panic("配置文件读取错误 " + err.Error()) } beeLogger.Log.Info(RunMode + " 模式") // 项目中文名称 appNameCn, err := web.AppConfig.String("app_name_cn") if err != nil { panic(any("配置文件读取app_name_cn错误 " + err.Error())) } APP_NAME_CN = appNameCn MYSQL_URL = config["mysql_url"] MONGODB_URL = config["mongodb_url"] MONGODB_COMMUNITY = config["mongodb_community"] MONGODB_CREDENTIAL = config["mongodb_credential"] // 公共api内部服务调用 { // 公共指标库相关 EDB_LIB_URL = config["edb_lib_url"] APP_EDB_LIB_NAME_EN = config["app_edb_lib_name_en"] EDB_LIB_Md5_KEY = config["edb_lib_md5_key"] opUserIdStr := config["op_user_id"] if opUserIdStr != `` { OpUserId, err = strconv.Atoi(opUserIdStr) if err != nil { panic("配置文件中操作人配置错误 " + err.Error()) } } OpUserRealName = config["op_user_real_name"] } //日志配置 { LogPath = config["log_path"] LogFile = config["log_file"] LogDataPath = config["log_data_path"] LogDataFile = config["log_data_file"] BinLogPath = config["binlog_path"] BinLogFile = config["binlog_file"] ApiLogPath = config["apilog_path"] ApiLogFile = config["apilog_file"] logMaxDaysStr := config["log_max_day"] LogMaxDays, _ = strconv.Atoi(logMaxDaysStr) } { // 报警服务地址 AlarmMsgUrl = config["alarm_msg_url"] } // 初始化缓存 redisClient, err := initRedis(config["redis_type"], config["beego_cache"]) if err != nil { fmt.Println("redis链接异常:", err) panic(any(Re)) } Rc = redisClient // ES配置 { ES_URL = config["es_url"] ES_USERNAME = config["es_username"] ES_PASSWORD = config["es_password"] } // 初始化ES initEs() // ES 索引 { DATA_INDEX_NAME = config["data_index_name"] CHART_INDEX_NAME = config["chart_index_name"] } } //修改接口文档 //http://8.136.199.33:8300/swagger/