fix robot list issue

fixes #13985
Add sorting for listing the robot account

Signed-off-by: Wang Yan <wangyan@vmware.com>
This commit is contained in:
Wang Yan 2021-01-15 11:22:46 +08:00
parent 74d055b26b
commit df8e7c45e3
2 changed files with 7 additions and 0 deletions

View File

@ -119,6 +119,9 @@ func (d *dao) List(ctx context.Context, query *q.Query) ([]*model.Robot, error)
if err != nil {
return nil, err
}
if query.Sorting != "" {
qs = qs.OrderBy(query.Sorting)
}
if _, err = qs.All(&robots); err != nil {
return nil, err
}

View File

@ -81,5 +81,9 @@ func (m *manager) Update(ctx context.Context, r *model.Robot, props ...string) e
// List ...
func (m *manager) List(ctx context.Context, query *q.Query) ([]*model.Robot, error) {
query = q.MustClone(query)
if query.Sorting == "" {
query.Sorting = "name"
}
return m.dao.List(ctx, query)
}