@@ -9,7 +9,18 @@ import (
99 "github.com/kunalkumar-1/Evently/internals/database"
1010)
1111
12- // create event handler
12+ // CreateEvent creates a new event
13+ // @Summary Create a new event
14+ // @Description Create a new event owned by the authenticated user
15+ // @Tags Events
16+ // @Accept json
17+ // @Produce json
18+ // @Param event body database.Event true "Event Data"
19+ // @Success 201 {object} database.Event
20+ // @Failure 400 {object} map[string]string
21+ // @Failure 500 {object} map[string]string
22+ // @Router /events [post]
23+ // @Security BearerAuth
1324func (app * application ) createEvent (c * gin.Context ) {
1425
1526 var event database.Event
@@ -39,7 +50,16 @@ func (app *application) createEvent(c *gin.Context) {
3950 c .JSON (http .StatusCreated , event )
4051}
4152
42- // get all events
53+ // GetAllEvent returns all events
54+ // @Summary Get all events
55+ // @Description Retrieve a list of all available events
56+ // @Tags Events
57+ // @Accept json
58+ // @Produce json
59+ // @Success 200 {array} database.Event
60+ // @Failure 500 {object} map[string]string "Failed to retrieve events"
61+ // @Router /events [get]
62+
4363func (app * application ) getAllEvent (c * gin.Context ) {
4464 events , err := app .models .Events .GetAll ()
4565 if err != nil {
@@ -51,7 +71,17 @@ func (app *application) getAllEvent(c *gin.Context) {
5171 c .JSON (http .StatusOK , events )
5272}
5373
54- // get events
74+ // GetEvent retrieves an event by ID
75+ // @Summary Get event by ID
76+ // @Description Retrieve details of a specific event
77+ // @Tags Events
78+ // @Accept json
79+ // @Produce json
80+ // @Param id path int true "Event ID"
81+ // @Success 200 {object} database.Event
82+ // @Failure 400 {object} map[string]string
83+ // @Failure 404 {object} map[string]string
84+ // @Router /events/{id} [get]
5585func (app * application ) getEvent (c * gin.Context ) {
5686 id , err := strconv .Atoi (c .Param ("id" ))
5787 if err != nil {
@@ -78,7 +108,20 @@ func (app *application) getEvent(c *gin.Context) {
78108 c .JSON (http .StatusCreated , event )
79109}
80110
81- // update event
111+ // UpdateEvent updates an existing event
112+ // @Summary Update event
113+ // @Description Update an existing event by ID (only by owner)
114+ // @Tags Events
115+ // @Accept json
116+ // @Produce json
117+ // @Param id path int true "Event ID"
118+ // @Param event body database.Event true "Updated Event Data"
119+ // @Success 200 {object} database.Event
120+ // @Failure 400 {object} map[string]string
121+ // @Failure 403 {object} map[string]string
122+ // @Failure 500 {object} map[string]string
123+ // @Router /events/{id} [put]
124+ // @Security BearerAuth
82125func (app * application ) updateEvent (c * gin.Context ) {
83126 id , err := strconv .Atoi (c .Param ("id" )) // get event id from url
84127 if err != nil {
@@ -137,7 +180,17 @@ func (app *application) updateEvent(c *gin.Context) {
137180 c .JSON (http .StatusOK , updatedEvent )
138181}
139182
140- // delete event
183+ // DeleteEvent deletes an event by ID
184+ // @Summary Delete event
185+ // @Description Delete an event by ID (only by owner)
186+ // @Tags Events
187+ // @Param id path int true "Event ID"
188+ // @Success 204 {object} nil
189+ // @Failure 400 {object} map[string]string
190+ // @Failure 403 {object} map[string]string
191+ // @Failure 404 {object} map[string]string
192+ // @Router /events/{id} [delete]
193+ // @Security BearerAuth
141194func (app * application ) deleteEvent (c * gin.Context ) {
142195 id , err := strconv .Atoi (c .Param ("id" ))
143196 if err != nil {
@@ -178,6 +231,18 @@ func (app *application) deleteEvent(c *gin.Context) {
178231
179232}
180233
234+ // AddAttendeeToEvent adds a user to an event
235+ // @Summary Add attendee to event
236+ // @Description Adds a user as an attendee to a specific event
237+ // @Tags Attendees
238+ // @Param id path int true "Event ID"
239+ // @Param userId path int true "User ID"
240+ // @Success 201 {object} database.Attendee
241+ // @Failure 400 {object} map[string]string
242+ // @Failure 403 {object} map[string]string
243+ // @Failure 404 {object} map[string]string
244+ // @Router /events/{id}/attendees/{userId} [post]
245+ // @Security BearerAuth
181246func (app * application ) addAttendeeToEvent (c * gin.Context ) {
182247 eventId , err := strconv .Atoi (c .Param ("id" ))
183248 if err != nil {
@@ -262,6 +327,14 @@ func (app *application) addAttendeeToEvent(c *gin.Context) {
262327 c .JSON (http .StatusCreated , attendee )
263328}
264329
330+ // GetAttendeesForEvent retrieves attendees for a given event
331+ // @Summary Get attendees for event
332+ // @Description Get a list of all attendees for a specific event
333+ // @Tags Attendees
334+ // @Param id path int true "Event ID"
335+ // @Success 200 {array} database.Attendee
336+ // @Failure 400 {object} map[string]string
337+ // @Router /events/{id}/attendees [get]
265338func (app * application ) getAttendeesForEvent (c * gin.Context ) {
266339 id , err := strconv .Atoi (c .Param ("id" ))
267340 if err != nil {
0 commit comments