fix: documents api
This commit is contained in:
@@ -11,12 +11,12 @@ var userClaimsKey = struct{}{}
|
||||
func JWTRequired(c *fiber.Ctx) error {
|
||||
jwt := c.Get("Authorization")
|
||||
if jwt == "" {
|
||||
return c.Status(401).JSON(fiber.Map{"msg": "Unauthorized"})
|
||||
return fiber.ErrUnauthorized
|
||||
}
|
||||
claims, err := casdoorsdk.ParseJwtToken(jwt)
|
||||
if err != nil {
|
||||
log.Ctx(c.UserContext()).Error().Err(err).Msg("Unauthorized user")
|
||||
return c.Status(401).JSON(fiber.Map{"msg": "Unauthorized"})
|
||||
return fiber.ErrUnauthorized
|
||||
}
|
||||
c.Locals(userClaimsKey, claims)
|
||||
return nil
|
||||
|
||||
@@ -26,7 +26,7 @@ func RegisterDocRouter(app *soda.Soda) {
|
||||
SetSummary("更新文档").
|
||||
AddJWTSecurity(JWTRequired).
|
||||
SetParameters(schema.DocID{}).
|
||||
SetJSONRequestBody(schema.ListDocQuery{}).
|
||||
SetJSONRequestBody(schema.UpdateDoc{}).
|
||||
AddJSONResponse(200, schema.Doc{}).OK()
|
||||
|
||||
app.Delete("/docs/:id", nil).
|
||||
@@ -45,27 +45,27 @@ func RegisterDocRouter(app *soda.Soda) {
|
||||
|
||||
app.Post("/docs/batch/update", nil).
|
||||
AddTags("文档管理").
|
||||
SetSummary("批量-文件删除").
|
||||
SetSummary("批量-文件更新").
|
||||
AddJWTSecurity(JWTRequired).
|
||||
SetJSONRequestBody(schema.DocsBatchUpdate{}).
|
||||
AddJSONResponse(200, schema.DocsBatchResults{}).OK()
|
||||
|
||||
app.Get("/doc-folders", nil).
|
||||
AddTags("文档管理").
|
||||
AddTags("文件夹管理").
|
||||
SetSummary("获取文件夹树").
|
||||
AddJWTSecurity(JWTRequired).
|
||||
SetParameters(schema.GetDocFolderTree{}).
|
||||
AddJSONResponse(200, schema.DocFolderWithChildren{}).OK()
|
||||
|
||||
app.Post("/doc-folders", nil).
|
||||
AddTags("文档管理").
|
||||
AddTags("文件夹管理").
|
||||
SetSummary("新建文件夹").
|
||||
AddJWTSecurity(JWTRequired).
|
||||
SetJSONRequestBody(schema.CreateDocFolder{}).
|
||||
AddJSONResponse(200, schema.DocFolder{}).OK()
|
||||
|
||||
app.Put("/doc-folders/:id", nil).
|
||||
AddTags("文档管理").
|
||||
AddTags("文件夹管理").
|
||||
SetSummary("更新文件夹").
|
||||
AddJWTSecurity(JWTRequired).
|
||||
SetParameters(schema.DocFolderID{}).
|
||||
@@ -73,7 +73,7 @@ func RegisterDocRouter(app *soda.Soda) {
|
||||
AddJSONResponse(200, schema.DocFolder{}).OK()
|
||||
|
||||
app.Delete("/doc-folders/:id", nil).
|
||||
AddTags("文档管理").
|
||||
AddTags("文件夹管理").
|
||||
SetSummary("删除文件夹").
|
||||
AddJWTSecurity(JWTRequired).
|
||||
SetParameters(schema.DocFolderID{}).
|
||||
|
||||
Reference in New Issue
Block a user