2020-01-15 04:04:33 +01:00
|
|
|
package form
|
|
|
|
|
|
|
|
import "time"
|
|
|
|
|
|
|
|
// GeoSearch represents search form fields for "/api/v1/geo".
|
|
|
|
type GeoSearch struct {
|
2020-04-24 10:07:13 +02:00
|
|
|
Query string `form:"q"`
|
2020-05-23 20:58:58 +02:00
|
|
|
Type string `form:"type"`
|
|
|
|
Path string `form:"path"`
|
|
|
|
Folder string `form:"folder"` // Alias for Path
|
|
|
|
Name string `form:"name"`
|
2020-04-24 10:07:13 +02:00
|
|
|
Before time.Time `form:"before" time_format:"2006-01-02"`
|
|
|
|
After time.Time `form:"after" time_format:"2006-01-02"`
|
|
|
|
Favorite bool `form:"favorite"`
|
2020-05-23 20:58:58 +02:00
|
|
|
Video bool `form:"video"`
|
|
|
|
Photo bool `form:"photo"`
|
2020-04-26 11:41:54 +02:00
|
|
|
Lat float32 `form:"lat"`
|
|
|
|
Lng float32 `form:"lng"`
|
2020-04-24 10:07:13 +02:00
|
|
|
S2 string `form:"s2"`
|
|
|
|
Olc string `form:"olc"`
|
|
|
|
Dist uint `form:"dist"`
|
2020-04-24 13:25:04 +02:00
|
|
|
Quality int `form:"quality"`
|
|
|
|
Review bool `form:"review"`
|
2020-05-23 20:58:58 +02:00
|
|
|
Album string `form:"album"`
|
|
|
|
Country string `form:"country"`
|
|
|
|
Year int `form:"year"`
|
|
|
|
Month int `form:"month"`
|
|
|
|
Color string `form:"color"`
|
|
|
|
Camera int `form:"camera"`
|
|
|
|
Lens int `form:"lens"`
|
2020-01-15 04:04:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetQuery returns the query parameter as string.
|
|
|
|
func (f *GeoSearch) GetQuery() string {
|
|
|
|
return f.Query
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetQuery sets the query parameter.
|
|
|
|
func (f *GeoSearch) SetQuery(q string) {
|
|
|
|
f.Query = q
|
|
|
|
}
|
|
|
|
|
|
|
|
// ParseQueryString parses the query parameter if possible.
|
|
|
|
func (f *GeoSearch) ParseQueryString() error {
|
2020-05-23 20:58:58 +02:00
|
|
|
err := ParseQueryString(f)
|
|
|
|
|
|
|
|
if f.Path == "" && f.Folder != "" {
|
|
|
|
f.Path = f.Folder
|
|
|
|
}
|
|
|
|
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// Serialize returns a string containing non-empty fields and values of a struct.
|
|
|
|
func (f *GeoSearch) Serialize() string {
|
|
|
|
return Serialize(f, false)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SerializeAll returns a string containing all non-empty fields and values of a struct.
|
|
|
|
func (f *GeoSearch) SerializeAll() string {
|
|
|
|
return Serialize(f, true)
|
2020-01-15 04:04:33 +01:00
|
|
|
}
|
2020-01-28 22:16:59 +01:00
|
|
|
|
|
|
|
func NewGeoSearch(query string) GeoSearch {
|
|
|
|
return GeoSearch{Query: query}
|
|
|
|
}
|