From b2786dcae557694e70d1b90ea7a2f90758901d7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=85=89=E6=98=A5?= Date: Thu, 8 Sep 2022 14:50:59 +0800 Subject: [PATCH] - update api ip --- api_gorm.go | 8 ++++++++ api_mongo.go | 8 ++++++++ const.go | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/api_gorm.go b/api_gorm.go index c988129..a7e02c8 100644 --- a/api_gorm.go +++ b/api_gorm.go @@ -20,6 +20,7 @@ type ApiGormClientConfig struct { GormClientFun apiGormClientFun // 日志配置 Debug bool // 日志开关 ZapLog *ZapLog // 日志服务 + CurrentIp string // 当前ip } // NewApiGormClient 创建接口实例化 @@ -35,6 +36,13 @@ func NewApiGormClient(config *ApiGormClientConfig) (*ApiClient, error) { c.logDebug = config.Debug + if config.CurrentIp == "" { + config.CurrentIp = goip.GetOutsideIp(ctx) + } + if config.CurrentIp != "" && config.CurrentIp != "0.0.0.0" { + c.currentIp = config.CurrentIp + } + client, tableName := config.GormClientFun() if client == nil || client.Db == nil { diff --git a/api_mongo.go b/api_mongo.go index 7132512..f2ca6cd 100644 --- a/api_mongo.go +++ b/api_mongo.go @@ -21,6 +21,7 @@ type ApiMongoClientConfig struct { MongoClientFun apiMongoClientFun // 日志配置 Debug bool // 日志开关 ZapLog *ZapLog // 日志服务 + CurrentIp string // 当前ip } // NewApiMongoClient 创建接口实例化 @@ -37,6 +38,13 @@ func NewApiMongoClient(config *ApiMongoClientConfig) (*ApiClient, error) { c.logDebug = config.Debug + if config.CurrentIp == "" { + config.CurrentIp = goip.GetOutsideIp(ctx) + } + if config.CurrentIp != "" && config.CurrentIp != "0.0.0.0" { + c.currentIp = config.CurrentIp + } + client, databaseName, collectionName := config.MongoClientFun() if client == nil || client.Db == nil { diff --git a/const.go b/const.go index 271637a..6610869 100644 --- a/const.go +++ b/const.go @@ -1,5 +1,5 @@ package golog const ( - Version = "1.0.70" + Version = "1.0.71" )