Init V4 community edition (#2265)

* Init V4 community edition

* Init V4 community edition
This commit is contained in:
AaronLiu
2025-04-20 17:31:25 +08:00
committed by GitHub
parent da4e44b77a
commit 21d158db07
597 changed files with 119415 additions and 41692 deletions

View File

@@ -1,28 +1,27 @@
package controllers
import (
"github.com/cloudreve/Cloudreve/v3/service/explorer"
"errors"
"github.com/cloudreve/Cloudreve/v4/pkg/serializer"
"github.com/cloudreve/Cloudreve/v4/service/explorer"
"github.com/gin-gonic/gin"
)
// CreateDirectory 创建目录
func CreateDirectory(c *gin.Context) {
var service explorer.DirectoryService
if err := c.ShouldBindJSON(&service); err == nil {
res := service.CreateDirectory(c)
c.JSON(200, res)
} else {
c.JSON(200, ErrorResponse(err))
}
}
// ListDirectory 列出目录下内容
func ListDirectory(c *gin.Context) {
var service explorer.DirectoryService
if err := c.ShouldBindUri(&service); err == nil {
res := service.ListDirectory(c)
c.JSON(200, res)
} else {
c.JSON(200, ErrorResponse(err))
service := ParametersFromContext[*explorer.ListFileService](c, explorer.ListFileParameterCtx{})
resp, err := service.List(c)
if err != nil {
if errors.Is(err, explorer.ErrSSETakeOver) {
return
}
c.JSON(200, serializer.Err(c, err))
c.Abort()
return
}
c.JSON(200, serializer.Response{
Data: resp,
})
}