mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Feat: WebDAV mount folders
This commit is contained in:
@@ -135,3 +135,15 @@ func UserStorage(c *gin.Context) {
|
||||
res := serializer.BuildUserStorageResponse(*currUser)
|
||||
c.JSON(200, res)
|
||||
}
|
||||
|
||||
// UserAvailablePolicies 用户存储策略设置
|
||||
func UserAvailablePolicies(c *gin.Context) {
|
||||
var service user.SettingService
|
||||
if err := c.ShouldBindUri(&service); err == nil {
|
||||
res := service.Policy(c, CurrentUser(c))
|
||||
c.JSON(200, res)
|
||||
} else {
|
||||
c.JSON(200, ErrorResponse(err))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -64,6 +64,17 @@ func DeleteWebDAVAccounts(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// DeleteWebDAVMounts 删除WebDAV挂载
|
||||
func DeleteWebDAVMounts(c *gin.Context) {
|
||||
var service setting.WebDAVListService
|
||||
if err := c.ShouldBindUri(&service); err == nil {
|
||||
res := service.Unmount(c, CurrentUser(c))
|
||||
c.JSON(200, res)
|
||||
} else {
|
||||
c.JSON(200, ErrorResponse(err))
|
||||
}
|
||||
}
|
||||
|
||||
// CreateWebDAVAccounts 创建WebDAV账户
|
||||
func CreateWebDAVAccounts(c *gin.Context) {
|
||||
var service setting.WebDAVAccountCreateService
|
||||
@@ -74,3 +85,14 @@ func CreateWebDAVAccounts(c *gin.Context) {
|
||||
c.JSON(200, ErrorResponse(err))
|
||||
}
|
||||
}
|
||||
|
||||
// CreateWebDAVMounts 创建WebDAV目录挂载
|
||||
func CreateWebDAVMounts(c *gin.Context) {
|
||||
var service setting.WebDAVMountCreateService
|
||||
if err := c.ShouldBindJSON(&service); err == nil {
|
||||
res := service.Create(c, CurrentUser(c))
|
||||
c.JSON(200, res)
|
||||
} else {
|
||||
c.JSON(200, ErrorResponse(err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,6 +253,13 @@ func InitMasterRouter() *gin.Engine {
|
||||
authn.PUT("", controllers.StartRegAuthn)
|
||||
authn.PUT("finish", controllers.FinishRegAuthn)
|
||||
}
|
||||
|
||||
// 用户设置
|
||||
setting := user.Group("setting")
|
||||
{
|
||||
// 获取用户可选存储策略
|
||||
setting.GET("policies", controllers.UserAvailablePolicies)
|
||||
}
|
||||
}
|
||||
|
||||
// 文件
|
||||
@@ -390,6 +397,13 @@ func InitMasterRouter() *gin.Engine {
|
||||
webdav.POST("accounts", controllers.CreateWebDAVAccounts)
|
||||
// 删除账号
|
||||
webdav.DELETE("accounts/:id", controllers.DeleteWebDAVAccounts)
|
||||
// 删除目录挂载
|
||||
webdav.DELETE("mount/:id",
|
||||
middleware.HashID(hashid.FolderID),
|
||||
controllers.DeleteWebDAVMounts,
|
||||
)
|
||||
// 创建目录挂载
|
||||
webdav.POST("mount", controllers.CreateWebDAVMounts)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user