Order & Sorting
This commit is contained in:
@@ -27,8 +27,8 @@ type AlbumFilter struct {
|
||||
}
|
||||
|
||||
type AlbumResponse struct {
|
||||
Data []*Album `json:"data" `
|
||||
PageInfo *PageInfo `json:"pageInfo" `
|
||||
Data []*Album `json:"data" `
|
||||
Page *PageResponse `json:"page" `
|
||||
}
|
||||
|
||||
type AuthResponse struct {
|
||||
@@ -66,8 +66,8 @@ type DeviceFilter struct {
|
||||
}
|
||||
|
||||
type DeviceResponse struct {
|
||||
Data []*Device `json:"data" `
|
||||
PageInfo *PageInfo `json:"pageInfo" `
|
||||
Data []*Device `json:"data" `
|
||||
Page *PageResponse `json:"page" `
|
||||
}
|
||||
|
||||
type DeviceTypeFilter struct {
|
||||
@@ -127,8 +127,8 @@ type MediaItemFilter struct {
|
||||
}
|
||||
|
||||
type MediaItemResponse struct {
|
||||
Data []*MediaItem `json:"data" `
|
||||
PageInfo *PageInfo `json:"pageInfo" `
|
||||
Data []*MediaItem `json:"data" `
|
||||
Page *PageResponse `json:"page" `
|
||||
}
|
||||
|
||||
type NewAlbum struct {
|
||||
@@ -155,8 +155,18 @@ type NewUser struct {
|
||||
Password *string `json:"password" `
|
||||
}
|
||||
|
||||
type PageInfo struct {
|
||||
Count int `json:"count" `
|
||||
type Order struct {
|
||||
By *string `json:"by" `
|
||||
Direction *OrderDirection `json:"direction" `
|
||||
}
|
||||
|
||||
type Page struct {
|
||||
Size *int `json:"size" `
|
||||
Page *int `json:"page" `
|
||||
}
|
||||
|
||||
type PageResponse struct {
|
||||
Size int `json:"size" `
|
||||
Page int `json:"page" `
|
||||
Total int `json:"total" `
|
||||
}
|
||||
@@ -193,8 +203,8 @@ type TagFilter struct {
|
||||
}
|
||||
|
||||
type TagResponse struct {
|
||||
Data []*Tag `json:"data" `
|
||||
PageInfo *PageInfo `json:"pageInfo" `
|
||||
Data []*Tag `json:"data" `
|
||||
Page *PageResponse `json:"page" `
|
||||
}
|
||||
|
||||
type TimeFilter struct {
|
||||
@@ -233,8 +243,8 @@ type UserFilter struct {
|
||||
}
|
||||
|
||||
type UserResponse struct {
|
||||
Data []*User `json:"data" `
|
||||
PageInfo *PageInfo `json:"pageInfo" `
|
||||
Data []*User `json:"data" `
|
||||
Page *PageResponse `json:"page" `
|
||||
}
|
||||
|
||||
type AuthResult string
|
||||
@@ -372,6 +382,47 @@ func (e DeviceType) MarshalGQL(w io.Writer) {
|
||||
fmt.Fprint(w, strconv.Quote(e.String()))
|
||||
}
|
||||
|
||||
type OrderDirection string
|
||||
|
||||
const (
|
||||
OrderDirectionAsc OrderDirection = "ASC"
|
||||
OrderDirectionDesc OrderDirection = "DESC"
|
||||
)
|
||||
|
||||
var AllOrderDirection = []OrderDirection{
|
||||
OrderDirectionAsc,
|
||||
OrderDirectionDesc,
|
||||
}
|
||||
|
||||
func (e OrderDirection) IsValid() bool {
|
||||
switch e {
|
||||
case OrderDirectionAsc, OrderDirectionDesc:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (e OrderDirection) String() string {
|
||||
return string(e)
|
||||
}
|
||||
|
||||
func (e *OrderDirection) UnmarshalGQL(v interface{}) error {
|
||||
str, ok := v.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("enums must be strings")
|
||||
}
|
||||
|
||||
*e = OrderDirection(str)
|
||||
if !e.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid OrderDirection", str)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e OrderDirection) MarshalGQL(w io.Writer) {
|
||||
fmt.Fprint(w, strconv.Quote(e.String()))
|
||||
}
|
||||
|
||||
type Role string
|
||||
|
||||
const (
|
||||
|
||||
Reference in New Issue
Block a user