place.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Package models
  2. package models
  3. import "time"
  4. type Place struct {
  5. ID string `json:"id"`
  6. Type string `json:"type"`
  7. OwnerID string `json:"owner_id"`
  8. Title string `json:"title"`
  9. Description *string `json:"description"`
  10. Address *string `json:"address"`
  11. Lat float64 `json:"lat"`
  12. Lng float64 `json:"lng"`
  13. CoverImage *string `json:"cover_image"`
  14. AccessInfo *string `json:"access_info"`
  15. Status string `json:"status"`
  16. ModerationComment *string `json:"moderation_comment,omitempty"`
  17. Rating float64 `json:"rating"`
  18. ReviewsCount int `json:"reviews_count"`
  19. HourlyRate *int `json:"hourly_rate,omitempty"`
  20. Currency string `json:"currency"`
  21. MinHours int `json:"min_hours"`
  22. BookingURL *string `json:"booking_url,omitempty"`
  23. Tags []Tag `json:"tags"`
  24. Features []Feature `json:"features"`
  25. Images []PlaceImage `json:"images,omitempty"`
  26. Owner *User `json:"owner,omitempty"`
  27. Version int `json:"version"`
  28. CreatedAt time.Time `json:"created_at"`
  29. UpdatedAt time.Time `json:"updated_at"`
  30. PublishedAt *time.Time `json:"published_at,omitempty"`
  31. DeletedAt *time.Time `json:"-"`
  32. }
  33. type PlaceImage struct {
  34. ID string `json:"id"`
  35. PlaceID string `json:"place_id"`
  36. URL string `json:"url"`
  37. Alt string `json:"alt"`
  38. SortOrder int `json:"sort_order"`
  39. IsCover bool `json:"is_cover"`
  40. }
  41. type PlaceFilter struct {
  42. Type string
  43. OwnerID string
  44. TagIDs []string
  45. FeatureIDs []string
  46. MinRating float64
  47. PriceMin *int
  48. PriceMax *int
  49. Bounds *Bounds
  50. Limit_ int
  51. Sort string
  52. UserLat *float64
  53. UserLng *float64
  54. Status string
  55. IncludeTagsFeatures bool
  56. Cursor string
  57. CursorCreatedAt *time.Time
  58. CursorRating *float64
  59. }
  60. type PaginatedPlaces struct {
  61. Data []*Place `json:"data"`
  62. NextCursor string `json:"next_cursor"`
  63. HasMore bool `json:"has_more"`
  64. }
  65. type Bounds struct {
  66. SWLat float64
  67. SWLng float64
  68. NELat float64
  69. NELng float64
  70. }
  71. func (f PlaceFilter) Limit() int {
  72. if f.Limit_ <= 0 || f.Limit_ > 100 {
  73. return 20
  74. }
  75. return f.Limit_
  76. }