|
|
@ -1,6 +1,7 @@ |
|
|
|
package db |
|
|
|
package db |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
|
|
|
|
"context" |
|
|
|
"database/sql" |
|
|
|
"database/sql" |
|
|
|
"errors" |
|
|
|
"errors" |
|
|
|
"gorm.io/driver/mysql" |
|
|
|
"gorm.io/driver/mysql" |
|
|
@ -69,6 +70,10 @@ func DB() *gorm.DB { |
|
|
|
return db |
|
|
|
return db |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func WithContext(ctx context.Context) *gorm.DB { |
|
|
|
|
|
|
|
return DB().WithContext(ctx) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// SetDB 自定义操作引擎
|
|
|
|
// SetDB 自定义操作引擎
|
|
|
|
func SetDB(engine *gorm.DB) { |
|
|
|
func SetDB(engine *gorm.DB) { |
|
|
|
lock.Lock() |
|
|
|
lock.Lock() |
|
|
|