diff options
author | Joe Chen <jc@unknwon.io> | 2023-02-04 00:02:34 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-04 00:02:34 +0800 |
commit | cc4d4eacad6b6a92ebb3380715dcaee3bcc5fd41 (patch) | |
tree | 36889c562b8560c2065199ca4b1b01ccfad179c9 /internal/route/home.go | |
parent | c53a1998c589a544b25d53f6e6fdf0f24a4df25b (diff) |
refactor(db): migrate methods off `user.go` (#7331)
Diffstat (limited to 'internal/route/home.go')
-rw-r--r-- | internal/route/home.go | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/internal/route/home.go b/internal/route/home.go index ec4be9d2..a389c080 100644 --- a/internal/route/home.go +++ b/internal/route/home.go @@ -113,15 +113,13 @@ func RenderUserSearch(c *context.Context, opts *UserSearchOptions) { } count = opts.Counter(c.Req.Context()) } else { - users, count, err = db.SearchUserByName(&db.SearchUserOptions{ - Keyword: keyword, - Type: opts.Type, - OrderBy: opts.OrderBy, - Page: page, - PageSize: opts.PageSize, - }) + search := db.Users.SearchByName + if opts.Type == db.UserTypeOrganization { + search = db.Orgs.SearchByName + } + users, count, err = search(c.Req.Context(), keyword, page, opts.PageSize, opts.OrderBy) if err != nil { - c.Error(err, "search user by name") + c.Error(err, "search by name") return } } |