diff --git a/model/permission_request.go b/model/permission_request.go index 6d0eb34..fd59f60 100644 --- a/model/permission_request.go +++ b/model/permission_request.go @@ -27,6 +27,7 @@ type PermissionUpdateOptions struct { type PermissionAllQuery struct { Page int64 Limit int64 + Sort interface{} } // Validate ... diff --git a/model/role_request.go b/model/role_request.go index e976e12..a1d97a6 100644 --- a/model/role_request.go +++ b/model/role_request.go @@ -22,6 +22,7 @@ type RoleUpdateOptions struct { type RoleAllQuery struct { Page int64 Limit int64 + Sort interface{} } // Validate ... diff --git a/model/user_request.go b/model/user_request.go index 7a2cb40..ab95ea5 100644 --- a/model/user_request.go +++ b/model/user_request.go @@ -39,6 +39,7 @@ type UserAllQuery struct { Keyword string RoleID string Status string + Sort interface{} } // Validate ... diff --git a/permission/handle.go b/permission/handle.go index bb20486..87790d9 100644 --- a/permission/handle.go +++ b/permission/handle.go @@ -104,7 +104,7 @@ func All(queryParams model.PermissionAllQuery) (r model.PermissionAll) { query := model.CommonQuery{ Page: queryParams.Page, Limit: queryParams.Limit, - Sort: bson.M{"createdAt": -1}, + Sort: queryParams.Sort, } // Assign condition diff --git a/role/handle.go b/role/handle.go index 071bff1..79923d3 100644 --- a/role/handle.go +++ b/role/handle.go @@ -102,7 +102,7 @@ func All(queryParams model.RoleAllQuery) (r model.RoleAll) { query := model.CommonQuery{ Page: queryParams.Page, Limit: queryParams.Limit, - Sort: bson.M{"createdAt": -1}, + Sort: queryParams.Sort, } // Assign condition diff --git a/user/handle.go b/user/handle.go index a1c97eb..0b252cc 100644 --- a/user/handle.go +++ b/user/handle.go @@ -87,7 +87,7 @@ func All(queryParams model.UserAllQuery) (r model.UserAll) { Keyword: queryParams.Keyword, RoleID: queryParams.RoleID, Status: queryParams.Status, - Sort: bson.M{"createdAt": -1}, + Sort: queryParams.Sort, } // Assign condition