Update def.go
This commit is contained in:
@@ -19,6 +19,7 @@ var {{.StructName}}Columns = struct { {{range $em := .Em}}
|
|||||||
package {{.PackageName}}
|
package {{.PackageName}}
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -27,6 +28,11 @@ import (
|
|||||||
|
|
||||||
var globalIsRelated bool = true // 全局预加载
|
var globalIsRelated bool = true // 全局预加载
|
||||||
|
|
||||||
|
// IsNotFound ErrRecordNotFound
|
||||||
|
func IsNotFound(err error) bool {
|
||||||
|
return errors.Is(err, gorm.ErrRecordNotFound)
|
||||||
|
}
|
||||||
|
|
||||||
// prepare for other
|
// prepare for other
|
||||||
type _BaseMgr struct {
|
type _BaseMgr struct {
|
||||||
*gorm.DB
|
*gorm.DB
|
||||||
@@ -89,6 +95,11 @@ func (obj *_BaseMgr) NewDB() *gorm.DB {
|
|||||||
return obj.DB.Session(&gorm.Session{NewDB: true, Context: obj.ctx})
|
return obj.DB.Session(&gorm.Session{NewDB: true, Context: obj.ctx})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsNotFound ErrRecordNotFound
|
||||||
|
func (obj *_BaseMgr) IsNotFound(err error) bool {
|
||||||
|
return errors.Is(err, gorm.ErrRecordNotFound)
|
||||||
|
}
|
||||||
|
|
||||||
type options struct {
|
type options struct {
|
||||||
query map[string]interface{}
|
query map[string]interface{}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user