From cc4d4eacad6b6a92ebb3380715dcaee3bcc5fd41 Mon Sep 17 00:00:00 2001 From: Joe Chen Date: Sat, 4 Feb 2023 00:02:34 +0800 Subject: refactor(db): migrate methods off `user.go` (#7331) --- internal/route/api/v1/user/user.go | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'internal/route/api/v1/user') diff --git a/internal/route/api/v1/user/user.go b/internal/route/api/v1/user/user.go index b311f68b..d956f0c6 100644 --- a/internal/route/api/v1/user/user.go +++ b/internal/route/api/v1/user/user.go @@ -7,8 +7,6 @@ package user import ( "net/http" - "github.com/unknwon/com" - api "github.com/gogs/go-gogs-client" "gogs.io/gogs/internal/context" @@ -17,16 +15,11 @@ import ( ) func Search(c *context.APIContext) { - opts := &db.SearchUserOptions{ - Keyword: c.Query("q"), - Type: db.UserTypeIndividual, - PageSize: com.StrTo(c.Query("limit")).MustInt(), - } - if opts.PageSize == 0 { - opts.PageSize = 10 + pageSize := c.QueryInt("limit") + if pageSize <= 0 { + pageSize = 10 } - - users, _, err := db.SearchUserByName(opts) + users, _, err := db.Users.SearchByName(c.Req.Context(), c.Query("q"), 1, pageSize, "") if err != nil { c.JSON(http.StatusInternalServerError, map[string]any{ "ok": false, -- cgit v1.2.3