add hook
parent
f10719c212
commit
95419dd651
|
@ -24,7 +24,7 @@ type Group struct {
|
||||||
UpdatedAt time.Time
|
UpdatedAt time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
var BeforeGroupSave func(*Group) error = func(g *Group) error { return nil }
|
var BeforeGroupSave func(*Group, *gorm.DB) error = nil
|
||||||
|
|
||||||
func (grp *Group) BeforeSave(tx *gorm.DB) (err error) {
|
func (grp *Group) BeforeSave(tx *gorm.DB) (err error) {
|
||||||
|
|
||||||
|
@ -32,17 +32,17 @@ func (grp *Group) BeforeSave(tx *gorm.DB) (err error) {
|
||||||
if grp.DisplayName == "" {
|
if grp.DisplayName == "" {
|
||||||
grp.DisplayName = strings.TrimPrefix(grp.Name, SYS_AUTH_PREFIX)
|
grp.DisplayName = strings.TrimPrefix(grp.Name, SYS_AUTH_PREFIX)
|
||||||
}
|
}
|
||||||
return BeforeGroupSave(grp)
|
return BeforeGroupSave(grp, tx)
|
||||||
}
|
}
|
||||||
|
|
||||||
var BeforeGroupUpdate func(*Group) error = func(g *Group) error { return nil }
|
var BeforeGroupUpdate func(*Group, *gorm.DB) error = nil
|
||||||
|
|
||||||
func (grp *Group) BeforeUpdate(tx *gorm.DB) (err error) {
|
func (grp *Group) BeforeUpdate(tx *gorm.DB) (err error) {
|
||||||
return BeforeGroupUpdate(grp)
|
return BeforeGroupUpdate(grp, tx)
|
||||||
}
|
}
|
||||||
|
|
||||||
var BeforeGroupDelete func(*Group) error = func(g *Group) error { return nil }
|
var BeforeGroupDelete func(*Group, *gorm.DB) error = nil
|
||||||
|
|
||||||
func (grp *Group) BeforeDelete(tx *gorm.DB) (err error) {
|
func (grp *Group) BeforeDelete(tx *gorm.DB) (err error) {
|
||||||
return BeforeGroupDelete(grp)
|
return BeforeGroupDelete(grp, tx)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue