master
李光春 2 years ago
parent 0565ef6626
commit 259ee637e0

@ -1,6 +1,7 @@
package golog
import (
"go.dtapp.net/goip"
"gorm.io/datatypes"
"gorm.io/gorm"
)
@ -55,3 +56,10 @@ func (a *api) Record(content ApiPostgresqlLog) int64 {
func (a *api) Query() *gorm.DB {
return a.db.Table(a.tableName)
}
// 配置
func (a *api) configOutsideIp() {
go func() {
a.insideIp = goip.GetOutsideIp()
}()
}

@ -22,9 +22,9 @@ func (a *App) InitClientApi() {
}
a.Api.db = a.Pgsql
a.Api.tableName = a.TableName
a.Api.outsideIp = goip.GetOutsideIp()
a.Api.insideIp = goip.GetInsideIp()
a.Api.AutoMigrate()
a.Api.configOutsideIp()
}
// InitClientGin 框架实例化
@ -37,7 +37,7 @@ func (a *App) InitClientGin() {
}
a.Gin.db = a.Pgsql
a.Gin.tableName = a.TableName
a.Gin.outsideIp = goip.GetOutsideIp()
a.Gin.insideIp = goip.GetInsideIp()
a.Gin.AutoMigrate()
a.Gin.configOutsideIp()
}

@ -18,8 +18,9 @@ func NewClientGin(db *gorm.DB, tableName string) *Client {
if tableName == "" {
panic("表名不能为空")
}
client := &Client{Gin: gin{db: db, tableName: tableName, outsideIp: goip.GetOutsideIp(), insideIp: goip.GetInsideIp()}}
client := &Client{Gin: gin{db: db, tableName: tableName, insideIp: goip.GetInsideIp()}}
client.Gin.AutoMigrate()
client.Gin.configOutsideIp()
return client
}
@ -31,7 +32,8 @@ func NewClientApi(db *gorm.DB, tableName string) *Client {
if tableName == "" {
panic("表名不能为空")
}
client := &Client{Api: api{db: db, tableName: tableName, outsideIp: goip.GetOutsideIp(), insideIp: goip.GetInsideIp()}}
client := &Client{Api: api{db: db, tableName: tableName, insideIp: goip.GetInsideIp()}}
client.Api.AutoMigrate()
client.Api.configOutsideIp()
return client
}

@ -1,6 +1,7 @@
package golog
import (
"go.dtapp.net/goip"
"gorm.io/datatypes"
"gorm.io/gorm"
)
@ -66,3 +67,10 @@ func (g *gin) Record(content GinPostgresqlLog) int64 {
func (g *gin) Query() *gorm.DB {
return g.db.Table(g.tableName)
}
// 配置
func (g *gin) configOutsideIp() {
go func() {
g.insideIp = goip.GetOutsideIp()
}()
}

Loading…
Cancel
Save