Skip to content

fixed handling and documentation #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 51 additions & 3 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,54 @@ const docTemplate = `{
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/announcement/:id": {
"put": {
"description": "Updates the Announcement of choice in the database",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Announcements"
],
"summary": "Updates the Announcement of Choice",
"parameters": [
{
"type": "string",
"description": "Announcement ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {}
},
"delete": {
"description": "Deletes the Announcement of choice in the database",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Announcements"
],
"summary": "Deletes the Announcement of Choice",
"parameters": [
{
"type": "string",
"description": "Event ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {}
}
},
"/announcements": {
"post": {
"description": "Creates a new announcement and generates unique ID",
Expand Down Expand Up @@ -58,7 +106,7 @@ const docTemplate = `{
},
"/events": {
"get": {
"description": "Gets all the events from the event database",
"description": "Get all the events from the event database",
"consumes": [
"application/json"
],
Expand All @@ -68,7 +116,7 @@ const docTemplate = `{
"tags": [
"Events"
],
"summary": "Gets all the events",
"summary": "Get all the events",
"responses": {}
},
"post": {
Expand Down Expand Up @@ -121,7 +169,7 @@ const docTemplate = `{
"tags": [
"Events"
],
"summary": "Update the Event of Choice",
"summary": "Updates the Event of Choice",
"parameters": [
{
"type": "string",
Expand Down
54 changes: 51 additions & 3 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,54 @@
"contact": {}
},
"paths": {
"/announcement/:id": {
"put": {
"description": "Updates the Announcement of choice in the database",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Announcements"
],
"summary": "Updates the Announcement of Choice",
"parameters": [
{
"type": "string",
"description": "Announcement ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {}
},
"delete": {
"description": "Deletes the Announcement of choice in the database",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Announcements"
],
"summary": "Deletes the Announcement of Choice",
"parameters": [
{
"type": "string",
"description": "Event ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {}
}
},
"/announcements": {
"post": {
"description": "Creates a new announcement and generates unique ID",
Expand Down Expand Up @@ -47,7 +95,7 @@
},
"/events": {
"get": {
"description": "Gets all the events from the event database",
"description": "Get all the events from the event database",
"consumes": [
"application/json"
],
Expand All @@ -57,7 +105,7 @@
"tags": [
"Events"
],
"summary": "Gets all the events",
"summary": "Get all the events",
"responses": {}
},
"post": {
Expand Down Expand Up @@ -110,7 +158,7 @@
"tags": [
"Events"
],
"summary": "Update the Event of Choice",
"summary": "Updates the Event of Choice",
"parameters": [
{
"type": "string",
Expand Down
39 changes: 36 additions & 3 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
info:
contact: {}
paths:
/announcement/:id:
delete:
consumes:
- application/json
description: Deletes the Announcement of choice in the database
parameters:
- description: Event ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses: {}
summary: Deletes the Announcement of Choice
tags:
- Announcements
put:
consumes:
- application/json
description: Updates the Announcement of choice in the database
parameters:
- description: Announcement ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses: {}
summary: Updates the Announcement of Choice
tags:
- Announcements
/announcements:
post:
consumes:
Expand Down Expand Up @@ -33,11 +66,11 @@ paths:
get:
consumes:
- application/json
description: Gets all the events from the event database
description: Get all the events from the event database
produces:
- application/json
responses: {}
summary: Gets all the events
summary: Get all the events
tags:
- Events
post:
Expand Down Expand Up @@ -96,7 +129,7 @@ paths:
produces:
- application/json
responses: {}
summary: Update the Event of Choice
summary: Updates the Event of Choice
tags:
- Events
swagger: "2.0"
19 changes: 19 additions & 0 deletions internal/api/handlers/announcement_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,28 @@ func (h *AnnouncementHandler) CreateAnnouncement(c *gin.Context) {
})
}

// UpdateAnnouncement godoc
//
// @Summary Updates the Announcement of Choice
// @Description Updates the Announcement of choice in the database
// @Tags Announcements
// @Accept json
// @Produce json
// @Param id path string true "Announcement ID"
// @Router /announcement/:id [Put]
func (h *AnnouncementHandler) UpdateAnnouncement(c *gin.Context) {
panic("implement me (UpdateAnnouncement Handler)")
}

// DeleteAnnouncement godoc
//
// @Summary Deletes the Announcement of Choice
// @Description Deletes the Announcement of choice in the database
// @Tags Announcements
// @Accept json
// @Produce json
// @Param id path string true "Event ID"
// @Router /announcement/:id [Delete]
func (h *AnnouncementHandler) DeleteAnnouncement(c *gin.Context) {
panic("implement me (DeleteAnnouncement Handler)")
}
6 changes: 3 additions & 3 deletions internal/api/handlers/events_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ func (h *EventsHandler) CreateEvent(c *gin.Context) {

// GetEvents godoc
//
// @Summary Gets all the events
// @Description Gets all the events from the event database
// @Summary Get all the events
// @Description Get all the events from the event database
// @Tags Events
// @Accept json
// @Produce json
Expand All @@ -120,7 +120,7 @@ func (h *EventsHandler) GetEvents(c *gin.Context) {

// UpdateEvent godoc
//
// @Summary Update the Event of Choice
// @Summary Updates the Event of Choice
// @Description Updates the event of choice in the database
// @Tags Events
// @Accept json
Expand Down
2 changes: 1 addition & 1 deletion internal/api/routes/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ func SetupRoutes(router *gin.Engine, eventService *services.EventsService, annou
announcementHandler := handlers.NewAnnouncementHandler(announcementService)
router.GET("/announcement/:id", announcementHandler.GetAnnouncement)
router.POST("/announcement", announcementHandler.CreateAnnouncement)
router.POST("/announcement/:id", announcementHandler.DeleteAnnouncement)
router.DELETE("/announcement/:id", announcementHandler.DeleteAnnouncement)
router.POST("/announcement/:id", announcementHandler.UpdateAnnouncement)
}
1 change: 1 addition & 0 deletions internal/api/services/announcement_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func (s *AnnouncementService) List(ctx context.Context, filters ...any) ([]model
return result, nil
}

// partially implemented
func (s *AnnouncementService) Update(ctx context.Context, uuid string, params models.UpdateAnnouncementParams) error {
err := s.q.UpdateAnnouncement(ctx, params)
if err != nil {
Expand Down
34 changes: 29 additions & 5 deletions internal/db/models/board.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading