diff --git a/pkg/apiserver/openpitrix/applications.go b/pkg/apiserver/openpitrix/applications.go index 8fafc9a17db53184fa7e0d40937f5528bccad31f..f536cf85ff48658147aa17d48a8e493f92498315 100644 --- a/pkg/apiserver/openpitrix/applications.go +++ b/pkg/apiserver/openpitrix/applications.go @@ -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 diff --git a/pkg/models/openpitrix/applications.go b/pkg/models/openpitrix/applications.go index f7a3751abdadcd701eb230c45927c070e5550570..2254f1619a24ad9f6250266a4c502848205d923e 100644 --- a/pkg/models/openpitrix/applications.go +++ b/pkg/models/openpitrix/applications.go @@ -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) diff --git a/pkg/models/openpitrix/apps.go b/pkg/models/openpitrix/apps.go index 215dbc9eb6958a548e09144e737d4c9870444eb3..1ba62acfb910c0c00959c514b52332e50bdafcb8 100644 --- a/pkg/models/openpitrix/apps.go +++ b/pkg/models/openpitrix/apps.go @@ -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) diff --git a/pkg/models/openpitrix/categories.go b/pkg/models/openpitrix/categories.go index f827a71a866b05559d26f32f216dc4695b23bfed..7215151ce91b80eb3f07dfcc226937791bd0c6a1 100644 --- a/pkg/models/openpitrix/categories.go +++ b/pkg/models/openpitrix/categories.go @@ -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) diff --git a/pkg/models/openpitrix/repos.go b/pkg/models/openpitrix/repos.go index 5954336d4cb3a0093f0ad56fea530bdd79e4bd88..754cc63d07634ec8c206775d6e0a3405d330d754 100644 --- a/pkg/models/openpitrix/repos.go +++ b/pkg/models/openpitrix/repos.go @@ -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)