|
|
@ -6,6 +6,7 @@ |
|
|
|
package org |
|
|
|
package org |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
|
|
|
|
"fmt" |
|
|
|
"net/http" |
|
|
|
"net/http" |
|
|
|
"strings" |
|
|
|
"strings" |
|
|
|
|
|
|
|
|
|
|
@ -650,15 +651,17 @@ func SearchTeam(ctx *context.APIContext) { |
|
|
|
// items:
|
|
|
|
// items:
|
|
|
|
// "$ref": "#/definitions/Team"
|
|
|
|
// "$ref": "#/definitions/Team"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
listOptions := utils.GetListOptions(ctx) |
|
|
|
|
|
|
|
|
|
|
|
opts := &models.SearchTeamOptions{ |
|
|
|
opts := &models.SearchTeamOptions{ |
|
|
|
UserID: ctx.User.ID, |
|
|
|
UserID: ctx.User.ID, |
|
|
|
Keyword: strings.TrimSpace(ctx.Query("q")), |
|
|
|
Keyword: strings.TrimSpace(ctx.Query("q")), |
|
|
|
OrgID: ctx.Org.Organization.ID, |
|
|
|
OrgID: ctx.Org.Organization.ID, |
|
|
|
IncludeDesc: (ctx.Query("include_desc") == "" || ctx.QueryBool("include_desc")), |
|
|
|
IncludeDesc: (ctx.Query("include_desc") == "" || ctx.QueryBool("include_desc")), |
|
|
|
ListOptions: utils.GetListOptions(ctx), |
|
|
|
ListOptions: listOptions, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
teams, _, err := models.SearchTeam(opts) |
|
|
|
teams, maxResults, err := models.SearchTeam(opts) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Error("SearchTeam failed: %v", err) |
|
|
|
log.Error("SearchTeam failed: %v", err) |
|
|
|
ctx.JSON(http.StatusInternalServerError, map[string]interface{}{ |
|
|
|
ctx.JSON(http.StatusInternalServerError, map[string]interface{}{ |
|
|
@ -681,6 +684,8 @@ func SearchTeam(ctx *context.APIContext) { |
|
|
|
apiTeams[i] = convert.ToTeam(teams[i]) |
|
|
|
apiTeams[i] = convert.ToTeam(teams[i]) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ctx.SetLinkHeader(int(maxResults), listOptions.PageSize) |
|
|
|
|
|
|
|
ctx.Header().Set("X-Total-Count", fmt.Sprintf("%d", maxResults)) |
|
|
|
ctx.JSON(http.StatusOK, map[string]interface{}{ |
|
|
|
ctx.JSON(http.StatusOK, map[string]interface{}{ |
|
|
|
"ok": true, |
|
|
|
"ok": true, |
|
|
|
"data": apiTeams, |
|
|
|
"data": apiTeams, |
|
|
|