-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevent_occurrence.go
More file actions
151 lines (131 loc) · 6.17 KB
/
event_occurrence.go
File metadata and controls
151 lines (131 loc) · 6.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
package models
import (
"strconv"
"time"
"github.com/google/uuid"
)
type EventOccurrenceStatus string
const (
EventOccurrenceStatusScheduled EventOccurrenceStatus = "scheduled"
EventOccurrenceStatusCancelled EventOccurrenceStatus = "cancelled"
)
type EventOccurrence struct {
ID uuid.UUID `json:"id" db:"id"`
ManagerId *uuid.UUID `json:"manager_id" db:"manager_id"`
Event Event `json:"event" db:"-"`
Location Location `json:"location" db:"-"`
StartTime time.Time `json:"start_time" db:"start_time"`
EndTime time.Time `json:"end_time" db:"end_time"`
MaxAttendees int `json:"max_attendees" db:"max_attendees"`
Language string `json:"language" db:"language"`
CurrEnrolled int `json:"curr_enrolled" db:"curr_enrolled"`
Price int `json:"price" db:"price" doc:"Price in cents (e.g., 10000 = $100)"`
Currency string `json:"currency" db:"currency" doc:"Currency code (e.g., thb, usd)"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
Status EventOccurrenceStatus `json:"status" db:"status" doc:"Current status of the event occurrence" enum:"scheduled,cancelled"`
}
type GetAllEventOccurrencesInput struct {
AcceptLanguage string `header:"Accept-Language" default:"en-US" enum:"en-US,th-TH"`
Page int `query:"page" minimum:"1" default:"1"`
Limit int `query:"limit" minimum:"1" maximum:"100" default:"100"`
Search string `query:"search"`
Latitude OptionalFloat64 `query:"lat"`
Longitude OptionalFloat64 `query:"lng"`
RadiusKm float64 `query:"radius_km"`
MinPrice int `query:"min_price"`
MaxPrice int `query:"max_price"`
MinDuration int `query:"min_duration"`
MaxDuration int `query:"max_duration"`
MinAge int `query:"min_age"`
MaxAge int `query:"max_age"`
Category string `query:"category"`
SoldOut bool `query:"soldout"`
MinDate time.Time `query:"min_date"`
MaxDate time.Time `query:"max_date"`
}
type GetAllEventOccurrencesFilter struct {
Search *string
Latitude *float64
Longitude *float64
RadiusKm *float64
MinPrice *int
MaxPrice *int
MinDurationMinutes *int
MaxDurationMinutes *int
MinAge *int
MaxAge *int
Category *string
SoldOut *bool
MinDate *time.Time
MaxDate *time.Time
}
type GetAllEventOccurrencesOutput struct {
Body []EventOccurrence `json:"body" doc:"List of all event occurrences in the database"`
}
type GetEventOccurrenceByIDInput struct {
AcceptLanguage string `header:"Accept-Language" default:"en-US" enum:"en-US,th-TH"`
ID uuid.UUID `path:"id" doc:"ID of an event occurrence"`
}
type OptionalFloat64 struct {
Value float64
Set bool
}
type GetEventOccurrenceByIDOutput struct {
Body *EventOccurrence `json:"body" doc:"Event occurrence in the database that matches the ID"`
}
type CreateEventOccurrenceInput struct {
AcceptLanguage string `header:"Accept-Language" default:"en-US" enum:"en-US,th-TH"`
Body struct {
ManagerId *uuid.UUID `json:"manager_id,omitempty" doc:"ID of a manager in the database"`
EventId uuid.UUID `json:"event_id" doc:"ID of an event in the database"`
StartTime time.Time `json:"start_time" doc:"Start time of the event occurrence"`
EndTime time.Time `json:"end_time" doc:"End time of the event occurrence"`
MaxAttendees int `json:"max_attendees" doc:"Maximum number of attendees" minimum:"1" maximum:"100"`
Language string `json:"language" doc:"Primary language used for the event occurrence" minLength:"2" maxLength:"30"`
Price int `json:"price" doc:"Price in cents (e.g., 10000 = ฿100)" minimum:"0"`
Currency string `json:"currency" doc:"Currency code (e.g., thb, usd)"`
} `json:"body" doc:"New event occurrence to add"`
}
type CreateEventOccurrenceOutput struct {
Body *EventOccurrence `json:"body" doc:"Created event occurrence"`
}
type UpdateEventOccurrenceInput struct {
AcceptLanguage string `header:"Accept-Language" default:"en-US" enum:"en-US,th-TH"`
ID uuid.UUID `path:"id" doc:"ID of the event occurrence to update"`
Body struct {
ManagerId *uuid.UUID `json:"manager_id,omitempty" doc:"ID of a manager in the database"`
EventId *uuid.UUID `json:"event_id,omitempty" doc:"ID of an event in the database"`
StartTime *time.Time `json:"start_time,omitempty" doc:"Start time of the event occurrence"`
EndTime *time.Time `json:"end_time,omitempty" doc:"End time of the event occurrence"`
MaxAttendees *int `json:"max_attendees,omitempty" doc:"Maximum number of attendees" minimum:"1" maximum:"100"`
Language *string `json:"language,omitempty" doc:"Primary language used for the event occurrence" minLength:"2" maxLength:"30"`
CurrEnrolled *int `json:"curr_enrolled,omitempty" doc:"Number of students currently enrolled in the event occurrence" minimum:"0" maximum:"100"`
Price *int `json:"price,omitempty" doc:"Price in lowest denomination of currency" minimum:"0"`
Currency *string `json:"currency,omitempty" doc:"Currency code" minLength:"3" maxLength:"3"`
} `json:"body" doc:"Event occurrence fields to update"`
}
type UpdateEventOccurrenceOutput struct {
Body *EventOccurrence `json:"body" doc:"Updated event occurrence"`
}
type CancelEventOccurrenceInput struct {
ID uuid.UUID `path:"id" doc:"ID of an event occurrence"`
}
type CancelEventOccurrenceOutput struct {
Body struct {
Message string `json:"message" doc:"Success message"`
} `json:"body"`
}
func (o *OptionalFloat64) UnmarshalText(text []byte) error {
if len(text) == 0 {
o.Set = false
return nil
}
v, err := strconv.ParseFloat(string(text), 64)
if err != nil {
return err
}
o.Value = v
o.Set = true
return nil
}