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