Files
gormt/data/view/genfunc/gen.base.go
谢小军 da4332286f new
2019-12-13 19:52:15 +08:00

35 lines
550 B
Go

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}}
}
///////////////////////////////////////////////////