Finish the delete method.

This commit is contained in:
zicla 2019-04-21 15:54:08 +08:00
parent 18dc7f7e2c
commit ee9b049db4
2 changed files with 22 additions and 0 deletions

View File

@ -159,6 +159,10 @@ func (this *DavController) Index(writer http.ResponseWriter, request *http.Reque
//请求文件详情(下载)
this.davService.HandleGet(writer, request, user, subPath)
} else if method == "DELETE" {
//删除文件
this.davService.HandleDelete(writer, request, user, subPath)
} else {
this.PanicBadRequest("该方法还不支持。%s", method)

View File

@ -225,3 +225,21 @@ func (this *DavService) HandleGet(writer http.ResponseWriter, request *http.Requ
this.matterService.DownloadFile(writer, request, matter.AbsolutePath(), matter.Name, false)
}
//删除文件
func (this *DavService) HandleDelete(writer http.ResponseWriter, request *http.Request, user *User, subPath string) {
fmt.Printf("DELETE %s\n", subPath)
//寻找符合条件的matter.
var matter *Matter
//如果是空或者/就是请求根目录
if subPath == "" || subPath == "/" {
matter = NewRootMatter(user)
} else {
matter = this.matterDao.checkByUserUuidAndPath(user.Uuid, subPath)
}
this.matterDao.Delete(matter)
}