Compare commits
4 Commits
Author | SHA1 | Date |
---|---|---|
dtapps | 2468c93f21 | 4 months ago |
李光春 | 735458386d | 2 years ago |
李光春 | d2f280e2e6 | 2 years ago |
李光春 | c34f3b51ff | 2 years ago |
@ -1,96 +1,30 @@
|
||||
package kuaishou
|
||||
|
||||
import (
|
||||
"go.dtapp.net/dorm"
|
||||
"go.dtapp.net/golog"
|
||||
"go.dtapp.net/gorequest"
|
||||
)
|
||||
|
||||
// client *dorm.GormClient
|
||||
type gormClientFun func() *dorm.GormClient
|
||||
|
||||
// client *dorm.MongoClient
|
||||
// databaseName string
|
||||
type mongoClientFun func() (*dorm.MongoClient, string)
|
||||
|
||||
// ClientConfig 实例配置
|
||||
type ClientConfig struct {
|
||||
GormClientFun gormClientFun // 日志配置
|
||||
MongoClientFun mongoClientFun // 日志配置
|
||||
Debug bool // 日志开关
|
||||
ZapLog *golog.ZapLog // 日志服务
|
||||
CurrentIp string // 当前ip
|
||||
}
|
||||
|
||||
// Client 实例
|
||||
type Client struct {
|
||||
requestClient *gorequest.App // 请求服务
|
||||
zapLog *golog.ZapLog // 日志服务
|
||||
currentIp string // 当前ip
|
||||
config struct {
|
||||
config struct {
|
||||
ua string // 用户代理
|
||||
}
|
||||
log struct {
|
||||
gorm bool // 日志开关
|
||||
gormClient *dorm.GormClient // 日志数据库
|
||||
logGormClient *golog.ApiClient // 日志服务
|
||||
mongo bool // 日志开关
|
||||
mongoClient *dorm.MongoClient // 日志数据库
|
||||
logMongoClient *golog.ApiClient // 日志服务
|
||||
gormLog struct {
|
||||
status bool // 状态
|
||||
client *golog.ApiGorm // 日志服务
|
||||
}
|
||||
}
|
||||
|
||||
// NewClient 创建实例化
|
||||
func NewClient(config *ClientConfig) (*Client, error) {
|
||||
|
||||
var err error
|
||||
c := &Client{}
|
||||
|
||||
c.zapLog = config.ZapLog
|
||||
|
||||
c.currentIp = config.CurrentIp
|
||||
|
||||
c.config.ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36"
|
||||
|
||||
c.requestClient = gorequest.NewHttp()
|
||||
|
||||
gormClient := config.GormClientFun()
|
||||
if gormClient != nil && gormClient.Db != nil {
|
||||
c.log.logGormClient, err = golog.NewApiGormClient(&golog.ApiGormClientConfig{
|
||||
GormClientFun: func() (*dorm.GormClient, string) {
|
||||
return gormClient, logTable
|
||||
},
|
||||
Debug: config.Debug,
|
||||
ZapLog: c.zapLog,
|
||||
CurrentIp: c.currentIp,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c.log.gorm = true
|
||||
c.log.gormClient = gormClient
|
||||
}
|
||||
|
||||
mongoClient, databaseName := config.MongoClientFun()
|
||||
if mongoClient != nil && mongoClient.Db != nil {
|
||||
c.log.logMongoClient, err = golog.NewApiMongoClient(&golog.ApiMongoClientConfig{
|
||||
MongoClientFun: func() (*dorm.MongoClient, string, string) {
|
||||
return mongoClient, databaseName, logTable
|
||||
},
|
||||
Debug: config.Debug,
|
||||
ZapLog: c.zapLog,
|
||||
CurrentIp: c.currentIp,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c.log.mongo = true
|
||||
c.log.mongoClient = mongoClient
|
||||
}
|
||||
|
||||
//if c.config.GormClient.Db != nil {
|
||||
// go c.logClient.GormMiddleware(ctx, request, Version)
|
||||
//}
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
package kuaishou
|
||||
|
||||
import (
|
||||
"go.dtapp.net/golog"
|
||||
)
|
||||
|
||||
// ConfigApiGormFun 接口日志配置
|
||||
func (c *Client) ConfigApiGormFun(apiClientFun golog.ApiGormFun) {
|
||||
client := apiClientFun()
|
||||
if client != nil {
|
||||
c.gormLog.client = client
|
||||
c.gormLog.status = true
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package kuaishou
|
||||
|
||||
const (
|
||||
logTable = "kuaishou"
|
||||
Version = "1.0.10"
|
||||
LogTable = "kuaishou"
|
||||
)
|
||||
|
@ -1,92 +1,77 @@
|
||||
module go.dtapp.net/kuaishou
|
||||
|
||||
go 1.19
|
||||
go 1.21.5
|
||||
|
||||
require (
|
||||
github.com/mvdan/xurls v1.1.0
|
||||
go.dtapp.net/dorm v1.0.33
|
||||
go.dtapp.net/golog v1.0.73
|
||||
go.dtapp.net/gorequest v1.0.31
|
||||
go.dtapp.net/golog v1.0.103
|
||||
go.dtapp.net/gorequest v1.0.40
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/MercuryEngineering/CookieMonster v0.0.0-20180304172713-1584578b3403 // indirect
|
||||
github.com/basgys/goxml2json v1.1.0 // indirect
|
||||
github.com/beego/beego/v2 v2.0.5 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||
github.com/bytedance/sonic v1.10.2 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
|
||||
github.com/chenzhuoyu/iasm v0.9.1 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/gin-gonic/gin v1.8.1 // indirect
|
||||
github.com/go-playground/locales v0.14.0 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.0 // indirect
|
||||
github.com/go-playground/validator/v10 v10.11.0 // indirect
|
||||
github.com/go-redis/redis/v9 v9.0.0-beta.2 // indirect
|
||||
github.com/go-sql-driver/mysql v1.6.0 // indirect
|
||||
github.com/goccy/go-json v0.9.11 // indirect
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
github.com/hashicorp/golang-lru v0.5.4 // indirect
|
||||
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
|
||||
github.com/jackc/pgconn v1.13.0 // indirect
|
||||
github.com/jackc/pgio v1.0.0 // indirect
|
||||
github.com/gin-gonic/gin v1.9.1 // indirect
|
||||
github.com/go-ole/go-ole v1.3.0 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.16.0 // indirect
|
||||
github.com/go-sql-driver/mysql v1.7.1 // indirect
|
||||
github.com/goccy/go-json v0.10.2 // indirect
|
||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||
github.com/jackc/pgproto3/v2 v2.3.1 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
|
||||
github.com/jackc/pgtype v1.12.0 // indirect
|
||||
github.com/jackc/pgx/v4 v4.17.2 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 // indirect
|
||||
github.com/jackc/pgx/v5 v5.5.1 // indirect
|
||||
github.com/jackc/puddle/v2 v2.2.1 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/compress v1.15.9 // indirect
|
||||
github.com/leodido/go-urn v1.2.1 // indirect
|
||||
github.com/lib/pq v1.10.7 // indirect
|
||||
github.com/mattn/go-isatty v0.0.16 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
|
||||
github.com/leodido/go-urn v1.2.4 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/montanaflynn/stats v0.6.6 // indirect
|
||||
github.com/natefinch/lumberjack v2.0.0+incompatible // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/saracen/go7z v0.0.0-20191010121135-9c09b6bd7fda // indirect
|
||||
github.com/saracen/solidblock v0.0.0-20190426153529-45df20abab6f // indirect
|
||||
github.com/segmentio/fasthash v1.0.3 // indirect
|
||||
github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18 // indirect
|
||||
github.com/sirupsen/logrus v1.9.0 // indirect
|
||||
github.com/syndtr/goleveldb v1.0.0 // indirect
|
||||
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect
|
||||
github.com/ugorji/go/codec v1.2.7 // indirect
|
||||
github.com/ulikunitz/xz v0.5.10 // indirect
|
||||
github.com/upper/db/v4 v4.6.0 // indirect
|
||||
github.com/uptrace/bun v1.1.8 // indirect
|
||||
github.com/uptrace/bun/dialect/mysqldialect v1.1.8 // indirect
|
||||
github.com/uptrace/bun/dialect/pgdialect v1.1.8 // indirect
|
||||
github.com/uptrace/bun/driver/pgdriver v1.1.8 // indirect
|
||||
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
|
||||
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
|
||||
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
|
||||
github.com/xdg-go/scram v1.1.1 // indirect
|
||||
github.com/xdg-go/stringprep v1.0.3 // indirect
|
||||
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
|
||||
go.dtapp.net/goip v1.0.30 // indirect
|
||||
go.dtapp.net/gorandom v1.0.1 // indirect
|
||||
go.dtapp.net/gostring v1.0.10 // indirect
|
||||
go.dtapp.net/gotime v1.0.5 // indirect
|
||||
github.com/oschwald/geoip2-golang v1.9.0 // indirect
|
||||
github.com/oschwald/maxminddb-golang v1.12.0 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
|
||||
github.com/redis/go-redis/v9 v9.3.1 // indirect
|
||||
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
|
||||
github.com/sirupsen/logrus v1.9.3 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.13 // indirect
|
||||
github.com/tklauser/numcpus v0.7.0 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.3 // indirect
|
||||
go.dtapp.net/dorm v1.0.55 // indirect
|
||||
go.dtapp.net/goip v1.0.43 // indirect
|
||||
go.dtapp.net/gojson v1.0.2 // indirect
|
||||
go.dtapp.net/gorandom v1.0.2 // indirect
|
||||
go.dtapp.net/gostring v1.0.12 // indirect
|
||||
go.dtapp.net/gotime v1.0.6 // indirect
|
||||
go.dtapp.net/gotrace_id v1.0.6 // indirect
|
||||
go.dtapp.net/gourl v1.0.0 // indirect
|
||||
go.mongodb.org/mongo-driver v1.10.2 // indirect
|
||||
go.uber.org/atomic v1.10.0 // indirect
|
||||
go.uber.org/multierr v1.8.0 // indirect
|
||||
go.uber.org/zap v1.23.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
|
||||
golang.org/x/net v0.0.0-20220909164309-bea034e7d591 // indirect
|
||||
golang.org/x/sync v0.0.0-20220907140024-f12130a52804 // indirect
|
||||
golang.org/x/sys v0.0.0-20220913175220-63ea55921009 // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
google.golang.org/protobuf v1.28.1 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gorm.io/driver/mysql v1.3.6 // indirect
|
||||
gorm.io/driver/postgres v1.3.9 // indirect
|
||||
gorm.io/gorm v1.23.8 // indirect
|
||||
mellium.im/sasl v0.3.0 // indirect
|
||||
xorm.io/builder v0.3.12 // indirect
|
||||
xorm.io/xorm v1.3.2 // indirect
|
||||
golang.org/x/arch v0.6.0 // indirect
|
||||
golang.org/x/crypto v0.17.0 // indirect
|
||||
golang.org/x/mod v0.14.0 // indirect
|
||||
golang.org/x/net v0.19.0 // indirect
|
||||
golang.org/x/sync v0.5.0 // indirect
|
||||
golang.org/x/sys v0.15.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
golang.org/x/tools v0.16.1 // indirect
|
||||
google.golang.org/protobuf v1.31.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
gorm.io/datatypes v1.2.0 // indirect
|
||||
gorm.io/driver/mysql v1.5.2 // indirect
|
||||
gorm.io/driver/postgres v1.5.4 // indirect
|
||||
gorm.io/gen v0.3.24 // indirect
|
||||
gorm.io/gorm v1.25.5 // indirect
|
||||
gorm.io/hints v1.1.2 // indirect
|
||||
gorm.io/plugin/dbresolver v1.5.0 // indirect
|
||||
)
|
||||
|
@ -0,0 +1,5 @@
|
||||
package kuaishou
|
||||
|
||||
const (
|
||||
Version = "1.0.13"
|
||||
)
|
Loading…
Reference in new issue