This commit is contained in:
eson 2023-08-29 16:15:34 +08:00
parent 1ed2346303
commit ff7bbe66a7
2 changed files with 14 additions and 7 deletions

View File

@ -60,7 +60,6 @@ func InheritGuestIdResource(tx *gorm.DB, userId, guestId int64, afterDo func(txR
err = txRes.
Where("guest_id = ?", guestId).
UpdateColumn("user_id", userId).Error
if err != nil && err != gorm.ErrRecordNotFound {
return err
}
@ -82,6 +81,15 @@ func InheritGuestIdResource(tx *gorm.DB, userId, guestId int64, afterDo func(txR
}
if afterDo != nil {
if txRes.Error != nil {
txRes = tx.Model(&FsResource{})
}
if txUserMaterial.Error != nil {
txUserMaterial = tx.Model(&FsUserMaterial{})
}
if txUserInfo.Error != nil {
txUserInfo = tx.Model(&FsUserInfo{})
}
return afterDo(txRes, txUserMaterial, txUserInfo)
}
return fmt.Errorf("guest_id must not be 0")
@ -98,7 +106,6 @@ func (u *FsUserModel) RegisterByGoogleOAuth(ctx context.Context, token *auth.Reg
if err != nil {
// 没有找到在数据库就创建注册
if err == gorm.ErrRecordNotFound {
createAt := time.Now().UTC().Unix()
user.Email = &token.Email
user.CreatedAt = &createAt
@ -108,7 +115,6 @@ func (u *FsUserModel) RegisterByGoogleOAuth(ctx context.Context, token *auth.Reg
if err != nil {
return err
}
// 继承guest_id的资源表
return InheritGuestIdResource(tx, user.Id, token.GuestId, nil)
}
@ -144,7 +150,6 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT
userTx := tx.Model(user)
err = userTx.Where("email = ?", token.Email).Take(user).Error
if err == gorm.ErrRecordNotFound {
FirstName := token.Extend["first_name"].(string)

View File

@ -111,7 +111,10 @@ func (l *UserEmailConfirmationLogic) UserEmailConfirmation(req *types.RequestEma
return resp.SetStatus(basic.CodeDbSqlErr)
}
FinishRegister(l.svcCtx, user, token)
err = FinishRegister(l.svcCtx, user, token)
if err != nil {
logx.Error(err)
}
logx.Info("success", token.TraceId)
case "facebook":
@ -120,9 +123,8 @@ func (l *UserEmailConfirmationLogic) UserEmailConfirmation(req *types.RequestEma
user, err := l.svcCtx.AllModels.FsUser.RegisterByFusen(l.ctx, token)
if err != nil && err != gorm.ErrRecordNotFound {
logx.Error(err, ":", token.TraceId)
return resp.SetStatus(basic.CodeDbSqlErr)
return resp.SetStatus(basic.CodeDbSqlErr, err.Error())
}
err = FinishRegister(l.svcCtx, user, token)
if err != nil {
logx.Error(err)