new
This commit is contained in:
34
data/view/genfunc/gen.base.go
Normal file
34
data/view/genfunc/gen.base.go
Normal 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}}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
Reference in New Issue
Block a user