fix
This commit is contained in:
parent
99f785a7c3
commit
c4b4b72947
|
@ -9,8 +9,6 @@ import (
|
|||
"fusenapi/utils/fssql"
|
||||
"time"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
|
@ -65,7 +63,7 @@ func InheritGuestIdResource(tx *gorm.DB, userId, guestId int64, afterDo func(txR
|
|||
if guestId != 0 {
|
||||
// 继承guest_id的资源表
|
||||
err = txRes.
|
||||
Where("guest_id = ? and source != 'temp'", guestId).
|
||||
Where("guest_id = ? and source != 'temp' and version != '0.0.0'", guestId).
|
||||
UpdateColumn("user_id", userId).Error
|
||||
|
||||
if err != nil && err != gorm.ErrRecordNotFound {
|
||||
|
@ -77,16 +75,14 @@ func InheritGuestIdResource(tx *gorm.DB, userId, guestId int64, afterDo func(txR
|
|||
UpdateColumn("user_id", userId).Error
|
||||
|
||||
if err != nil && err != gorm.ErrRecordNotFound {
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
err = txUserInfo.
|
||||
Where("guest_id = ? and module != 'clear' and module != 'temp'", guestId).
|
||||
UpdateColumn("user_id", userId).Error
|
||||
logx.Info(err, "guest_id = ", guestId)
|
||||
if err != nil && err != gorm.ErrRecordNotFound {
|
||||
|
||||
if err != nil && err != gorm.ErrRecordNotFound {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -173,7 +169,6 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT
|
|||
var err error
|
||||
|
||||
err = tx.Model(&FsUser{}).Where("email = ?", token.Email).Take(user).Error
|
||||
logx.Info("success", token.TraceId)
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
|
||||
FirstName := token.Extend["first_name"].(string)
|
||||
|
@ -181,7 +176,6 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT
|
|||
Resetaurant := token.Extend["resetaurant"].(string)
|
||||
|
||||
createAt := time.Now().UTC().Unix()
|
||||
|
||||
user.Email = &token.Email
|
||||
user.CreatedAt = &createAt
|
||||
user.PasswordHash = &token.Password
|
||||
|
@ -190,15 +184,11 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT
|
|||
|
||||
err = tx.Model(&FsUser{}).Create(user).Error
|
||||
if err != nil && err != gorm.ErrRecordNotFound {
|
||||
logx.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
logx.Info("success", token.TraceId)
|
||||
|
||||
// 继承guest_id的资源表
|
||||
err = InheritGuestIdResource(tx, user.Id, token.GuestId, func(txResouce, txUserMaterial, txUserInfo *gorm.DB) error {
|
||||
logx.Info("success", token.TraceId)
|
||||
userProfile := &UserProfile{
|
||||
FirstName: FirstName,
|
||||
LastName: LastName,
|
||||
|
@ -209,8 +199,6 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT
|
|||
return err
|
||||
}
|
||||
|
||||
// txUserInfo.Where("user_id = ?", user.Id).Row().Err()
|
||||
|
||||
now := time.Now().UTC()
|
||||
uinfo := &FsUserInfo{
|
||||
Module: FsString("profile"),
|
||||
|
@ -222,12 +210,10 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT
|
|||
}
|
||||
|
||||
err = txUserInfo.Where("module = 'profile' and user_id = ?", *uinfo.UserId).Take(nil).Error
|
||||
|
||||
logx.Info(err, "*uinfo.UserId", *uinfo.UserId)
|
||||
if err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
err = tx.Model(&FsUserInfo{}).Create(uinfo).Error
|
||||
logx.Info(err, "*uinfo.UserId:", *uinfo.UserId, " ", uinfo.Id)
|
||||
// logx.Info(err, "*uinfo.UserId:", *uinfo.UserId, " ", uinfo.Id)
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user