feat: add sorts support for the projects listing API (#14425)

Signed-off-by: He Weiwei <hweiwei@vmware.com>
This commit is contained in:
He Weiwei 2021-03-12 15:04:08 +08:00 committed by GitHub
parent 0d4992a41e
commit 85f9a49bc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -151,6 +151,7 @@ paths:
operationId: listProjects
parameters:
- $ref: '#/parameters/requestId'
- $ref: '#/parameters/query'
- $ref: '#/parameters/page'
- $ref: '#/parameters/pageSize'
- $ref: '#/parameters/sort'

View File

@ -378,9 +378,10 @@ func (a *projectAPI) HeadProject(ctx context.Context, params operation.HeadProje
}
func (a *projectAPI) ListProjects(ctx context.Context, params operation.ListProjectsParams) middleware.Responder {
query := q.New(q.KeyWords{})
query.PageNumber = *params.Page
query.PageSize = *params.PageSize
query, err := a.BuildQuery(ctx, params.Q, params.Sort, params.Page, params.PageSize)
if err != nil {
return a.SendError(ctx, err)
}
if name := lib.StringValue(params.Name); name != "" {
query.Keywords["name"] = &q.FuzzyMatchValue{Value: name}
@ -642,7 +643,7 @@ func (a *projectAPI) validateProjectReq(ctx context.Context, req *models.Project
func (a *projectAPI) populateProperties(ctx context.Context, p *project.Project) error {
if secCtx, ok := security.FromContext(ctx); ok {
if sc, ok := secCtx.(*local.SecurityContext); ok {
roles, err := pro.ListRoles(sc.User(), p.ProjectID)
roles, err := a.projectCtl.ListRoles(ctx, p.ProjectID, sc.User())
if err != nil {
return err
}