feat: search file under current folder

This commit is contained in:
HFO4
2022-04-29 20:03:52 +08:00
parent d51351eebd
commit 8ab0fe0e2f
8 changed files with 114 additions and 7 deletions

View File

@@ -15,6 +15,7 @@ import (
type ItemSearchService struct {
Type string `uri:"type" binding:"required"`
Keywords string `uri:"keywords" binding:"required"`
Path string `form:"path"`
}
// Search 执行搜索
@@ -26,6 +27,15 @@ func (service *ItemSearchService) Search(c *gin.Context) serializer.Response {
}
defer fs.Recycle()
if service.Path != "" {
ok, parent := fs.IsPathExist(service.Path)
if !ok {
return serializer.Err(serializer.CodeParentNotExist, "Cannot find parent folder", nil)
}
fs.Root = parent
}
switch service.Type {
case "keywords":
return service.SearchKeywords(c, fs, "%"+service.Keywords+"%")