Skip to content

Commit 3ff17c2

Browse files
committed
feat: put routes add equivalent patch routes
1 parent d6692f7 commit 3ff17c2

7 files changed

Lines changed: 343 additions & 20 deletions

File tree

apis/account.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ func register(c *fiber.Ctx, email, password string, batch bool) error {
337337
// @Accept json
338338
// @Produce json
339339
// @Router /register [put]
340+
// @Router /register [patch]
340341
// @Param json body RegisterRequest true "json"
341342
// @Success 200 {object} TokenResponse
342343
// @Failure 400 {object} common.MessageResponse "验证码错误"

apis/routes.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func RegisterRoutes(app *fiber.App) {
3232
routes.Get("/verify/apikey", VerifyWithApikey)
3333
routes.Post("/register", Register)
3434
routes.Put("/register", ChangePassword)
35+
routes.Patch("/register", ChangePassword)
3536
routes.Delete("/users/me", DeleteUser)
3637
routes.Delete("/users/:id", DeleteUserByID)
3738

@@ -52,6 +53,7 @@ func RegisterRoutes(app *fiber.App) {
5253
routes.Get("/users/:id", GetUserByID)
5354
routes.Get("/users", ListUsers)
5455
routes.Put("/users/:id", ModifyUser)
56+
routes.Patch("/users/:id<int>/_modify", ModifyUser)
5557

5658
// shamir
5759
routes.Get("/shamir/status", GetShamirStatus)
@@ -61,6 +63,7 @@ func RegisterRoutes(app *fiber.App) {
6163
routes.Post("/shamir/key", UploadPublicKey)
6264
routes.Post("/shamir/update", UpdateShamir)
6365
routes.Put("/shamir/refresh", RefreshShamir)
66+
routes.Patch("/shamir/refresh", RefreshShamir)
6467
routes.Post("/shamir/decrypt", UploadUserShares)
6568
routes.Get("/shamir/decrypt/:id", GetDecryptedUserEmail)
6669
routes.Get("/shamir/decrypt/status/:id", GetDecryptStatusbyUserID)

apis/shamir.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ func UpdateShamir(c *fiber.Ctx) error {
333333
// @Summary trigger for refresh uploaded shares
334334
// @Tags shamir
335335
// @Router /shamir/refresh [put]
336+
// @Router /shamir/refresh [patch]
336337
// @Success 204
337338
// @Failure 403 {object} common.MessageResponse "非管理员"
338339
// @failure 500 {object} common.MessageResponse

apis/user.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ func ListAdmin(c *fiber.Ctx) error {
9595
// @Tags user
9696
// @Produce json
9797
// @Router /users/{user_id} [put]
98+
// @Router /users/{user_id}/_modify [patch]
9899
// @Param user_id path int true "UserID"
99100
// @Success 201 {object} User
100101
// @Failure 403 {object} common.MessageResponse "不是管理员"

docs/docs.go

Lines changed: 127 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// Code generated by swaggo/swag. DO NOT EDIT.
2-
1+
// Package docs Code generated by swaggo/swag. DO NOT EDIT
32
package docs
43

54
import "github.com/swaggo/swag"
@@ -321,6 +320,50 @@ const docTemplate = `{
321320
}
322321
}
323322
}
323+
},
324+
"patch": {
325+
"description": "reset password, reset jwt credential",
326+
"consumes": [
327+
"application/json"
328+
],
329+
"produces": [
330+
"application/json"
331+
],
332+
"tags": [
333+
"account"
334+
],
335+
"summary": "reset password",
336+
"parameters": [
337+
{
338+
"description": "json",
339+
"name": "json",
340+
"in": "body",
341+
"required": true,
342+
"schema": {
343+
"$ref": "#/definitions/apis.RegisterRequest"
344+
}
345+
}
346+
],
347+
"responses": {
348+
"200": {
349+
"description": "OK",
350+
"schema": {
351+
"$ref": "#/definitions/apis.TokenResponse"
352+
}
353+
},
354+
"400": {
355+
"description": "验证码错误",
356+
"schema": {
357+
"$ref": "#/definitions/common.MessageResponse"
358+
}
359+
},
360+
"500": {
361+
"description": "Internal Server Error",
362+
"schema": {
363+
"$ref": "#/definitions/common.MessageResponse"
364+
}
365+
}
366+
}
324367
}
325368
},
326369
"/register/questions": {
@@ -710,6 +753,29 @@ const docTemplate = `{
710753
}
711754
}
712755
}
756+
},
757+
"patch": {
758+
"tags": [
759+
"shamir"
760+
],
761+
"summary": "trigger for refresh uploaded shares",
762+
"responses": {
763+
"204": {
764+
"description": "No Content"
765+
},
766+
"403": {
767+
"description": "非管理员",
768+
"schema": {
769+
"$ref": "#/definitions/common.MessageResponse"
770+
}
771+
},
772+
"500": {
773+
"description": "Internal Server Error",
774+
"schema": {
775+
"$ref": "#/definitions/common.MessageResponse"
776+
}
777+
}
778+
}
713779
}
714780
},
715781
"/shamir/shares": {
@@ -1173,6 +1239,47 @@ const docTemplate = `{
11731239
}
11741240
}
11751241
},
1242+
"/users/{user_id}/_modify": {
1243+
"patch": {
1244+
"description": "modify user, owner or admin",
1245+
"produces": [
1246+
"application/json"
1247+
],
1248+
"tags": [
1249+
"user"
1250+
],
1251+
"summary": "modify user",
1252+
"parameters": [
1253+
{
1254+
"type": "integer",
1255+
"description": "UserID",
1256+
"name": "user_id",
1257+
"in": "path",
1258+
"required": true
1259+
}
1260+
],
1261+
"responses": {
1262+
"201": {
1263+
"description": "Created",
1264+
"schema": {
1265+
"$ref": "#/definitions/models.User"
1266+
}
1267+
},
1268+
"403": {
1269+
"description": "不是管理员",
1270+
"schema": {
1271+
"$ref": "#/definitions/common.MessageResponse"
1272+
}
1273+
},
1274+
"500": {
1275+
"description": "Internal Server Error",
1276+
"schema": {
1277+
"$ref": "#/definitions/common.MessageResponse"
1278+
}
1279+
}
1280+
}
1281+
}
1282+
},
11761283
"/verify/apikey": {
11771284
"get": {
11781285
"description": "verify with email in query, return verification code",
@@ -1442,6 +1549,9 @@ const docTemplate = `{
14421549
},
14431550
"apis.LoginRequest": {
14441551
"type": "object",
1552+
"required": [
1553+
"password"
1554+
],
14451555
"properties": {
14461556
"email": {
14471557
"description": "email in email blacklist",
@@ -1475,11 +1585,11 @@ const docTemplate = `{
14751585
"type": "string"
14761586
},
14771587
"answer": {
1478-
"description": "答案描述,单选、判断、多选\n如果是单选题,则只有一个答案\n如果是多选题,则有一个或多个答案\n如果是判断题,则只有一个答案,且只能是 true 或者 false",
1588+
"description": "答案索引,单选、判断、多选,从 0 开始",
14791589
"type": "array",
14801590
"minItems": 1,
14811591
"items": {
1482-
"type": "string"
1592+
"type": "integer"
14831593
}
14841594
},
14851595
"group": {
@@ -1587,6 +1697,9 @@ const docTemplate = `{
15871697
},
15881698
"apis.RegisterRequest": {
15891699
"type": "object",
1700+
"required": [
1701+
"password"
1702+
],
15901703
"properties": {
15911704
"email": {
15921705
"description": "email in email blacklist",
@@ -1798,12 +1911,19 @@ const docTemplate = `{
17981911
"field": {
17991912
"type": "string"
18001913
},
1801-
"tag": {
1914+
"message": {
18021915
"type": "string"
18031916
},
1804-
"value": {
1917+
"param": {
18051918
"type": "string"
1806-
}
1919+
},
1920+
"struct_field": {
1921+
"type": "string"
1922+
},
1923+
"tag": {
1924+
"type": "string"
1925+
},
1926+
"value": {}
18071927
}
18081928
},
18091929
"common.HttpError": {

0 commit comments

Comments
 (0)