place.go 1.8 KB

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