|
|
|
@ -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 {
|
|
|
|
|