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 {
 | 
					func JWTRequired(c *fiber.Ctx) error {
 | 
				
			||||||
	jwt := c.Get("Authorization")
 | 
						jwt := c.Get("Authorization")
 | 
				
			||||||
	if jwt == "" {
 | 
						if jwt == "" {
 | 
				
			||||||
		return c.Status(401).JSON(fiber.Map{"msg": "Unauthorized"})
 | 
							return fiber.ErrUnauthorized
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	claims, err := casdoorsdk.ParseJwtToken(jwt)
 | 
						claims, err := casdoorsdk.ParseJwtToken(jwt)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		log.Ctx(c.UserContext()).Error().Err(err).Msg("Unauthorized user")
 | 
							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)
 | 
						c.Locals(userClaimsKey, claims)
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
 | 
				
			|||||||
@ -26,7 +26,7 @@ func RegisterDocRouter(app *soda.Soda) {
 | 
				
			|||||||
		SetSummary("更新文档").
 | 
							SetSummary("更新文档").
 | 
				
			||||||
		AddJWTSecurity(JWTRequired).
 | 
							AddJWTSecurity(JWTRequired).
 | 
				
			||||||
		SetParameters(schema.DocID{}).
 | 
							SetParameters(schema.DocID{}).
 | 
				
			||||||
		SetJSONRequestBody(schema.ListDocQuery{}).
 | 
							SetJSONRequestBody(schema.UpdateDoc{}).
 | 
				
			||||||
		AddJSONResponse(200, schema.Doc{}).OK()
 | 
							AddJSONResponse(200, schema.Doc{}).OK()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	app.Delete("/docs/:id", nil).
 | 
						app.Delete("/docs/:id", nil).
 | 
				
			||||||
@ -45,27 +45,27 @@ func RegisterDocRouter(app *soda.Soda) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	app.Post("/docs/batch/update", nil).
 | 
						app.Post("/docs/batch/update", nil).
 | 
				
			||||||
		AddTags("文档管理").
 | 
							AddTags("文档管理").
 | 
				
			||||||
		SetSummary("批量-文件删除").
 | 
							SetSummary("批量-文件更新").
 | 
				
			||||||
		AddJWTSecurity(JWTRequired).
 | 
							AddJWTSecurity(JWTRequired).
 | 
				
			||||||
		SetJSONRequestBody(schema.DocsBatchUpdate{}).
 | 
							SetJSONRequestBody(schema.DocsBatchUpdate{}).
 | 
				
			||||||
		AddJSONResponse(200, schema.DocsBatchResults{}).OK()
 | 
							AddJSONResponse(200, schema.DocsBatchResults{}).OK()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	app.Get("/doc-folders", nil).
 | 
						app.Get("/doc-folders", nil).
 | 
				
			||||||
		AddTags("文档管理").
 | 
							AddTags("文件夹管理").
 | 
				
			||||||
		SetSummary("获取文件夹树").
 | 
							SetSummary("获取文件夹树").
 | 
				
			||||||
		AddJWTSecurity(JWTRequired).
 | 
							AddJWTSecurity(JWTRequired).
 | 
				
			||||||
		SetParameters(schema.GetDocFolderTree{}).
 | 
							SetParameters(schema.GetDocFolderTree{}).
 | 
				
			||||||
		AddJSONResponse(200, schema.DocFolderWithChildren{}).OK()
 | 
							AddJSONResponse(200, schema.DocFolderWithChildren{}).OK()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	app.Post("/doc-folders", nil).
 | 
						app.Post("/doc-folders", nil).
 | 
				
			||||||
		AddTags("文档管理").
 | 
							AddTags("文件夹管理").
 | 
				
			||||||
		SetSummary("新建文件夹").
 | 
							SetSummary("新建文件夹").
 | 
				
			||||||
		AddJWTSecurity(JWTRequired).
 | 
							AddJWTSecurity(JWTRequired).
 | 
				
			||||||
		SetJSONRequestBody(schema.CreateDocFolder{}).
 | 
							SetJSONRequestBody(schema.CreateDocFolder{}).
 | 
				
			||||||
		AddJSONResponse(200, schema.DocFolder{}).OK()
 | 
							AddJSONResponse(200, schema.DocFolder{}).OK()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	app.Put("/doc-folders/:id", nil).
 | 
						app.Put("/doc-folders/:id", nil).
 | 
				
			||||||
		AddTags("文档管理").
 | 
							AddTags("文件夹管理").
 | 
				
			||||||
		SetSummary("更新文件夹").
 | 
							SetSummary("更新文件夹").
 | 
				
			||||||
		AddJWTSecurity(JWTRequired).
 | 
							AddJWTSecurity(JWTRequired).
 | 
				
			||||||
		SetParameters(schema.DocFolderID{}).
 | 
							SetParameters(schema.DocFolderID{}).
 | 
				
			||||||
@ -73,7 +73,7 @@ func RegisterDocRouter(app *soda.Soda) {
 | 
				
			|||||||
		AddJSONResponse(200, schema.DocFolder{}).OK()
 | 
							AddJSONResponse(200, schema.DocFolder{}).OK()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	app.Delete("/doc-folders/:id", nil).
 | 
						app.Delete("/doc-folders/:id", nil).
 | 
				
			||||||
		AddTags("文档管理").
 | 
							AddTags("文件夹管理").
 | 
				
			||||||
		SetSummary("删除文件夹").
 | 
							SetSummary("删除文件夹").
 | 
				
			||||||
		AddJWTSecurity(JWTRequired).
 | 
							AddJWTSecurity(JWTRequired).
 | 
				
			||||||
		SetParameters(schema.DocFolderID{}).
 | 
							SetParameters(schema.DocFolderID{}).
 | 
				
			||||||
 | 
				
			|||||||
@ -75,16 +75,16 @@ type UpdateDoc struct {
 | 
				
			|||||||
type ListDocQuery struct {
 | 
					type ListDocQuery struct {
 | 
				
			||||||
	PageableQuery
 | 
						PageableQuery
 | 
				
			||||||
	SortableQuery
 | 
						SortableQuery
 | 
				
			||||||
	FolderIDs *[]string `query:"folder_ids" validate:"required" oai:"description=归属文件夹ID"`
 | 
						FolderIDs *[]string `query:"folder_ids" oai:"description=筛选归属文件夹ID"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type DocsBatchDelete struct {
 | 
					type DocsBatchDelete struct {
 | 
				
			||||||
	IDs      []string `query:"ids" validate:"required" oai:"description=批量选择文件ID列表"`
 | 
						IDs []string `json:"ids" validate:"required" oai:"description=批量选择文件ID列表"`
 | 
				
			||||||
	FolderID string   `            validate:"required" oai:"description=更新归属文件夹ID"   json:"folder_id"`
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type DocsBatchUpdate struct {
 | 
					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 {
 | 
					type DocActionResult struct {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user