Add UpdateUserInternal().

This commit is contained in:
Yang Luo
2021-06-09 21:41:27 +08:00
parent f672045b45
commit 8e5f3c18e1
3 changed files with 26 additions and 9 deletions

View File

@ -124,6 +124,22 @@ func UpdateUser(id string, user *User) bool {
return affected != 0
}
func UpdateUserInternal(id string, user *User) bool {
owner, name := util.GetOwnerAndNameFromId(id)
if getUser(owner, name) == nil {
return false
}
user.UpdateUserHash()
affected, err := adapter.Engine.ID(core.PK{owner, name}).AllCols().Update(user)
if err != nil {
panic(err)
}
return affected != 0
}
func UpdateUserForOriginal(user *User) bool {
affected, err := adapter.Engine.ID(core.PK{user.Owner, user.Name}).Cols("display_name", "password", "phone", "avatar", "affiliation", "score", "is_forbidden", "hash", "pre_hash").Update(user)
if err != nil {