Test: middleware / file / folder

This commit is contained in:
HFO4
2019-12-03 21:25:10 +08:00
parent c15b8a047d
commit 362a7c389d
6 changed files with 243 additions and 11 deletions

View File

@@ -127,13 +127,13 @@ func DeleteFileByIDs(ids []uint) error {
return result.Error
}
// GetRecursiveByPaths 根据给定的文件路径(s)递归查找文件
func GetRecursiveByPaths(paths []string, uid uint) ([]File, error) {
files := make([]File, 0, len(paths))
search := util.BuildRegexp(paths, "^", "/", "|")
result := DB.Where("(user_id = ? and dir REGEXP ?) or (user_id = and dir in (?))", uid, search, uid, paths).Find(&files)
return files, result.Error
}
//// GetRecursiveByPaths 根据给定的文件路径(s)递归查找文件
//func GetRecursiveByPaths(paths []string, uid uint) ([]File, error) {
// files := make([]File, 0, len(paths))
// search := util.BuildRegexp(paths, "^", "/", "|")
// result := DB.Where("(user_id = ? and dir REGEXP ?) or (user_id = and dir in (?))", uid, search, uid, paths).Find(&files)
// return files, result.Error
//}
// GetFilesByParentIDs 根据父目录ID查找文件
func GetFilesByParentIDs(ids []uint, uid uint) ([]File, error) {