You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
golog/client.go

38 lines
863 B

package golog
import (
"go.dtapp.net/goip"
"gorm.io/gorm"
)
type Client struct {
Gin gin // 框架日志
Api api // 接口日志
}
// NewClientGin 创建框架实例化
func NewClientGin(db *gorm.DB, tableName string) *Client {
if db == nil {
panic("驱动不正常")
}
if tableName == "" {
panic("表名不能为空")
}
client := &Client{Gin: gin{db: db, tableName: tableName, outsideIp: goip.GetOutsideIp(), insideIp: goip.GetInsideIp()}}
client.Gin.AutoMigrate()
return client
}
// NewClientApi 创建接口实例化
func NewClientApi(db *gorm.DB, tableName string) *Client {
if db == nil {
panic("驱动不正常")
}
if tableName == "" {
panic("表名不能为空")
}
client := &Client{Api: api{db: db, tableName: tableName, outsideIp: goip.GetOutsideIp(), insideIp: goip.GetInsideIp()}}
client.Api.AutoMigrate()
return client
}