fix: template

This commit is contained in:
Rogee
2024-12-21 00:25:12 +08:00
parent 58450dd63d
commit 6f04023a42
7 changed files with 26 additions and 20 deletions

View File

@@ -5,13 +5,13 @@ import (
"database/sql"
"fmt"
"{{.ModuleName}}/pkg/consts"
"github.com/go-jet/jet/v2/qrm"
)
const CtxDB = "__db__tx:"
func FromContext(ctx context.Context, db *sql.DB) qrm.DB {
if tx, ok := ctx.Value(consts.CtxKeyTx).(*sql.Tx); ok {
if tx, ok := ctx.Value(CtxDB).(*sql.Tx); ok {
return tx
}
return db