aboutsummaryrefslogtreecommitdiff
path: root/internal/route/api/v1/user
diff options
context:
space:
mode:
authorJoe Chen <jc@unknwon.io>2023-02-04 00:02:34 +0800
committerGitHub <noreply@github.com>2023-02-04 00:02:34 +0800
commitcc4d4eacad6b6a92ebb3380715dcaee3bcc5fd41 (patch)
tree36889c562b8560c2065199ca4b1b01ccfad179c9 /internal/route/api/v1/user
parentc53a1998c589a544b25d53f6e6fdf0f24a4df25b (diff)
refactor(db): migrate methods off `user.go` (#7331)
Diffstat (limited to 'internal/route/api/v1/user')
-rw-r--r--internal/route/api/v1/user/user.go15
1 files changed, 4 insertions, 11 deletions
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,