fix: documents api
This commit is contained in:
parent
084d0de8bc
commit
05c133a4b5
@ -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{}).
|
||||
|
@ -75,16 +75,16 @@ type UpdateDoc struct {
|
||||
type ListDocQuery struct {
|
||||
PageableQuery
|
||||
SortableQuery
|
||||
FolderIDs *[]string `query:"folder_ids" validate:"required" oai:"description=归属文件夹ID"`
|
||||
FolderIDs *[]string `query:"folder_ids" oai:"description=筛选归属文件夹ID"`
|
||||
}
|
||||
|
||||
type DocsBatchDelete struct {
|
||||
IDs []string `query:"ids" validate:"required" oai:"description=批量选择文件ID列表"`
|
||||
FolderID string ` validate:"required" oai:"description=更新归属文件夹ID" json:"folder_id"`
|
||||
IDs []string `json:"ids" validate:"required" oai:"description=批量选择文件ID列表"`
|
||||
}
|
||||
|
||||
type DocsBatchUpdate struct {
|
||||
IDs []string `query:"ids" validate:"required" oai:"description=批量选择文件ID列表"`
|
||||
IDs []string `json:"ids" validate:"required" oai:"description=批量选择文件ID列表"`
|
||||
FolderID string `json:"folder_id" validate:"required" oai:"description=更新归属文件夹ID"`
|
||||
}
|
||||
|
||||
type DocActionResult struct {
|
||||
|
Loading…
x
Reference in New Issue
Block a user