diff options
author | Joe Chen <jc@unknwon.io> | 2022-11-27 19:36:10 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-27 19:36:10 +0800 |
commit | ae20d03aece78fb44dc1caaacfa40c3aa40c7949 (patch) | |
tree | 7e7b33f99eae57d8426eeead443276d5cbe0dd5a /internal/route/api/v1/org | |
parent | 44333afd20a6312b617e0c33a497a4385ba3a250 (diff) |
refactor(db): migrate `UpdateUser` off `user.go` (#7267)
Diffstat (limited to 'internal/route/api/v1/org')
-rw-r--r-- | internal/route/api/v1/org/org.go | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/internal/route/api/v1/org/org.go b/internal/route/api/v1/org/org.go index 2f6b4b70..9b99bead 100644 --- a/internal/route/api/v1/org/org.go +++ b/internal/route/api/v1/org/org.go @@ -89,14 +89,25 @@ func Edit(c *context.APIContext, form api.EditOrgOption) { return } - org.FullName = form.FullName - org.Description = form.Description - org.Website = form.Website - org.Location = form.Location - if err := db.UpdateUser(org); err != nil { - c.Error(err, "update user") + err := db.Users.Update( + c.Req.Context(), + c.Org.Organization.ID, + db.UpdateUserOptions{ + FullName: &form.FullName, + Website: &form.Website, + Location: &form.Location, + Description: &form.Description, + }, + ) + if err != nil { + c.Error(err, "update organization") return } + org, err = db.GetOrgByName(org.Name) + if err != nil { + c.Error(err, "get organization") + return + } c.JSONSuccess(convert.ToOrganization(org)) } |