fix
This commit is contained in:
parent
ac6a81dedd
commit
9ad045c8f4
|
@ -216,38 +216,31 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT
|
|||
err = txUserInfo.Where("user_id = ?", uinfo.UserId).Take(nil).Error
|
||||
// txUserInfo.Statement.Table
|
||||
|
||||
if err == nil {
|
||||
if err != nil {
|
||||
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
err = txUserInfo.Create(uinfo).Error
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
} else {
|
||||
updatesql := `UPDATE %s
|
||||
SET metadata = CASE
|
||||
WHEN metadata IS NULL THEN '%s'
|
||||
ELSE JSON_MERGE_PATCH(metadata, '%s')
|
||||
WHEN metadata IS NULL THEN ?
|
||||
ELSE JSON_MERGE_PATCH(metadata, ?)
|
||||
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 = ?;`)
|
||||
txUserInfo.Raw(updatesql, metadata, metadata, uinfo.UserId)
|
||||
}
|
||||
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
err = txUserInfo.Create(uinfo).Error
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
|
||||
})
|
||||
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return nil
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user