place.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. TagIDs []string
  43. FeatureIDs []string
  44. MinRating float64
  45. PriceMin *int
  46. PriceMax *int
  47. Bounds *Bounds
  48. Limit_ int
  49. Sort string
  50. UserLat *float64
  51. UserLng *float64
  52. Status string
  53. }
  54. type Bounds struct {
  55. SWLat float64
  56. SWLng float64
  57. NELat float64
  58. NELng float64
  59. }
  60. func (f PlaceFilter) Limit() int {
  61. if f.Limit_ <= 0 || f.Limit_ > 100 {
  62. return 20
  63. }
  64. return f.Limit_
  65. }