info get profile
This commit is contained in:
parent
6072341a2b
commit
316ebd9fca
|
@ -121,13 +121,58 @@ func (u *FsUserModel) RegisterByGoogleOAuth(ctx context.Context, token *auth.Reg
|
|||
user.GoogleId = &googleId
|
||||
user.PasswordHash = &token.Password
|
||||
user.FirstName = &firstName
|
||||
user.FirstName = &lastName
|
||||
user.LastName = &lastName
|
||||
err = tx.Model(&FsUser{}).Create(user).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// 继承guest_id的资源表
|
||||
return InheritGuestIdResource(tx, user.Id, token.GuestId, nil)
|
||||
return InheritGuestIdResource(tx, user.Id, token.GuestId, func(txResouce, txUserMaterial, txUserInfo *gorm.DB) error {
|
||||
userProfileBase := UserProfileBase{
|
||||
FirstName: *user.FirstName,
|
||||
LastName: *user.LastName,
|
||||
Email: *user.Email,
|
||||
}
|
||||
|
||||
userProfile := &UserProfile{
|
||||
ProfileBase: userProfileBase,
|
||||
}
|
||||
|
||||
metadata, err := json.Marshal(userProfile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
now := time.Now().UTC()
|
||||
uinfo := &FsUserInfo{
|
||||
Module: FsString("profile"),
|
||||
UserId: &user.Id,
|
||||
GuestId: &token.GuestId,
|
||||
Metadata: &metadata,
|
||||
Ctime: &now,
|
||||
Utime: &now,
|
||||
}
|
||||
|
||||
// logx.Error(metadata)
|
||||
|
||||
err = txUserInfo.Where("module = 'profile' and user_id = ?", *uinfo.UserId).Take(nil).Error
|
||||
if err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
err = tx.Model(&FsUserInfo{}).Create(uinfo).Error
|
||||
// logx.Info(err, "*uinfo.UserId:", *uinfo.UserId, " ", uinfo.Id)
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
} else {
|
||||
err = fssql.MetadataModulePATCH(txUserInfo, "profile", FsUserInfo{}, metadata, "user_id = ?", *uinfo.UserId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return err
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue
Block a user