Cloudreve/routers/controllers/objects.go

38 lines
801 B
Go
Raw Normal View History

2019-11-30 15:09:56 +08:00
package controllers
import (
"context"
"github.com/HFO4/cloudreve/service/explorer"
"github.com/gin-gonic/gin"
)
// Delete 删除文件或目录
func Delete(c *gin.Context) {
// 创建上下文
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
var service explorer.ItemService
if err := c.ShouldBindJSON(&service); err == nil {
res := service.Delete(ctx, c)
c.JSON(200, res)
} else {
c.JSON(200, ErrorResponse(err))
}
}
2019-12-01 18:31:29 +08:00
// Move 移动文件或目录
func Move(c *gin.Context) {
// 创建上下文
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
var service explorer.ItemMoveService
if err := c.ShouldBindJSON(&service); err == nil {
res := service.Move(ctx, c)
c.JSON(200, res)
} else {
c.JSON(200, ErrorResponse(err))
}
}