From 570468aa8ece1f78e7cee8ec0f3e6aa845bc7e05 Mon Sep 17 00:00:00 2001 From: Hengyu Ai Date: Thu, 23 May 2024 18:29:04 +0800 Subject: [PATCH] fix(queries.Register): handle error from updating inviter's reward --- pkg/queries/user.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/queries/user.go b/pkg/queries/user.go index 0385d7b..c817e1c 100644 --- a/pkg/queries/user.go +++ b/pkg/queries/user.go @@ -131,7 +131,10 @@ func Register(db *gorm.DB, u *models.User, invitation_code string) error { u.InvitedByUserID = inviter.ID // TODO: only once for the inviter? inviter.Reward += 100 - db.Select("reward").Save(inviter) + err = db.Select("reward").Save(inviter).Error + if err != nil { + return errors.Wrap(err, errors.DatabaseError) + } } // 检查邮箱是否已存在