🚧 构建目录树
This commit is contained in:
30
server/controllers/v2/list.go
Normal file
30
server/controllers/v2/list.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package v2
|
||||
|
||||
import (
|
||||
"github.com/Xhofe/alist/server/controllers"
|
||||
"github.com/Xhofe/alist/server/models"
|
||||
"github.com/gin-gonic/gin"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// list request bean
|
||||
type ListReq struct {
|
||||
Path string `json:"path"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
// handle list request
|
||||
func List(c *gin.Context) {
|
||||
var list ListReq
|
||||
if err := c.ShouldBindJSON(&list); err != nil {
|
||||
c.JSON(200, controllers.MetaResponse(400, "Bad Request."))
|
||||
return
|
||||
}
|
||||
log.Debugf("list:%+v", list)
|
||||
files, err := models.GetFilesByParentPath(list.Path)
|
||||
if err != nil {
|
||||
c.JSON(200, controllers.MetaResponse(500, err.Error()))
|
||||
return
|
||||
}
|
||||
c.JSON(200, controllers.DataResponse(files))
|
||||
}
|
Reference in New Issue
Block a user