2022-10-12 18:57:22 +08:00
|
|
|
package service
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2022-11-09 15:08:38 +08:00
|
|
|
|
2022-10-17 16:32:31 +08:00
|
|
|
"github.com/1Panel-dev/1Panel/backend/global"
|
2022-10-12 18:57:22 +08:00
|
|
|
"gorm.io/gorm"
|
|
|
|
)
|
|
|
|
|
2022-11-09 15:08:38 +08:00
|
|
|
type dbStr string
|
|
|
|
|
2022-10-12 18:57:22 +08:00
|
|
|
func getTxAndContext() (tx *gorm.DB, ctx context.Context) {
|
2022-11-09 15:08:38 +08:00
|
|
|
db := dbStr("db")
|
2022-10-12 18:57:22 +08:00
|
|
|
tx = global.DB.Begin()
|
2022-11-09 15:08:38 +08:00
|
|
|
ctx = context.WithValue(context.Background(), db, tx)
|
2022-10-12 18:57:22 +08:00
|
|
|
return
|
|
|
|
}
|