fix
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -146,15 +147,16 @@ func (u *FsUserModel) RegisterByGoogleOAuth(ctx context.Context, token *auth.Reg
|
||||
// SubscriptionStatus 订阅状态
|
||||
type SubscriptionStatus struct {
|
||||
SubEmail bool `json:"all_emails"`
|
||||
ItemMap struct {
|
||||
ItemMap *struct {
|
||||
} `json:"item_map"`
|
||||
}
|
||||
|
||||
// UserProfile 个人信息
|
||||
type UserProfile struct {
|
||||
FirstName string `json:"first_name"`
|
||||
LastName string `json:"last_name"`
|
||||
Resetaurant string `json:"resetaurant"`
|
||||
FirstName string `json:"first_name"`
|
||||
LastName string `json:"last_name"`
|
||||
Resetaurant string `json:"resetaurant"`
|
||||
SubStatus SubscriptionStatus `json:"sub_status"`
|
||||
}
|
||||
|
||||
// 自平台的注册流程
|
||||
@@ -188,6 +190,7 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT
|
||||
|
||||
// 继承guest_id的资源表
|
||||
err = InheritGuestIdResource(tx, user.Id, token.GuestId, func(txResouce, txUserMaterial, txUserInfo *gorm.DB) error {
|
||||
|
||||
userProfile := &UserProfile{
|
||||
FirstName: FirstName,
|
||||
LastName: LastName,
|
||||
@@ -197,6 +200,9 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// txUserInfo.Where("user_id = ?", user.Id).Row().Err()
|
||||
|
||||
now := time.Now()
|
||||
uinfo := &FsUserInfo{
|
||||
Module: FsString("profile"),
|
||||
@@ -207,11 +213,36 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT
|
||||
Utime: &now,
|
||||
}
|
||||
|
||||
err = txUserInfo.Create(uinfo).Error
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return nil
|
||||
err = txUserInfo.Where("user_id = ?", uinfo.UserId).Take(nil).Error
|
||||
// txUserInfo.Statement.Table
|
||||
|
||||
if err == nil {
|
||||
|
||||
updatesql := `UPDATE %s
|
||||
SET metadata = CASE
|
||||
WHEN metadata IS NULL THEN '%s'
|
||||
ELSE JSON_MERGE_PATCH(metadata, '%s')
|
||||
END
|
||||
WHERE id = ?;`
|
||||
updatesql = fmt.Sprintf(updatesql, txUserInfo.Statement.Table)
|
||||
|
||||
txUserInfo.Raw(`UPDATE fusen.fs_change_code
|
||||
SET metadata = CASE
|
||||
WHEN metadata IS NULL THEN '%s'
|
||||
ELSE JSON_MERGE_PATCH(metadata, '%s')
|
||||
END
|
||||
WHERE id = ?;`)
|
||||
}
|
||||
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
err = txUserInfo.Create(uinfo).Error
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
|
||||
})
|
||||
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
|
||||
Reference in New Issue
Block a user