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