From 88e68c390338265d4a362e0b230c84050fcc92fe Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Tue, 29 Aug 2023 15:21:19 +0800 Subject: [PATCH] fix --- model/gmodel/fs_user_logic.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/model/gmodel/fs_user_logic.go b/model/gmodel/fs_user_logic.go index 74fc6a00..f6a512ea 100644 --- a/model/gmodel/fs_user_logic.go +++ b/model/gmodel/fs_user_logic.go @@ -147,10 +147,11 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT }() err = u.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error { - var err error + var err error UserTx := tx.Model(user) err = UserTx.Where("email = ?", token.Email).Take(user).Error + if err == gorm.ErrRecordNotFound { FirstName := token.Extend["first_name"].(string) @@ -165,7 +166,6 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT user.LastName = &LastName err = UserTx.Create(user).Error - if err != nil && err != gorm.ErrRecordNotFound { logx.Error(err) return err @@ -194,7 +194,13 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT Utime: &now, } logcontent += "profile." - return txUserInfo.Create(uinfo).Error + + err = txUserInfo.Create(uinfo).Error + if err == gorm.ErrRecordNotFound { + return nil + } + + return err }) if err == gorm.ErrRecordNotFound {