place.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. CreatedAt time.Time `json:"created_at"`
  28. UpdatedAt time.Time `json:"updated_at"`
  29. PublishedAt *time.Time `json:"published_at,omitempty"`
  30. DeletedAt *time.Time `json:"-"`
  31. }
  32. type PlaceImage struct {
  33. ID string `json:"id"`
  34. PlaceID string `json:"place_id"`
  35. URL string `json:"url"`
  36. Alt string `json:"alt"`
  37. SortOrder int `json:"sort_order"`
  38. IsCover bool `json:"is_cover"`
  39. }
  40. type PlaceFilter struct {
  41. Type string
  42. OwnerID string
  43. TagIDs []string
  44. FeatureIDs []string
  45. MinRating float64
  46. PriceMin *int
  47. PriceMax *int
  48. Bounds *Bounds
  49. Limit_ int
  50. Sort string
  51. UserLat *float64
  52. UserLng *float64
  53. Status string
  54. IncludeTagsFeatures bool
  55. Cursor string
  56. CursorCreatedAt *time.Time
  57. CursorRating *float64
  58. }
  59. type PaginatedPlaces struct {
  60. Data []*Place `json:"data"`
  61. NextCursor string `json:"next_cursor"`
  62. HasMore bool `json:"has_more"`
  63. }
  64. type Bounds struct {
  65. SWLat float64
  66. SWLng float64
  67. NELat float64
  68. NELng float64
  69. }
  70. func (f PlaceFilter) Limit() int {
  71. if f.Limit_ <= 0 || f.Limit_ > 100 {
  72. return 20
  73. }
  74. return f.Limit_
  75. }