refactor(db): migrate methods off user.go (#7331)

This commit is contained in:
Joe Chen
2023-02-04 00:02:34 +08:00
committed by GitHub
parent c53a1998c5
commit cc4d4eacad
9 changed files with 288 additions and 81 deletions

View File

@@ -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(),
pageSize := c.QueryInt("limit")
if pageSize <= 0 {
pageSize = 10
}
if opts.PageSize == 0 {
opts.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,