fix openpitrix resource sort param

Signed-off-by: hongming <talonwan@yunify.com>
This commit is contained in:
hongming
2019-11-08 17:13:26 +08:00
parent 7a909e574e
commit 981669ca5a
5 changed files with 11 additions and 6 deletions

View File

@@ -42,6 +42,11 @@ func ListApplications(req *restful.Request, resp *restful.Response) {
orderBy := req.QueryParameter(params.OrderByParam)
reverse := params.ParseReverse(req)
if orderBy == "" {
orderBy = "create_time"
reverse = true
}
if err != nil {
resp.WriteHeaderAndEntity(http.StatusBadRequest, errors.Wrap(err))
return

View File

@@ -83,7 +83,7 @@ func ListApplications(conditions *params.Conditions, limit, offset int, orderBy
if orderBy != "" {
describeClustersRequest.SortKey = &wrappers.StringValue{Value: orderBy}
}
describeClustersRequest.Reverse = &wrappers.BoolValue{Value: reverse}
describeClustersRequest.Reverse = &wrappers.BoolValue{Value: !reverse}
resp, err := client.Cluster().DescribeClusters(openpitrix.SystemContext(), describeClustersRequest)
if err != nil {
klog.Errorln(err)

View File

@@ -587,7 +587,7 @@ func ListAppVersionAudits(conditions *params.Conditions, orderBy string, reverse
if orderBy != "" {
describeAppVersionAudits.SortKey = &wrappers.StringValue{Value: orderBy}
}
describeAppVersionAudits.Reverse = &wrappers.BoolValue{Value: reverse}
describeAppVersionAudits.Reverse = &wrappers.BoolValue{Value: !reverse}
describeAppVersionAudits.Limit = uint32(limit)
describeAppVersionAudits.Offset = uint32(offset)
resp, err := client.App().DescribeAppVersionAudits(openpitrix.SystemContext(), describeAppVersionAudits)
@@ -626,7 +626,7 @@ func ListAppVersionReviews(conditions *params.Conditions, orderBy string, revers
if orderBy != "" {
describeAppVersionReviews.SortKey = &wrappers.StringValue{Value: orderBy}
}
describeAppVersionReviews.Reverse = &wrappers.BoolValue{Value: reverse}
describeAppVersionReviews.Reverse = &wrappers.BoolValue{Value: !reverse}
describeAppVersionReviews.Limit = uint32(limit)
describeAppVersionReviews.Offset = uint32(offset)
// TODO icon is needed
@@ -669,7 +669,7 @@ func ListAppVersions(conditions *params.Conditions, orderBy string, reverse bool
if orderBy != "" {
describeAppVersionsRequest.SortKey = &wrappers.StringValue{Value: orderBy}
}
describeAppVersionsRequest.Reverse = &wrappers.BoolValue{Value: reverse}
describeAppVersionsRequest.Reverse = &wrappers.BoolValue{Value: !reverse}
describeAppVersionsRequest.Limit = uint32(limit)
describeAppVersionsRequest.Offset = uint32(offset)
resp, err := client.App().DescribeAppVersions(openpitrix.SystemContext(), describeAppVersionsRequest)

View File

@@ -144,7 +144,7 @@ func ListCategories(conditions *params.Conditions, orderBy string, reverse bool,
if orderBy != "" {
req.SortKey = &wrappers.StringValue{Value: orderBy}
}
req.Reverse = &wrappers.BoolValue{Value: reverse}
req.Reverse = &wrappers.BoolValue{Value: !reverse}
req.Limit = uint32(limit)
req.Offset = uint32(offset)
resp, err := client.Category().DescribeCategories(openpitrix.SystemContext(), req)

View File

@@ -190,7 +190,7 @@ func ListRepos(conditions *params.Conditions, orderBy string, reverse bool, limi
if orderBy != "" {
req.SortKey = &wrappers.StringValue{Value: orderBy}
}
req.Reverse = &wrappers.BoolValue{Value: reverse}
req.Reverse = &wrappers.BoolValue{Value: !reverse}
req.Limit = uint32(limit)
req.Offset = uint32(offset)
resp, err := client.Repo().DescribeRepos(openpitrix.SystemContext(), req)