From 7951de705e026bc780125014efee5fcaad46f7f7 Mon Sep 17 00:00:00 2001 From: Evan Chen Date: Sun, 19 Dec 2021 21:30:50 +0800 Subject: [PATCH] add hook --- auth/group.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/auth/group.go b/auth/group.go index 89ea66f..6636dab 100644 --- a/auth/group.go +++ b/auth/group.go @@ -24,11 +24,13 @@ type Group struct { UpdatedAt time.Time } +var BeforeGroupSave func(*Group) error = func(g *Group) error { return nil } + func (grp *Group) BeforeSave(tx *gorm.DB) (err error) { // set displayname if grp.DisplayName == "" { grp.DisplayName = strings.TrimPrefix(grp.Name, SYS_AUTH_PREFIX) } - return + return BeforeGroupSave(grp) }