You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
426 B
30 lines
426 B
1 month ago
|
package repository
|
||
|
|
||
|
import (
|
||
|
"gorm.io/gorm"
|
||
|
)
|
||
|
|
||
|
type BaseRepo struct {
|
||
|
db *gorm.DB
|
||
|
}
|
||
|
|
||
|
func NewBaseRepo(db *gorm.DB) *BaseRepo {
|
||
|
return &BaseRepo{db: db}
|
||
|
}
|
||
|
|
||
|
func (r *BaseRepo) DB() *gorm.DB {
|
||
|
return r.db
|
||
|
}
|
||
|
|
||
|
func (r *BaseRepo) Begin() *gorm.DB {
|
||
|
return r.db.Begin()
|
||
|
}
|
||
|
|
||
|
func (r *BaseRepo) Commit(tx *gorm.DB) error {
|
||
|
return tx.Commit().Error
|
||
|
}
|
||
|
|
||
|
func (r *BaseRepo) Rollback(tx *gorm.DB) error {
|
||
|
return tx.Rollback().Error
|
||
|
}
|