Working on integrating backend with ui

This commit is contained in:
viktorstrate
2020-02-09 15:26:59 +01:00
parent d50b8034d1
commit e6593ee7f3
12 changed files with 407 additions and 40 deletions

View File

@@ -3,6 +3,9 @@
package models
import (
"fmt"
"io"
"strconv"
"time"
)
@@ -12,6 +15,13 @@ type AuthorizeResult struct {
Token *string `json:"token"`
}
type Filter struct {
OrderBy *string `json:"order_by"`
OrderDirection *OrderDirection `json:"order_direction"`
Limit *int `json:"limit"`
Offset *int `json:"offset"`
}
// EXIF metadata from the camera
type PhotoExif struct {
Photo *Photo `json:"photo"`
@@ -47,3 +57,44 @@ type ScannerResult struct {
type SiteInfo struct {
InitialSetup bool `json:"initialSetup"`
}
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()))
}