Skip to content

Commit b4b6ee2

Browse files
authored
Merge pull request #58 from acmcsufoss/announcement
fixed handling and documentation
2 parents 9bd89d0 + e5418bc commit b4b6ee2

File tree

8 files changed

+191
-18
lines changed

8 files changed

+191
-18
lines changed

docs/docs.go

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,54 @@ const docTemplate = `{
1515
"host": "{{.Host}}",
1616
"basePath": "{{.BasePath}}",
1717
"paths": {
18+
"/announcement/:id": {
19+
"put": {
20+
"description": "Updates the Announcement of choice in the database",
21+
"consumes": [
22+
"application/json"
23+
],
24+
"produces": [
25+
"application/json"
26+
],
27+
"tags": [
28+
"Announcements"
29+
],
30+
"summary": "Updates the Announcement of Choice",
31+
"parameters": [
32+
{
33+
"type": "string",
34+
"description": "Announcement ID",
35+
"name": "id",
36+
"in": "path",
37+
"required": true
38+
}
39+
],
40+
"responses": {}
41+
},
42+
"delete": {
43+
"description": "Deletes the Announcement of choice in the database",
44+
"consumes": [
45+
"application/json"
46+
],
47+
"produces": [
48+
"application/json"
49+
],
50+
"tags": [
51+
"Announcements"
52+
],
53+
"summary": "Deletes the Announcement of Choice",
54+
"parameters": [
55+
{
56+
"type": "string",
57+
"description": "Event ID",
58+
"name": "id",
59+
"in": "path",
60+
"required": true
61+
}
62+
],
63+
"responses": {}
64+
}
65+
},
1866
"/announcements": {
1967
"post": {
2068
"description": "Creates a new announcement and generates unique ID",
@@ -58,7 +106,7 @@ const docTemplate = `{
58106
},
59107
"/events": {
60108
"get": {
61-
"description": "Gets all the events from the event database",
109+
"description": "Get all the events from the event database",
62110
"consumes": [
63111
"application/json"
64112
],
@@ -68,7 +116,7 @@ const docTemplate = `{
68116
"tags": [
69117
"Events"
70118
],
71-
"summary": "Gets all the events",
119+
"summary": "Get all the events",
72120
"responses": {}
73121
},
74122
"post": {
@@ -121,7 +169,7 @@ const docTemplate = `{
121169
"tags": [
122170
"Events"
123171
],
124-
"summary": "Update the Event of Choice",
172+
"summary": "Updates the Event of Choice",
125173
"parameters": [
126174
{
127175
"type": "string",

docs/swagger.json

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,54 @@
44
"contact": {}
55
},
66
"paths": {
7+
"/announcement/:id": {
8+
"put": {
9+
"description": "Updates the Announcement of choice in the database",
10+
"consumes": [
11+
"application/json"
12+
],
13+
"produces": [
14+
"application/json"
15+
],
16+
"tags": [
17+
"Announcements"
18+
],
19+
"summary": "Updates the Announcement of Choice",
20+
"parameters": [
21+
{
22+
"type": "string",
23+
"description": "Announcement ID",
24+
"name": "id",
25+
"in": "path",
26+
"required": true
27+
}
28+
],
29+
"responses": {}
30+
},
31+
"delete": {
32+
"description": "Deletes the Announcement of choice in the database",
33+
"consumes": [
34+
"application/json"
35+
],
36+
"produces": [
37+
"application/json"
38+
],
39+
"tags": [
40+
"Announcements"
41+
],
42+
"summary": "Deletes the Announcement of Choice",
43+
"parameters": [
44+
{
45+
"type": "string",
46+
"description": "Event ID",
47+
"name": "id",
48+
"in": "path",
49+
"required": true
50+
}
51+
],
52+
"responses": {}
53+
}
54+
},
755
"/announcements": {
856
"post": {
957
"description": "Creates a new announcement and generates unique ID",
@@ -47,7 +95,7 @@
4795
},
4896
"/events": {
4997
"get": {
50-
"description": "Gets all the events from the event database",
98+
"description": "Get all the events from the event database",
5199
"consumes": [
52100
"application/json"
53101
],
@@ -57,7 +105,7 @@
57105
"tags": [
58106
"Events"
59107
],
60-
"summary": "Gets all the events",
108+
"summary": "Get all the events",
61109
"responses": {}
62110
},
63111
"post": {
@@ -110,7 +158,7 @@
110158
"tags": [
111159
"Events"
112160
],
113-
"summary": "Update the Event of Choice",
161+
"summary": "Updates the Event of Choice",
114162
"parameters": [
115163
{
116164
"type": "string",

docs/swagger.yaml

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,39 @@
11
info:
22
contact: {}
33
paths:
4+
/announcement/:id:
5+
delete:
6+
consumes:
7+
- application/json
8+
description: Deletes the Announcement of choice in the database
9+
parameters:
10+
- description: Event ID
11+
in: path
12+
name: id
13+
required: true
14+
type: string
15+
produces:
16+
- application/json
17+
responses: {}
18+
summary: Deletes the Announcement of Choice
19+
tags:
20+
- Announcements
21+
put:
22+
consumes:
23+
- application/json
24+
description: Updates the Announcement of choice in the database
25+
parameters:
26+
- description: Announcement ID
27+
in: path
28+
name: id
29+
required: true
30+
type: string
31+
produces:
32+
- application/json
33+
responses: {}
34+
summary: Updates the Announcement of Choice
35+
tags:
36+
- Announcements
437
/announcements:
538
post:
639
consumes:
@@ -33,11 +66,11 @@ paths:
3366
get:
3467
consumes:
3568
- application/json
36-
description: Gets all the events from the event database
69+
description: Get all the events from the event database
3770
produces:
3871
- application/json
3972
responses: {}
40-
summary: Gets all the events
73+
summary: Get all the events
4174
tags:
4275
- Events
4376
post:
@@ -96,7 +129,7 @@ paths:
96129
produces:
97130
- application/json
98131
responses: {}
99-
summary: Update the Event of Choice
132+
summary: Updates the Event of Choice
100133
tags:
101134
- Events
102135
swagger: "2.0"

internal/api/handlers/announcement_handler.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,28 @@ func (h *AnnouncementHandler) CreateAnnouncement(c *gin.Context) {
7878
})
7979
}
8080

81+
// UpdateAnnouncement godoc
82+
//
83+
// @Summary Updates the Announcement of Choice
84+
// @Description Updates the Announcement of choice in the database
85+
// @Tags Announcements
86+
// @Accept json
87+
// @Produce json
88+
// @Param id path string true "Announcement ID"
89+
// @Router /announcement/:id [Put]
8190
func (h *AnnouncementHandler) UpdateAnnouncement(c *gin.Context) {
8291
panic("implement me (UpdateAnnouncement Handler)")
8392
}
93+
94+
// DeleteAnnouncement godoc
95+
//
96+
// @Summary Deletes the Announcement of Choice
97+
// @Description Deletes the Announcement of choice in the database
98+
// @Tags Announcements
99+
// @Accept json
100+
// @Produce json
101+
// @Param id path string true "Event ID"
102+
// @Router /announcement/:id [Delete]
84103
func (h *AnnouncementHandler) DeleteAnnouncement(c *gin.Context) {
85104
panic("implement me (DeleteAnnouncement Handler)")
86105
}

internal/api/handlers/events_handler.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ func (h *EventsHandler) CreateEvent(c *gin.Context) {
9393

9494
// GetEvents godoc
9595
//
96-
// @Summary Gets all the events
97-
// @Description Gets all the events from the event database
96+
// @Summary Get all the events
97+
// @Description Get all the events from the event database
9898
// @Tags Events
9999
// @Accept json
100100
// @Produce json
@@ -120,7 +120,7 @@ func (h *EventsHandler) GetEvents(c *gin.Context) {
120120

121121
// UpdateEvent godoc
122122
//
123-
// @Summary Update the Event of Choice
123+
// @Summary Updates the Event of Choice
124124
// @Description Updates the event of choice in the database
125125
// @Tags Events
126126
// @Accept json

internal/api/routes/routes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ func SetupRoutes(router *gin.Engine, eventService *services.EventsService, annou
1717
announcementHandler := handlers.NewAnnouncementHandler(announcementService)
1818
router.GET("/announcement/:id", announcementHandler.GetAnnouncement)
1919
router.POST("/announcement", announcementHandler.CreateAnnouncement)
20-
router.POST("/announcement/:id", announcementHandler.DeleteAnnouncement)
20+
router.DELETE("/announcement/:id", announcementHandler.DeleteAnnouncement)
2121
router.POST("/announcement/:id", announcementHandler.UpdateAnnouncement)
2222
}

internal/api/services/announcement_service.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ func (s *AnnouncementService) List(ctx context.Context, filters ...any) ([]model
5555
return result, nil
5656
}
5757

58+
// partially implemented
5859
func (s *AnnouncementService) Update(ctx context.Context, uuid string, params models.UpdateAnnouncementParams) error {
5960
err := s.q.UpdateAnnouncement(ctx, params)
6061
if err != nil {

internal/db/models/board.sql.go

Lines changed: 29 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)