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