- 优化
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
0b7a7a28bb
commit
054024fa98
@ -1,48 +0,0 @@
|
||||
package golog
|
||||
|
||||
import (
|
||||
"go.dtapp.net/goip"
|
||||
"gorm.io/gorm"
|
||||
"os"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type App struct {
|
||||
Gin gin // 框架日志
|
||||
Api api // 接口日志
|
||||
Pgsql *gorm.DB // pgsql数据库
|
||||
TableName string // 日志表名
|
||||
}
|
||||
|
||||
// InitClientApi 接口实例化
|
||||
func (a *App) InitClientApi() {
|
||||
if a.Pgsql == nil {
|
||||
panic("驱动不正常")
|
||||
}
|
||||
if a.TableName == "" {
|
||||
panic("表名不能为空")
|
||||
}
|
||||
a.Api.db = a.Pgsql
|
||||
a.Api.tableName = a.TableName
|
||||
a.Api.hostname, _ = os.Hostname()
|
||||
a.Api.insideIp = goip.GetInsideIp()
|
||||
a.Api.goVersion = strings.TrimPrefix(runtime.Version(), "go")
|
||||
a.Api.AutoMigrate()
|
||||
}
|
||||
|
||||
// InitClientGin 框架实例化
|
||||
func (a *App) InitClientGin() {
|
||||
if a.Pgsql == nil {
|
||||
panic("驱动不正常")
|
||||
}
|
||||
if a.TableName == "" {
|
||||
panic("表名不能为空")
|
||||
}
|
||||
a.Gin.db = a.Pgsql
|
||||
a.Gin.tableName = a.TableName
|
||||
a.Gin.hostname, _ = os.Hostname()
|
||||
a.Gin.insideIp = goip.GetInsideIp()
|
||||
a.Gin.goVersion = strings.TrimPrefix(runtime.Version(), "go")
|
||||
a.Gin.AutoMigrate()
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
package golog
|
||||
|
||||
import (
|
||||
"go.dtapp.net/goip"
|
||||
"gorm.io/gorm"
|
||||
"os"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
Gin gin // 框架日志
|
||||
Api api // 接口日志
|
||||
}
|
||||
|
||||
// NewClientGin 创建框架实例化
|
||||
func NewClientGin(db *gorm.DB, tableName string) *Client {
|
||||
if db == nil {
|
||||
panic("驱动不正常")
|
||||
}
|
||||
if tableName == "" {
|
||||
panic("表名不能为空")
|
||||
}
|
||||
hostname, _ := os.Hostname()
|
||||
client := &Client{Gin: gin{db: db, tableName: tableName, hostname: hostname, insideIp: goip.GetInsideIp(), goVersion: strings.TrimPrefix(runtime.Version(), "go")}}
|
||||
client.Gin.AutoMigrate()
|
||||
return client
|
||||
}
|
||||
|
||||
// NewClientApi 创建接口实例化
|
||||
func NewClientApi(db *gorm.DB, tableName string) *Client {
|
||||
if db == nil {
|
||||
panic("驱动不正常")
|
||||
}
|
||||
if tableName == "" {
|
||||
panic("表名不能为空")
|
||||
}
|
||||
hostname, _ := os.Hostname()
|
||||
client := &Client{Api: api{db: db, tableName: tableName, hostname: hostname, insideIp: goip.GetInsideIp(), goVersion: strings.TrimPrefix(runtime.Version(), "go")}}
|
||||
client.Api.AutoMigrate()
|
||||
return client
|
||||
}
|
Loading…
Reference in new issue