Skip to content

Commit

Permalink
Merge pull request #162 from fsy2001/put
Browse files Browse the repository at this point in the history
change: PUT routes suffix
  • Loading branch information
JingYiJun authored Aug 4, 2024
2 parents 652e254 + d7b9c3f commit 095fb26
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 62 deletions.
2 changes: 1 addition & 1 deletion apis/division/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ func RegisterRoutes(app fiber.Router) {
app.Get("/divisions", ListDivisions)
app.Get("/divisions/:id", GetDivision)
app.Put("/divisions/:id", ModifyDivision)
app.Patch("/divisions/:id/_modify", ModifyDivision)
app.Patch("/divisions/:id/_webvpn", ModifyDivision)
app.Delete("/divisions/:id", DeleteDivision)
}
4 changes: 2 additions & 2 deletions apis/favourite/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ func RegisterRoutes(app fiber.Router) {
app.Get("/user/favorites", ListFavorites)
app.Post("/user/favorites", AddFavorite)
app.Put("/user/favorites", ModifyFavorite)
app.Patch("/user/favorites/_modify", ModifyFavorite)
app.Patch("/user/favorites/_webvpn", ModifyFavorite)
app.Delete("/user/favorites", DeleteFavorite)
app.Get("/user/favorite_groups", ListFavoriteGroups)
app.Post("/user/favorite_groups", AddFavoriteGroup)
app.Put("/user/favorite_groups", ModifyFavoriteGroup)
app.Patch("/user/favorite_groups/_modify", ModifyFavoriteGroup)
app.Patch("/user/favorite_groups/_webvpn", ModifyFavoriteGroup)
app.Delete("/user/favorite_groups", DeleteFavoriteGroup)
app.Put("/user/favorites/move", MoveFavorite)
}
4 changes: 2 additions & 2 deletions apis/floor/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func CreateFloorOld(c *fiber.Ctx) error {
// @Tags Floor
// @Produce application/json
// @Router /floors/{id} [put]
// @Router /floors/{id}/_modify [patch]
// @Router /floors/{id}/_webvpn [patch]
// @Param id path int true "id"
// @Param json body ModifyModel true "json"
// @Success 200 {object} Floor
Expand Down Expand Up @@ -958,7 +958,7 @@ func ListSensitiveFloors(c *fiber.Ctx) (err error) {
// @Tags Floor
// @Produce application/json
// @Router /floors/{id}/_sensitive [put]
// @Router /floors/{id}/_sensitive [patch]
// @Router /floors/{id}/_sensitive/_webvpn [patch]
// @Param id path int true "id"
// @Param json body ModifySensitiveFloorRequest true "json"
// @Success 200 {object} Floor
Expand Down
4 changes: 2 additions & 2 deletions apis/floor/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func RegisterRoutes(app fiber.Router) {
app.Post("/holes/:id<int>/floors", utils.MiddlewareHasAnsweredQuestions, CreateFloor)
app.Post("/floors", utils.MiddlewareHasAnsweredQuestions, CreateFloorOld)
app.Put("/floors/:id<int>", ModifyFloor)
app.Patch("/floors/:id<int>/_modify", ModifyFloor)
app.Patch("/floors/:id<int>/_webvpn", ModifyFloor)
app.Post("/floors/:id<int>/like/:like<int>", ModifyFloorLike)
app.Delete("/floors/:id<int>", DeleteFloor)

Expand All @@ -31,5 +31,5 @@ func RegisterRoutes(app fiber.Router) {

app.Get("/floors/_sensitive", ListSensitiveFloors)
app.Put("/floors/:id<int>/_sensitive", ModifyFloorSensitive)
app.Patch("/floors/:id<int>/_sensitive", ModifyFloorSensitive)
app.Patch("/floors/:id<int>/_sensitive/_webvpn", ModifyFloorSensitive)
}
2 changes: 1 addition & 1 deletion apis/hole/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ func CreateHoleOld(c *fiber.Ctx) error {
// @Tags Hole
// @Produce application/json
// @Router /holes/{id} [put]
// @Router /holes/{id}/_modify [patch]
// @Router /holes/{id}/_webvpn [patch]
// @Param id path int true "id"
// @Param json body ModifyModel true "json"
// @Success 200 {object} Hole
Expand Down
2 changes: 1 addition & 1 deletion apis/hole/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func RegisterRoutes(app fiber.Router) {
app.Get("/holes/_good", ListGoodHoles)
app.Post("/divisions/:id/holes", utils.MiddlewareHasAnsweredQuestions, CreateHole)
app.Post("/holes", utils.MiddlewareHasAnsweredQuestions, CreateHoleOld)
app.Patch("/holes/:id<int>/_modify", ModifyHole)
app.Patch("/holes/:id<int>/_webvpn", ModifyHole)
app.Patch("/holes/:id<int>", PatchHole)
app.Put("/holes/:id<int>", ModifyHole)
app.Delete("/holes/:id<int>", HideHole)
Expand Down
2 changes: 1 addition & 1 deletion apis/message/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func ClearMessages(c *fiber.Ctx) error {
// @Tags Message
// @Produce application/json
// @Router /messages [put]
// @Router /messages/_clear [patch]
// @Router /messages/_webvpn [patch]
// @Success 204
func ClearMessagesDeprecated(c *fiber.Ctx) error {
return ClearMessages(c)
Expand Down
2 changes: 1 addition & 1 deletion apis/message/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ func RegisterRoutes(app fiber.Router) {
app.Get("/messages", ListMessages)
app.Post("/messages/clear", ClearMessages)
app.Put("/messages", ClearMessagesDeprecated)
app.Patch("/messages/_clear", ClearMessagesDeprecated)
app.Patch("/messages/_webvpn", ClearMessagesDeprecated)
app.Delete("/messages/:id<int>", DeleteMessage)
}
2 changes: 1 addition & 1 deletion apis/tag/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func CreateTag(c *fiber.Ctx) error {
// @Tags Tag
// @Produce application/json
// @Router /tags/{id} [put]
// @Router /tags/{id}/_modify [patch]
// @Router /tags/{id}/_webvpn [patch]
// @Param id path int true "id"
// @Param json body ModifyModel true "json"
// @Success 200 {object} Tag
Expand Down
2 changes: 1 addition & 1 deletion apis/tag/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ func RegisterRoutes(app fiber.Router) {
app.Get("/tags/:id<int>", GetTag)
app.Post("/tags", CreateTag)
app.Put("/tags/:id<int>", ModifyTag)
app.Patch("/tags/:id<int>/_modify", ModifyTag)
app.Patch("/tags/:id<int>/_webvpn", ModifyTag)
app.Delete("/tags/:id<int>", DeleteTag)
}
8 changes: 4 additions & 4 deletions apis/user/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ func RegisterRoutes(app fiber.Router) {
app.Get("/users/me", GetCurrentUser)
app.Get("/users/:id<int>", GetUserByID)
app.Put("/users/:id<int>", ModifyUser)
app.Patch("/users/:id<int>/_modify", ModifyUser)
app.Patch("/users/:id<int>/_webvpn", ModifyUser)
app.Put("/users/me", ModifyCurrentUser)
app.Patch("/users/me/_modify", ModifyCurrentUser)
app.Patch("/users/me/_webvpn", ModifyCurrentUser)
}

// GetCurrentUser
Expand Down Expand Up @@ -70,7 +70,7 @@ func GetUserByID(c *fiber.Ctx) error {
// @Tags User
// @Produce json
// @Router /users/{user_id} [put]
// @Router /users/{user_id}/_modify [patch]
// @Router /users/{user_id}/_webvpn [patch]
// @Param user_id path int true "user id"
// @Param json body ModifyModel true "modify user"
// @Success 200 {object} User
Expand Down Expand Up @@ -115,7 +115,7 @@ func ModifyUser(c *fiber.Ctx) error {
// @Tags User
// @Produce json
// @Router /users/me [put]
// @Router /users/me/_modify [patch]
// @Router /users/me/_webvpn [patch]
// @Param user_id path int true "user id"
// @Param json body ModifyModel true "modify user"
// @Success 200 {object} User
Expand Down
32 changes: 17 additions & 15 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,16 +733,15 @@ const docTemplate = `{
}
}
},
"/floors/{id}/_modify": {
"patch": {
"description": "when both \"fold_v2\" and \"fold\" are empty, reset fold; else, \"fold_v2\" has the priority",
"/floors/{id}/_sensitive": {
"put": {
"produces": [
"application/json"
],
"tags": [
"Floor"
],
"summary": "Modify A Floor",
"summary": "Modify A Floor's actual_sensitive, admin only",
"parameters": [
{
"type": "integer",
Expand All @@ -757,7 +756,7 @@ const docTemplate = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/floor.ModifyModel"
"$ref": "#/definitions/floor.ModifySensitiveFloorRequest"
}
}
],
Expand All @@ -777,8 +776,8 @@ const docTemplate = `{
}
}
},
"/floors/{id}/_sensitive": {
"put": {
"/floors/{id}/_sensitive/_webvpn": {
"patch": {
"produces": [
"application/json"
],
Expand Down Expand Up @@ -818,15 +817,18 @@ const docTemplate = `{
}
}
}
},
}
},
"/floors/{id}/_webvpn": {
"patch": {
"description": "when both \"fold_v2\" and \"fold\" are empty, reset fold; else, \"fold_v2\" has the priority",
"produces": [
"application/json"
],
"tags": [
"Floor"
],
"summary": "Modify A Floor's actual_sensitive, admin only",
"summary": "Modify A Floor",
"parameters": [
{
"type": "integer",
Expand All @@ -841,7 +843,7 @@ const docTemplate = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/floor.ModifySensitiveFloorRequest"
"$ref": "#/definitions/floor.ModifyModel"
}
}
],
Expand Down Expand Up @@ -1466,7 +1468,7 @@ const docTemplate = `{
}
}
},
"/holes/{id}/_modify": {
"/holes/{id}/_webvpn": {
"patch": {
"description": "Modify a hole, modify tags and set the name mapping\nOnly admin can modify division, tags, hidden, lock\n` + "`" + `unhidden` + "`" + ` take effect only when hole is hidden and set to true",
"produces": [
Expand Down Expand Up @@ -1583,7 +1585,7 @@ const docTemplate = `{
}
}
},
"/messages/_clear": {
"/messages/_webvpn": {
"patch": {
"produces": [
"application/json"
Expand Down Expand Up @@ -2068,7 +2070,7 @@ const docTemplate = `{
}
}
},
"/tags/{id}/_modify": {
"/tags/{id}/_webvpn": {
"patch": {
"produces": [
"application/json"
Expand Down Expand Up @@ -2622,7 +2624,7 @@ const docTemplate = `{
}
}
},
"/users/me/_modify": {
"/users/me/_webvpn": {
"patch": {
"produces": [
"application/json"
Expand Down Expand Up @@ -2967,7 +2969,7 @@ const docTemplate = `{
}
}
},
"/users/{user_id}/_modify": {
"/users/{user_id}/_webvpn": {
"patch": {
"produces": [
"application/json"
Expand Down
32 changes: 17 additions & 15 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -726,16 +726,15 @@
}
}
},
"/floors/{id}/_modify": {
"patch": {
"description": "when both \"fold_v2\" and \"fold\" are empty, reset fold; else, \"fold_v2\" has the priority",
"/floors/{id}/_sensitive": {
"put": {
"produces": [
"application/json"
],
"tags": [
"Floor"
],
"summary": "Modify A Floor",
"summary": "Modify A Floor's actual_sensitive, admin only",
"parameters": [
{
"type": "integer",
Expand All @@ -750,7 +749,7 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/floor.ModifyModel"
"$ref": "#/definitions/floor.ModifySensitiveFloorRequest"
}
}
],
Expand All @@ -770,8 +769,8 @@
}
}
},
"/floors/{id}/_sensitive": {
"put": {
"/floors/{id}/_sensitive/_webvpn": {
"patch": {
"produces": [
"application/json"
],
Expand Down Expand Up @@ -811,15 +810,18 @@
}
}
}
},
}
},
"/floors/{id}/_webvpn": {
"patch": {
"description": "when both \"fold_v2\" and \"fold\" are empty, reset fold; else, \"fold_v2\" has the priority",
"produces": [
"application/json"
],
"tags": [
"Floor"
],
"summary": "Modify A Floor's actual_sensitive, admin only",
"summary": "Modify A Floor",
"parameters": [
{
"type": "integer",
Expand All @@ -834,7 +836,7 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/floor.ModifySensitiveFloorRequest"
"$ref": "#/definitions/floor.ModifyModel"
}
}
],
Expand Down Expand Up @@ -1459,7 +1461,7 @@
}
}
},
"/holes/{id}/_modify": {
"/holes/{id}/_webvpn": {
"patch": {
"description": "Modify a hole, modify tags and set the name mapping\nOnly admin can modify division, tags, hidden, lock\n`unhidden` take effect only when hole is hidden and set to true",
"produces": [
Expand Down Expand Up @@ -1576,7 +1578,7 @@
}
}
},
"/messages/_clear": {
"/messages/_webvpn": {
"patch": {
"produces": [
"application/json"
Expand Down Expand Up @@ -2061,7 +2063,7 @@
}
}
},
"/tags/{id}/_modify": {
"/tags/{id}/_webvpn": {
"patch": {
"produces": [
"application/json"
Expand Down Expand Up @@ -2615,7 +2617,7 @@
}
}
},
"/users/me/_modify": {
"/users/me/_webvpn": {
"patch": {
"produces": [
"application/json"
Expand Down Expand Up @@ -2960,7 +2962,7 @@
}
}
},
"/users/{user_id}/_modify": {
"/users/{user_id}/_webvpn": {
"patch": {
"produces": [
"application/json"
Expand Down
Loading

0 comments on commit 095fb26

Please sign in to comment.