diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-09-24 12:41:36 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-24 12:41:36 +0300 |
| commit | f04bb43856e72d3c0265bc7e2c38661fac268c7c (patch) | |
| tree | 153d96d63fa211df50cff6136cfe2c6639c3e03f | |
| parent | feat: removing (by flag) records (#56) (diff) | |
| download | lphub-f04bb43856e72d3c0265bc7e2c38661fac268c7c.tar.gz lphub-f04bb43856e72d3c0265bc7e2c38661fac268c7c.tar.bz2 lphub-f04bb43856e72d3c0265bc7e2c38661fac268c7c.zip | |
docs: add delete record, update discussion and main (#56)
Former-commit-id: 8abea862f066e06fc31df3d5ddd921334fe76f5c
| -rw-r--r-- | backend/handlers/discussions.go | 1 | ||||
| -rw-r--r-- | backend/handlers/record.go | 10 | ||||
| -rw-r--r-- | docs/docs.go | 53 | ||||
| -rw-r--r-- | docs/swagger.json | 53 | ||||
| -rw-r--r-- | docs/swagger.yaml | 37 | ||||
| -rw-r--r-- | main.go | 4 |
6 files changed, 130 insertions, 28 deletions
diff --git a/backend/handlers/discussions.go b/backend/handlers/discussions.go index 605c7c3..6687a53 100644 --- a/backend/handlers/discussions.go +++ b/backend/handlers/discussions.go | |||
| @@ -154,7 +154,6 @@ func FetchMapDiscussion(c *gin.Context) { | |||
| 154 | // @Produce json | 154 | // @Produce json |
| 155 | // @Param Authorization header string true "JWT Token" | 155 | // @Param Authorization header string true "JWT Token" |
| 156 | // @Param mapid path int true "Map ID" | 156 | // @Param mapid path int true "Map ID" |
| 157 | // @Param discussionid path int true "Discussion ID" | ||
| 158 | // @Param request body CreateMapDiscussionRequest true "Body" | 157 | // @Param request body CreateMapDiscussionRequest true "Body" |
| 159 | // @Success 200 {object} models.Response{data=CreateMapDiscussionRequest} | 158 | // @Success 200 {object} models.Response{data=CreateMapDiscussionRequest} |
| 160 | // @Router /maps/{mapid}/discussions [post] | 159 | // @Router /maps/{mapid}/discussions [post] |
diff --git a/backend/handlers/record.go b/backend/handlers/record.go index 70095bf..4b0fafa 100644 --- a/backend/handlers/record.go +++ b/backend/handlers/record.go | |||
| @@ -210,6 +210,16 @@ func CreateRecordWithDemo(c *gin.Context) { | |||
| 210 | }) | 210 | }) |
| 211 | } | 211 | } |
| 212 | 212 | ||
| 213 | // DELETE Record | ||
| 214 | // | ||
| 215 | // @Description Delete record with specified map and record id. | ||
| 216 | // @Tags maps | ||
| 217 | // @Produce json | ||
| 218 | // @Param mapid path int true "Map ID" | ||
| 219 | // @Param recordid path int true "Record ID" | ||
| 220 | // @Param Authorization header string true "JWT Token" | ||
| 221 | // @Success 200 {object} models.Response | ||
| 222 | // @Router /maps/{mapid}/record/{recordid} [delete] | ||
| 213 | func DeleteRecord(c *gin.Context) { | 223 | func DeleteRecord(c *gin.Context) { |
| 214 | mapID, err := strconv.Atoi(c.Param("mapid")) | 224 | mapID, err := strconv.Atoi(c.Param("mapid")) |
| 215 | if err != nil { | 225 | if err != nil { |
diff --git a/docs/docs.go b/docs/docs.go index 9712377..5a107c1 100644 --- a/docs/docs.go +++ b/docs/docs.go | |||
| @@ -345,13 +345,6 @@ const docTemplate = `{ | |||
| 345 | "required": true | 345 | "required": true |
| 346 | }, | 346 | }, |
| 347 | { | 347 | { |
| 348 | "type": "integer", | ||
| 349 | "description": "Discussion ID", | ||
| 350 | "name": "discussionid", | ||
| 351 | "in": "path", | ||
| 352 | "required": true | ||
| 353 | }, | ||
| 354 | { | ||
| 355 | "description": "Body", | 348 | "description": "Body", |
| 356 | "name": "request", | 349 | "name": "request", |
| 357 | "in": "body", | 350 | "in": "body", |
| @@ -714,6 +707,48 @@ const docTemplate = `{ | |||
| 714 | } | 707 | } |
| 715 | } | 708 | } |
| 716 | }, | 709 | }, |
| 710 | "/maps/{mapid}/record/{recordid}": { | ||
| 711 | "delete": { | ||
| 712 | "description": "Delete record with specified map and record id.", | ||
| 713 | "produces": [ | ||
| 714 | "application/json" | ||
| 715 | ], | ||
| 716 | "tags": [ | ||
| 717 | "maps" | ||
| 718 | ], | ||
| 719 | "parameters": [ | ||
| 720 | { | ||
| 721 | "type": "integer", | ||
| 722 | "description": "Map ID", | ||
| 723 | "name": "mapid", | ||
| 724 | "in": "path", | ||
| 725 | "required": true | ||
| 726 | }, | ||
| 727 | { | ||
| 728 | "type": "integer", | ||
| 729 | "description": "Record ID", | ||
| 730 | "name": "recordid", | ||
| 731 | "in": "path", | ||
| 732 | "required": true | ||
| 733 | }, | ||
| 734 | { | ||
| 735 | "type": "string", | ||
| 736 | "description": "JWT Token", | ||
| 737 | "name": "Authorization", | ||
| 738 | "in": "header", | ||
| 739 | "required": true | ||
| 740 | } | ||
| 741 | ], | ||
| 742 | "responses": { | ||
| 743 | "200": { | ||
| 744 | "description": "OK", | ||
| 745 | "schema": { | ||
| 746 | "$ref": "#/definitions/models.Response" | ||
| 747 | } | ||
| 748 | } | ||
| 749 | } | ||
| 750 | } | ||
| 751 | }, | ||
| 717 | "/maps/{mapid}/summary": { | 752 | "/maps/{mapid}/summary": { |
| 718 | "get": { | 753 | "get": { |
| 719 | "description": "Get map summary with specified id.", | 754 | "description": "Get map summary with specified id.", |
| @@ -1937,8 +1972,8 @@ const docTemplate = `{ | |||
| 1937 | // SwaggerInfo holds exported Swagger Info so clients can modify it | 1972 | // SwaggerInfo holds exported Swagger Info so clients can modify it |
| 1938 | var SwaggerInfo = &swag.Spec{ | 1973 | var SwaggerInfo = &swag.Spec{ |
| 1939 | Version: "1.0", | 1974 | Version: "1.0", |
| 1940 | Host: "lp.ardapektezol.com/api", | 1975 | Host: "lp.ardapektezol.com", |
| 1941 | BasePath: "/v1", | 1976 | BasePath: "/api/v1", |
| 1942 | Schemes: []string{}, | 1977 | Schemes: []string{}, |
| 1943 | Title: "Least Portals Database API", | 1978 | Title: "Least Portals Database API", |
| 1944 | Description: "Backend API endpoints for the Least Portals Database.", | 1979 | Description: "Backend API endpoints for the Least Portals Database.", |
diff --git a/docs/swagger.json b/docs/swagger.json index 226cadd..d118ce7 100644 --- a/docs/swagger.json +++ b/docs/swagger.json | |||
| @@ -10,8 +10,8 @@ | |||
| 10 | }, | 10 | }, |
| 11 | "version": "1.0" | 11 | "version": "1.0" |
| 12 | }, | 12 | }, |
| 13 | "host": "lp.ardapektezol.com/api", | 13 | "host": "lp.ardapektezol.com", |
| 14 | "basePath": "/v1", | 14 | "basePath": "/api/v1", |
| 15 | "paths": { | 15 | "paths": { |
| 16 | "/chapters/{chapterid}": { | 16 | "/chapters/{chapterid}": { |
| 17 | "get": { | 17 | "get": { |
| @@ -338,13 +338,6 @@ | |||
| 338 | "required": true | 338 | "required": true |
| 339 | }, | 339 | }, |
| 340 | { | 340 | { |
| 341 | "type": "integer", | ||
| 342 | "description": "Discussion ID", | ||
| 343 | "name": "discussionid", | ||
| 344 | "in": "path", | ||
| 345 | "required": true | ||
| 346 | }, | ||
| 347 | { | ||
| 348 | "description": "Body", | 341 | "description": "Body", |
| 349 | "name": "request", | 342 | "name": "request", |
| 350 | "in": "body", | 343 | "in": "body", |
| @@ -707,6 +700,48 @@ | |||
| 707 | } | 700 | } |
| 708 | } | 701 | } |
| 709 | }, | 702 | }, |
| 703 | "/maps/{mapid}/record/{recordid}": { | ||
| 704 | "delete": { | ||
| 705 | "description": "Delete record with specified map and record id.", | ||
| 706 | "produces": [ | ||
| 707 | "application/json" | ||
| 708 | ], | ||
| 709 | "tags": [ | ||
| 710 | "maps" | ||
| 711 | ], | ||
| 712 | "parameters": [ | ||
| 713 | { | ||
| 714 | "type": "integer", | ||
| 715 | "description": "Map ID", | ||
| 716 | "name": "mapid", | ||
| 717 | "in": "path", | ||
| 718 | "required": true | ||
| 719 | }, | ||
| 720 | { | ||
| 721 | "type": "integer", | ||
| 722 | "description": "Record ID", | ||
| 723 | "name": "recordid", | ||
| 724 | "in": "path", | ||
| 725 | "required": true | ||
| 726 | }, | ||
| 727 | { | ||
| 728 | "type": "string", | ||
| 729 | "description": "JWT Token", | ||
| 730 | "name": "Authorization", | ||
| 731 | "in": "header", | ||
| 732 | "required": true | ||
| 733 | } | ||
| 734 | ], | ||
| 735 | "responses": { | ||
| 736 | "200": { | ||
| 737 | "description": "OK", | ||
| 738 | "schema": { | ||
| 739 | "$ref": "#/definitions/models.Response" | ||
| 740 | } | ||
| 741 | } | ||
| 742 | } | ||
| 743 | } | ||
| 744 | }, | ||
| 710 | "/maps/{mapid}/summary": { | 745 | "/maps/{mapid}/summary": { |
| 711 | "get": { | 746 | "get": { |
| 712 | "description": "Get map summary with specified id.", | 747 | "description": "Get map summary with specified id.", |
diff --git a/docs/swagger.yaml b/docs/swagger.yaml index b20f762..3e83fe8 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | basePath: /v1 | 1 | basePath: /api/v1 |
| 2 | definitions: | 2 | definitions: |
| 3 | handlers.ChapterMapsResponse: | 3 | handlers.ChapterMapsResponse: |
| 4 | properties: | 4 | properties: |
| @@ -462,7 +462,7 @@ definitions: | |||
| 462 | user_name: | 462 | user_name: |
| 463 | type: string | 463 | type: string |
| 464 | type: object | 464 | type: object |
| 465 | host: lp.ardapektezol.com/api | 465 | host: lp.ardapektezol.com |
| 466 | info: | 466 | info: |
| 467 | contact: {} | 467 | contact: {} |
| 468 | description: Backend API endpoints for the Least Portals Database. | 468 | description: Backend API endpoints for the Least Portals Database. |
| @@ -660,11 +660,6 @@ paths: | |||
| 660 | name: mapid | 660 | name: mapid |
| 661 | required: true | 661 | required: true |
| 662 | type: integer | 662 | type: integer |
| 663 | - description: Discussion ID | ||
| 664 | in: path | ||
| 665 | name: discussionid | ||
| 666 | required: true | ||
| 667 | type: integer | ||
| 668 | - description: Body | 663 | - description: Body |
| 669 | in: body | 664 | in: body |
| 670 | name: request | 665 | name: request |
| @@ -890,6 +885,34 @@ paths: | |||
| 890 | type: object | 885 | type: object |
| 891 | tags: | 886 | tags: |
| 892 | - maps | 887 | - maps |
| 888 | /maps/{mapid}/record/{recordid}: | ||
| 889 | delete: | ||
| 890 | description: Delete record with specified map and record id. | ||
| 891 | parameters: | ||
| 892 | - description: Map ID | ||
| 893 | in: path | ||
| 894 | name: mapid | ||
| 895 | required: true | ||
| 896 | type: integer | ||
| 897 | - description: Record ID | ||
| 898 | in: path | ||
| 899 | name: recordid | ||
| 900 | required: true | ||
| 901 | type: integer | ||
| 902 | - description: JWT Token | ||
| 903 | in: header | ||
| 904 | name: Authorization | ||
| 905 | required: true | ||
| 906 | type: string | ||
| 907 | produces: | ||
| 908 | - application/json | ||
| 909 | responses: | ||
| 910 | "200": | ||
| 911 | description: OK | ||
| 912 | schema: | ||
| 913 | $ref: '#/definitions/models.Response' | ||
| 914 | tags: | ||
| 915 | - maps | ||
| 893 | /maps/{mapid}/summary: | 916 | /maps/{mapid}/summary: |
| 894 | delete: | 917 | delete: |
| 895 | description: Delete map summary with specified map id. | 918 | description: Delete map summary with specified map id. |
| @@ -19,8 +19,8 @@ import ( | |||
| 19 | // @license.name GNU General Public License, Version 2 | 19 | // @license.name GNU General Public License, Version 2 |
| 20 | // @license.url https://www.gnu.org/licenses/old-licenses/gpl-2.0.html | 20 | // @license.url https://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
| 21 | 21 | ||
| 22 | // @host lp.ardapektezol.com/api | 22 | // @host lp.ardapektezol.com |
| 23 | // @BasePath /v1 | 23 | // @BasePath /api/v1 |
| 24 | func main() { | 24 | func main() { |
| 25 | if os.Getenv("ENV") == "PROD" { | 25 | if os.Getenv("ENV") == "PROD" { |
| 26 | gin.SetMode(gin.ReleaseMode) | 26 | gin.SetMode(gin.ReleaseMode) |