This commit is contained in:
谢小军
2019-12-13 19:52:15 +08:00
parent 3646031889
commit da4332286f
8 changed files with 66 additions and 15 deletions

View File

@@ -0,0 +1,34 @@
package genfunc
import (
"context"
"fmt"
"github.com/jinzhu/gorm"
)
type _BaseMgr struct {
*gorm.DB
ctx *context.Context
}
// SetCtx set context
func (obj *_BaseMgr) SetCtx(c *context.Context) {
obj.ctx = c
}
////////////////////////////////////////////logic
type _ExampleMgr struct {
*_BaseMgr
}
// ExampleMgr open func
func ExampleMgr(db *gorm.DB) *_ExampleMgr {
if db == nil {
panic(fmt.Errorf("ExampleMgr init need db"))
}
return &_ExampleMgr{_BaseMgr: &_BaseMgr{DB: db}}
}
///////////////////////////////////////////////////