diff options
author | Unknwon <u@gogs.io> | 2016-03-11 15:33:12 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-03-11 15:33:12 -0500 |
commit | 2bf8494332592b3c57f9a12a26b9abd356fb3f15 (patch) | |
tree | e46c61ba30018ebbafcda6b97b36d3ffece3cfb0 /routers/api/v1/user | |
parent | df2bdf7ea36ad0729e0326ca799d8896d7f96946 (diff) | |
download | gitea-2bf8494332592b3c57f9a12a26b9abd356fb3f15.tar.gz gitea-2bf8494332592b3c57f9a12a26b9abd356fb3f15.zip |
#13 finish user and repository search
Both are possible on explore and admin panel
Diffstat (limited to 'routers/api/v1/user')
-rw-r--r-- | routers/api/v1/user/user.go | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/routers/api/v1/user/user.go b/routers/api/v1/user/user.go index d08fd20241..71056894a5 100644 --- a/routers/api/v1/user/user.go +++ b/routers/api/v1/user/user.go @@ -15,15 +15,16 @@ import ( // https://github.com/gogits/go-gogs-client/wiki/Users#search-users func Search(ctx *context.Context) { - opt := models.SearchOption{ - Keyword: ctx.Query("q"), - Limit: com.StrTo(ctx.Query("limit")).MustInt(), + opts := &models.SearchUserOptions{ + Keyword: ctx.Query("q"), + Type: models.USER_TYPE_INDIVIDUAL, + PageSize: com.StrTo(ctx.Query("limit")).MustInt(), } - if opt.Limit == 0 { - opt.Limit = 10 + if opts.PageSize == 0 { + opts.PageSize = 10 } - us, err := models.SearchUserByName(opt) + users, _, err := models.SearchUserByName(opts) if err != nil { ctx.JSON(500, map[string]interface{}{ "ok": false, @@ -32,16 +33,16 @@ func Search(ctx *context.Context) { return } - results := make([]*api.User, len(us)) - for i := range us { + results := make([]*api.User, len(users)) + for i := range users { results[i] = &api.User{ - ID: us[i].Id, - UserName: us[i].Name, - AvatarUrl: us[i].AvatarLink(), - FullName: us[i].FullName, + ID: users[i].Id, + UserName: users[i].Name, + AvatarUrl: users[i].AvatarLink(), + FullName: users[i].FullName, } if ctx.IsSigned { - results[i].Email = us[i].Email + results[i].Email = users[i].Email } } |