1Panel/backend/app/service/helper.go

15 lines
310 B
Go
Raw Normal View History

2022-10-12 10:57:22 +00:00
package service
import (
"context"
2022-11-02 07:19:14 +00:00
"github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/backend/global"
2022-10-12 10:57:22 +00:00
"gorm.io/gorm"
)
func getTxAndContext() (tx *gorm.DB, ctx context.Context) {
tx = global.DB.Begin()
2022-11-02 07:19:14 +00:00
ctx = context.WithValue(context.Background(), constant.DB, tx)
2022-10-12 10:57:22 +00:00
return
}