This commit is contained in:
bryanqiu 2024-06-28 16:17:01 +08:00
parent 5952c1103b
commit cb1e36d005
2 changed files with 115 additions and 91 deletions

23
go.mod
View File

@ -1,3 +1,26 @@
module qoobing.com/gomod/model module qoobing.com/gomod/model
go 1.19.2 go 1.19.2
require (
gorm.io/driver/postgres v1.5.9
gorm.io/gorm v1.25.10
qoobing.com/gomod/database v0.0.0-20240627111018-316f516e9b69
qoobing.com/gomod/log v1.2.8
qoobing.com/gomod/redis v1.3.4
)
require (
github.com/gomodule/redigo v1.9.2 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgx/v5 v5.5.5 // 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/tylerb/gls v0.0.0-20150407001822-e606233f194d // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/text v0.14.0 // indirect
qoobing.com/gomod/str v1.0.5 // indirect
)

View File

@ -7,12 +7,12 @@ import (
"gorm.io/driver/postgres" "gorm.io/driver/postgres"
"gorm.io/gorm" "gorm.io/gorm"
"qoobing.com/gomod/database"
"qoobing.com/gomod/log" "qoobing.com/gomod/log"
"qoobing.com/gomod/redis" "qoobing.com/gomod/redis"
"qoobing.com/gomod/database" "qoobing.com/gomod/redis/sentinel"
) )
type Model struct { type Model struct {
DB *gorm.DB DB *gorm.DB
DbTxStatus DbTxStatus DbTxStatus DbTxStatus
@ -21,6 +21,7 @@ type Model struct {
} }
type DbTxStatus int type DbTxStatus int
const ( const (
DBTX_STATUS_TX_NONE DbTxStatus = 0 DBTX_STATUS_TX_NONE DbTxStatus = 0
DBTX_STATUS_TX_DOING DbTxStatus = 1 DBTX_STATUS_TX_DOING DbTxStatus = 1
@ -159,7 +160,7 @@ func OptOpenDefaultRedis(m *Model) {
} }
// Init init default database config & redis config // Init init default database config & redis config
func Init(defaultDb *database.Config, defaultRds *redis.Config){ func Init(defaultDb *database.Config, defaultRds *redis.Config) {
defaultOptions = []Options{} defaultOptions = []Options{}
if defaultDb { if defaultDb {