🚧 change path api resp struct

pull/548/head
微凉 2021-12-31 17:15:37 +08:00
parent 939c9cd5ac
commit cc217df924
1 changed files with 24 additions and 6 deletions

View File

@ -27,6 +27,12 @@ func Hide(files []model.File, path string) []model.File {
return files return files
} }
type PathResp struct {
Type string `json:"type"`
Driver string `json:"driver"`
Files []model.File `json:"files"`
}
func Path(c *gin.Context) { func Path(c *gin.Context) {
reqV, _ := c.Get("req") reqV, _ := c.Get("req")
req := reqV.(common.PathReq) req := reqV.(common.PathReq)
@ -39,8 +45,12 @@ func Path(c *gin.Context) {
files = Hide(files, req.Path) files = Hide(files, req.Path)
c.JSON(200, common.Resp{ c.JSON(200, common.Resp{
Code: 200, Code: 200,
Message: "folder", Message: "success",
Data: files, Data: PathResp{
Type: "folder",
Driver: "root",
Files: files,
},
}) })
return return
} }
@ -72,8 +82,12 @@ func Path(c *gin.Context) {
} }
c.JSON(200, common.Resp{ c.JSON(200, common.Resp{
Code: 200, Code: 200,
Message: "file", Message: "success",
Data: []*model.File{file}, Data: PathResp{
Type: "file",
Driver: driver.Config().Name,
Files: []model.File{*file},
},
}) })
} else { } else {
files = Hide(files, req.Path) files = Hide(files, req.Path)
@ -82,8 +96,12 @@ func Path(c *gin.Context) {
} }
c.JSON(200, common.Resp{ c.JSON(200, common.Resp{
Code: 200, Code: 200,
Message: "folder", Message: "success",
Data: files, Data: PathResp{
Type: "folder",
Driver: "root",
Files: files,
},
}) })
} }
} }